3

According to Why is cmake file GLOB evil?, using glob as a target sources is a bad practice. I've tried to produce the described situation.

CMakeLists.txt

file(GLOB SOURCES "src/*.cpp")
add_executable(main "${SOURCES}")

src/main.cpp

#include <iostream>

int main() {
    return 0;
}

I am running cmake once. After that I am creating an invalid cpp file src/test.cpp and running cmake once more, followed by make. According to situation described in the post I've to get everything compiled because cmake doesn't track this file. But in reality cmake does detect a change and compilation fails. Did I understand it wrong? I am using cmake version 3.17.1

1 Answers1

1

In the post that you quoted, they don't run cmake after your new file creation.

They only run make and the make rule of Makefile generated by CMake should re-run CMake if the cache is outdated.

But in this case CMake doesn't detect the outdated cache and do not relaunch CMake to include your test.cpp.