How to change the build type to Release mode in cmake?

前端 未结 5 997
清歌不尽
清歌不尽 2020-12-04 10:42

I am trying to build a project in Release mode. By default it is built in debug mode. I am setting the variable CMAKE_BUILD_TYPE to \"Release\" in CMakeLi

5条回答
  •  佛祖请我去吃肉
    2020-12-04 11:34

    I checked it with Visual Studio 2015 and cmake 3.3 .

    Short answer

    Link

    cmake --build {BUILD_DIR_PATH} --target ALL_BUILD --config {BUILD_TYPE}
    

    Example

    cmake --build . --target ALL_BUILD --config Release
    

    Long answer

    cmake -G{GENERATOR_NAME} -B{BUILD_DIR_PATH} -H{SOURCE_DIR_PATH}
    
    cmake --build {BUILD_DIR_PATH} --target ALL_BUILD --config {BUILD_TYPE}
    

    Example

    cmake -GVisual Studio 14 -Bbuild/win32/x86 -H.    
    
    cmake --build build/win32/x86 --target ALL_BUILD --config Release
    

    Additional info

    • "-G" - specifies the generator name

    • "-B" - specifies path to the build folder

    • "-H" - specifies path to the source folder

提交回复
热议问题