Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake test if i am in scripting mode

Tags:

cmake

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?

like image 442
kuga Avatar asked Nov 15 '25 19:11

kuga


1 Answers

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.

like image 72
compor Avatar answered Nov 18 '25 19:11

compor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!