Note that there are some explanatory texts on larger screens.

plurals
  1. POUpper level seeing a lower level option
    primarykey
    data
    text
    <p>I have a lower level project that builds several libraries. The upper level takes the libs and links them into many executables. The lower level has this option:</p> <pre><code>option(TOOLA_SUPPORT "Ena/Disable toolA support" OFF) </code></pre> <p>I'd like to get the upper level build to see the <code>TOOLA_SUPPORT</code> flag from the lower level build. As it is now, there are 2 <code>TOOLA_SUPPORT</code> flags. One at the lower, the other at the upper level builds. This is a hassle as they both need to be in the same state for a successful build.</p> <p>I'm not sure how to get one CMakeLists.txt file to inherit a flag from another (cache). (Only want this one flag, not the whole lower CMakeLists.txt/cache settings.) What commands might help, or where to look for info? </p> <p><strong>Edit_1</strong>:<br> <code>dirUpper/src/CMakeLists.txt</code> (Does NOT contain dirLower) I'd like this cmakelists to "inherit" the cache var TOOLA_SUPPORT from <strong>dirLower</strong>/src/CMakeLists.txt</p> <pre><code>option(TOOLA_SUPPORT "" OFF) add_subdirectory(${dirLower}/src ${dirLower}/lib EXCLUDE_FROM_ALL) if(TOOLA_SUPPORT) link_directories(blah bla bla) else() link_directories(blah bla) endif() </code></pre> <p><code>dirLower/src/CMakeLists.txt</code> (Is not part of the dirUpper tree) I'd like to pass TOOLA_SUPPORT from this cmakelists, to <strong>dirUpper</strong>/src/cmakelists.txt </p> <pre><code>IF(NOT (${COMPILER_FLAGS} MATCHES "-Wall")) #this only applies to dirLower MESSAGE(FATAL_ERROR "compiler flag not properly set") #will crash the dirUpper 'config' ENDIF() OPTION(TOOLA_SUPPORT "" OFF) IF(TOOLA_SUPPORT) INCLUDE_DIRECTORIES(some/dir/include) SET(TOOLA_SUPPORT ON CACHE "" FORCE PARENT_SCOPE) ELSE() MESSAGE("TOOLA is not supported") SET(TOOLA_SUPPORT OFF CACHE "" FORCE PARENT_SCOPE) ENDIF() </code></pre> <p>When I run the dirLower file, I get a cmake warning telling me there is no parent for it. (Not part of the dirUpper tree)<br> When I run the dirUpper file, I get a fatal error due to the COMPILER_FLAG test in the dirLower file. When I bypass this issue, Im not seeing the TOOLA_SUPPORT setting being inherited from the dirLower.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload