Cmake 中的 Variables that Provide Information和构建模式

发布于:2022-11-03 ⋅ 阅读:(382) ⋅ 点赞:(0)

 Variables that Provide Information (cmake-variables(7) — CMake 3.0.2 Documentation

  1: CMAKE_INCLUDE_CURRENT_DIR

       set (CMAKE_INCLUDE_CURRENT_DIR ON)  //自动添加CMAKE_CURRENT_BINARY_DIR和CMAKE_CURRENT_SOURCE_DIR到当前处理的CMakeLists.txt;

 2:    CMAKE_CURRENT_SOURCE_DIR:指的是当前处理的CMakeLists.txt所在的路径;

 3:    CMAKE_CURRENT_BINARY_DIR:如果是in-source编译,则跟CMAKE_CURRENT_SOURCE_DIR一致;如果是out-of-source,指的是target编译目录;

 in-source build 和 out-of-source build 

   in-source build:(源码中构建) in-source是指在顶层CmakeLists.txt中中直接执行

    cmake  .

  out-of-source build:是指在非CmakeLists.txt中目录执行 cmake 

//假设顶层的CMakeLists.txt在bulid同级目录
mkdir build
cd ./build
cmake ../
make


网站公告

今日签到

点亮在社区的每一天
去签到