如何在命令行设置CMake选项()
我创build了一个CMakeLists.txt,其中包含以下内容
project(P4V) cmake_minimum_required(VERSION 2.6) option(BUILD_STATIC_LIBS "Build the static library" ON) option(BUILD_SHARED_LIBS "Build the shared library" ON) option(BUILD_TESTS "Build test programs" OFF) include_directories(${CMAKE_SOURCE_DIR}/include) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set(CMAKE_BUILD_TYPE Release) add_subdirectory(src) if(BUILD_TESTS) add_subdirectory(tests) endif(BUILD_TESTS)
默认情况下,BUILD_TESTS是closures的,如何在没有CMake GUI的情况下打开它,但使用cmake命令本身? 我尝试了以下,但它不起作用
cmake .. -G %1 -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON
删除CMakeCache.txt文件并尝试这个:
cmake -G %1 -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_TESTS=ON ..
包含path之前,必须input所有的命令行定义。