cmake use one cmakelist.txt for a project with subdirectories -



cmake use one cmakelist.txt for a project with subdirectories -

i construction code in multiple subdirs dont want create new cmakelist.txt in each new subdir.

my folder construction this:

project >cmakelist.txt >build >src >main.cpp >multiple_subdirs_or_(c|h)pp_files_with_more_subdirs_or_(c|h)pp_files

my cmakelist.txt looks this:

... file(glob_recurse cpps relative ${cmake_current_list_dir} "src/*.cpp") file(glob_recurse hpps relative ${cmake_current_list_dir} "src/*.hpp") #remove files main list(remove_item cpps "src/test.cpp") #bins add_executable(test src/test.cpp src/test.cpp ${hpps} ${cpps}) #same problem if used instead of other add_executable add_library(foo object ${cpps} ${hpps}) add_executable(test src/test.cpp $<target_objects:foo>)

the problem file:

source files created after execution of cmake not compiled , build fails if used. predicted http://www.cmake.org/cmake/help/v3.0/command/file.html in section glob:

we not recommend using glob collect list of source files source tree. if no cmakelists.txt file changes when source added or removed generated build scheme cannot know when inquire cmake regenerate.

the question: possible utilize single cmakelist.txt project multiple sub directories? (without problems of file(glob ...) )

you have 2 totally unrelated things here.

first, can utilize single cmakelists.txt file whole project? yes, of course of study can (although i'd not go way after project has reached size), , you're doing this.

second, problem glob. quoted part of documentation states problems utilize of glob has. cannot avoided @ moment if want go on using glob, part of cmake design distinguish between done during configure , build time. alternative list files manually. whether in single cmakelists.txt file in projects main directory, or in multiple files across subdirectories not matter.

cmake

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -