Project build configuration in CMake

后端 未结 2 829
野性不改
野性不改 2021-01-03 07:49

My question is very similar to CMake : Changing name of Visual Studio and Xcode exectuables depending on configuration in a project generated by CMake. In that post the outp

2条回答
  •  旧巷少年郎
    2021-01-03 08:06

    There is always another way:

      if(CMAKE_BUILD_TYPE MATCHES "release")
    
        SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE})
    
      else(CMAKE_BUILD_TYPE MATCHES "debug")
    
         SET(CMAKE_BUILD_TYPE "debug")
    
       endif(CMAKE_BUILD_TYPE MATCHES "release")
    

    We can use the variable CMAKE_BUILD_TYPE. We can also change this variable at the beginning of invoking CMAKE:

    cmake .. -DCMAKE_BUILD_TYPE:STRING=debug
    

    Then we can use this variable as an indicator of build configuration.

提交回复
热议问题