Tasks for configuring CMake jobs

Imagine the following situation:

I have a folder "project", in this folder there is a folder "src" and 2 files "1.cpp" and "2.cpp". Each individual .cpp produces a single executable file. After cmake generates makefiles, I want to be able to do the following:

  • specify that I want to create the executable file "1" or "2" or both
  • specify that I want to create all executables in debug mode
  • indicate that I want to create all executables in release mode
  • specify that I want to create all executable files in release and debug modes

so I want to write the following:

  • (c) make / anything 1
  • (c) make / anything 2
  • (c) make / anything all-release
  • (c) make / anything all-debug
  • (c) make / anything all-debug-and-release

? !

+3
1

CMakeLists.txt , src ( add_subdirectory). "src" CMakeLists.txt, , . , :

make 1 2

/, cmake CMAKE_BUILD_TYPE. , :

IF( NOT CMAKE_BUILD_TYPE )
  SET( CMAKE_BUILD_TYPE Debug ) 
  SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG" )
ENDIF( NOT CMAKE_BUILD_TYPE )

CMakeLists.txt

make edit_cache

ncurses , CMAKE_BUILD_TYPE .

+3

Source: https://habr.com/ru/post/1796472/


All Articles