Come posso chiamare un file cmake in modalità di script (-P) da un altro file cmake, quindi questo "cmake child" conosce tutte le variabili del suo genitore? Perché, se ho un sacco di variabili di cui il bambino ha bisogno, devo scrivere molte opzioni -D, e voglio evitarlo.CMake file in modalità script che eredita le variabili
Esempio:
// CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(teststr "Hello World!")
add_custom_command(test
${CMAKE_COMMAND} -Dteststr=${teststr} -P test.cmake
)
// test.cmake
message("${teststr}")
$ cmake .
$ make test
Hello world!
Built target test
funziona bene !. Ma, senza "-Dteststr":
// CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
set(teststr "Hello World!")
add_custom_command(test
${CMAKE_COMMAND} -P test.cmake
)
// test.cmake
message("${teststr}")
$ cmake .
$ make test
Built target test
Naturalmente, fermo opzione -D, il "teststr" variabile, in test.cmake, è disinserito, e pertanto, l'uscita è vuota.
Qualsiasi opzione per chiamare test.cmake in "modalità eredità" o qualcosa del genere?