我想要使用相同的cmake文件作为脚本和包含文件。
do_something.cmake:
这样我就可以轻松地从CMake项目和shell中调用我的脚本。如何做到这一点?
do_something.cmake:
function(do_something)
# do something
endfunction
if(CMAKE_IS_SCRIPTING_MODE) # this variable does not exist!
do_something()
endif
这样我就可以轻松地从CMake项目和shell中调用我的脚本。如何做到这一点?
CMAKE_SCRIPT_MODE_FILE
。 - comporif(NOT CMAKE_PARENT_LIST_FILE)
就足够了。 - kuga