I often find it more convenient to call add_library() and add_executable() first, apply properties to them etc., and then later add the sources to them with target_sources() (usually in other CMake files via add_subdirectory). Obviously, all my targets will eventually have sources added.
However, CMake completely errors out as soon as it sees me creating a target with no sources - it doesn't even care that I am adding sources to it later. Example: "You have called ADD_LIBRARY for library mylib without any source files. This typically indicates a problem with your CMakeLists.txt file" I have been working around this by adding a dummy source file or adding one of the sources ahead of time, but this is somewhat inconvenient. Is there a better way to do this? Alternatively, could CMake be changed to allow creating a target that initially has no sources as long as it eventually has sources added to it? Note: I am familiar with the approach of gathering a list of source files before creating the target, but this is really inconvenient to do across multiple files in multiple directories. It is easier to call target_sources() instead. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake