Change CMAKE_SOURCE_DIR

Is it possible to change CMAKE_SOURCE_DIRCMake to a “trick” to the idea that the top-level file CMakeLists.txtis somewhere else?

I have the following directory structure:

\src            <--- not a repository
    \cmake      <--- repository
    \common     <--- repository
    \project1   <--- repository
    ...
    CMakeLists.txt   <--- would like to locate this inside the cmake repository

The problem with the above structure is that the top-level CMakeLists.txt lives outside of any repository, so it's impossible to check for changes.

Is it possible to find this file inside a directory cmake(which contains nothing else) and still run CMake "as if" the file was in a directory src?

NOTE

  • I was a gifted client with a shared repository layout, no need to tell me that this is causing problems.
  • CMakeLists.txt src, , , , .
  • CMAKE_SOURCE_DIR script, .
+5
1

CMAKE_SOURCE_DIR .

: CMake ( add_subdirectory), , . , , CMAKE_SOURCE_DIR CMAKE_BINARY_DIR , CMake . PROJECT_SOURCE_DIR PROJECT_BINARY_DIR .

, , : , , CMake, , , . ExternalProject .

, , , , , CMake script, CMAKE_*_DIR PROJECT_*_DIR .

+7

Source: https://habr.com/ru/post/1530358/


All Articles