Home CMake <PROJECT-NAME>_SOURCE_DIR Variable Scope
Reply: 0


user975 Published in March 24, 2018, 12:29 am

Based on the thread "cmake variable scope, add_subdirectory", the CMake set command will set the variable in the current scope only, unless the PARENT_SCOPE parameter is specified.

Recently when I was looking at the project command, per CMake doc, variables <PROJECT-NAME>_SOURCE_DIR and <PROJECT-NAME>_BINARY_DIR will be set. But it didn't mention what is the scope of these variables. Can these variable be used in other subdirectory? For example:

|- root | |- CMakeLists.txt // add_subdirectory(proj1); add_subdirectory(proj2) | | | |- proj1 | | |- CMakeLists.txt // project(proj1) | | | |- proj2 | | |- CMakeLists.txt // Does this have access to proj1_SOURCE_DIR or // poj1_BINARY_DIR?

What about variables for other command like Find_Package? What is the scope of the <Module>_FOUND variable? Thanks!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301771 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO