I would like to use the same cmake file as a script and a include file
do_something.cmake:
function(do_something)
# do something
endfunction
if(CMAKE_IS_SCRIPTING_MODE) # this variable does not exist!
do_something()
endif
This way i can easyly call my scripts from a CMake project and from the shell. How can this be done?
I think you are looking for CMAKE_SCRIPT_MODE_FILE
When run in cmake(1) -P script mode, CMake sets this variable to the full path of the script file. When run to configure a CMakeLists.txt file, this variable is not set.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With