#设置输出目录--判断release还是debug if (CMAKE_BUILD_TYPE) string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE) if (${BUILD_TYPE} STREQUAL "debug") set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") elseif(CMAKE_BUILD_TYPE STREQUAL "release") set (CMAKE_BUILD_TYPE "Release") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wall -O3") else() set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") message("set Default CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") endif() else() set (CMAKE_BUILD_TYPE "Debug") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0") message("set Default CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}") endif() message(STATUS "${PROJECT_NAME} CMAKE_BUILD_TYPE : ${CMAKE_BUILD_TYPE}")
经测试,当不设置CMAKE_BUILD_TYPE或输错时,设置默认Debug,其余不区分大小写
PS F:\Project\FK\build> cmake .. -DCMAKE_BUILD_TYPE:STRING=debug -- FK_BIN_DIR :/cygdrive/f/Project/FK/bin -- FK_COMMON_DIR :/cygdrive/f/Project/FK/common -- FK_INCLUDE_DIR :/cygdrive/f/Project/FK/include -- FK_LIB_DIR :/cygdrive/f/Project/FK/lib -- FK_SOURCE_DIR :/cygdrive/f/Project/FK/Source -- FKFramework CMAKE_BUILD_TYPE : Debug -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/f/Project/FK/build PS F:\Project\FK\build> cmake .. -DCMAKE_BUILD_TYPE:STRING=release -- FK_BIN_DIR :/cygdrive/f/Project/FK/bin -- FK_COMMON_DIR :/cygdrive/f/Project/FK/common -- FK_INCLUDE_DIR :/cygdrive/f/Project/FK/include -- FK_LIB_DIR :/cygdrive/f/Project/FK/lib -- FK_SOURCE_DIR :/cygdrive/f/Project/FK/Source -- FKFramework CMAKE_BUILD_TYPE : Release -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/f/Project/FK/build PS F:\Project\FK\build> cmake .. -- FK_BIN_DIR :/cygdrive/f/Project/FK/bin -- FK_COMMON_DIR :/cygdrive/f/Project/FK/common -- FK_INCLUDE_DIR :/cygdrive/f/Project/FK/include -- FK_LIB_DIR :/cygdrive/f/Project/FK/lib -- FK_SOURCE_DIR :/cygdrive/f/Project/FK/Source -- FKFramework CMAKE_BUILD_TYPE : Release -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/f/Project/FK/build PS F:\Project\FK\build> cmake .. -DCMAKE_BUILD_TYPE:STRING=release5555 -- FK_BIN_DIR :/cygdrive/f/Project/FK/bin -- FK_COMMON_DIR :/cygdrive/f/Project/FK/common -- FK_INCLUDE_DIR :/cygdrive/f/Project/FK/include -- FK_LIB_DIR :/cygdrive/f/Project/FK/lib -- FK_SOURCE_DIR :/cygdrive/f/Project/FK/Source set Default CMAKE_BUILD_TYPE : Debug -- FKFramework CMAKE_BUILD_TYPE : Debug -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/f/Project/FK/build PS F:\Project\FK\build>
还没有评论,来说两句吧...