aux_source_directory Find all source files in a directory.
aux_source_directory( )
Collects the names of all the source files in the specified directory and stores the list in the provided. This command is intended to be used by projects that use explicit template instantiation. Template instantiation files can be stored in a "Templates" subdirectory and collected automatically using this command to avoid manually listing all instantiations.
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. Normally the generated build system knows when it needs to rerun CMake because the CMakeLists.txt file is modified to add a new source. When the source is just added to the directory without modifying this file, one would have to manually rerun CMake to generate a build system incorporating the new file.
OK, but what if I'm not using a build system like Buildbot which was suggested earlier? I'm not pr0^ (nor environmentally detrimental) enough to have computers running all the time to react every time my CMake files are updated anyway. So do I really need to care about this? I would invoke CMake manually every time I wanted to rebuild stuff anyway, which wouldn't be every time I add a file. So wouldn't I be better off, saving time, by using this command instead, in my use case?
EDIT:Another question... Trying to figure out how to make CMake enforce a C++14 flag. But all suggestions I find are something like this:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
But that's specific. I thought the point of CMake was to be underspecific so that stuff could be resolved for specific platforms/compilers/etc? Because for LLVM I want/need
-std=gnu++14 instead. Does that mean I have to write a bunch of
#ifdef-like things per platform in my CMakeLists anyway..?
EDIT 2:Okay, seems it can be done in a generic way after all:
https://cmake.org/cmake/help/v3.1/prop_tgt/CXX_STANDARD.htmlGoing to give it a try...
EDIT 3:Nope, doesn't work. Xcode project just end up set to "compiler default", not the C++14 options.
EDIT 4:... OK, it
does work. It just doesn't show up in the project's build settings in Xcode. But if I add this, the project compiles. If I don't, it doesn't. Despite build settings looking no different. Okay then.