You cannot directly access CMake cache variables from ctest -S script.
However, you could:
- enable third-party CMake script in ctest -S script with "enable" (after the update step, so the source tree is updated)
- read the CMakeCache.txt file after the configuration step to pull out the cache of interest
- add code to your CMakeLists.txt file to write a mini-script that contains only the information you are looking for.
For (1), the code will look something like this:
include(${CTEST_SOURCE_DIRECTORY}/path/to/3rdParty/script.cmake)
It would be real if the script does only simple things, such as given values โโof variables, which you can then reference. If it performs any CMake-configure-time actions, such as find_library or add_executable, then you should not do this.
For (2):
file(STRINGS ${CTEST_BINARY_DIRECTORY}/CMakeCache.txt result REGEX "^CURSES_LIBRARY:FILEPATH=(.*)$") message("result='${result}'") string(REGEX REPLACE "^CURSES_LIBRARY:FILEPATH=(.*)$" "\\1" filename "${result}") message("filename='${filename}'")
For (3):
In the CMakeLists.txt file:
file(WRITE "${CMAKE_BINARY_DIR}/mini-script.cmake" " set(supp_file \"${supp_file_location}\") ")
In ctest -S script after calling ctest_configure:
include("${CTEST_BINARY_DIRECTORY}/mini-script.cmake") message("supp_file='${supp_file}'")
source share