Are CMAKE_SOURCE_DIR and PROJECT_SOURCE_DIR the same in CMake?

前端 未结 2 1763
悲&欢浪女
悲&欢浪女 2021-01-30 00:18

This page contains a good summary of variables CMake already defines for us. I feel that some variables are the same. Take the example of CMAKE_SOURCE_DIR and

2条回答
  •  爱一瞬间的悲伤
    2021-01-30 00:52

    Following Fraser's excellent answer.

    CMAKE_CURRENT_SOURCE_DIR is the build directory being processed.

    Let's say you have a directory called Inner1 containing a CMakeLists.txt file without calling project inside of it. Then PROJECT_SOURCE_DIR is not set with Inner1's dir path, but the CMAKE_CURRENT_SOURCE_DIR is set when being processed.

    You may also find CMAKE_CURRENT_LIST_DIR interesting and the definition of listfile useful.

提交回复
热议问题