1

My CMakeLists.txt looks like this:

project(project_name)
cmake_minimum_required(VERSION 2.8)
aux_source_directory("src" SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})

set(CMAKE_C_FLAGS_DEBUG "-std=gnu99 -Wall -pedantic -g")
set(CMAKE_C_FLAGS_RELEASE "-std=gnu99 -O3")

now I added another file, src/constants.h. I ran CMake through the GUI. Unfortunately, the new file doesn't appear in Qt Creator.

What am I doing wrong?

marmistrz
  • 5,974
  • 10
  • 42
  • 94
  • 1
    Please don't glob your files. From [`aux_source_directory()`](https://cmake.org/cmake/help/v3.3/command/aux_source_directory.html) documentation: "It is tempting to use this command to avoid writing the list of source files for a library or executable target. While this seems to work, there is no way for CMake to generate a build system that knows when a new source file has been added." See also [Why is cmake file GLOB evil?](http://stackoverflow.com/questions/32411963/why-is-cmake-file-glob-evil). – Florian Apr 21 '16 at 12:29
  • Well, I noticed that after adding the file `src/constants.c`, it works. Why doesn't it working only with a header? – marmistrz Apr 21 '16 at 12:31
  • 1
    Out of my experience it only works if you also touch one of your project's `CMakeLists.txt` files. CMake generates dependencies to the `CMakeLists.txt` files into the make/build environment, but it will not rerun CMake configuration process if a file was added to the file system (it simply doesn't know something has changed in that case). – Florian Apr 21 '16 at 12:34

1 Answers1

-1

Close project in Qt Creator and load again.