I would like to make a custom target which could build a local existing make based project. Something like
find_file(SetEnvFile
NAME set-env.sh
PATHS ${path-discovered-during-configuration}/*
REQUIRED
)
add_custom_target(Foo
COMMAND source ${SetEnvFile}
COMMAND $(MAKE)
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
However, I’ve found I actually can’t use source
in my command. Do I have another option here? The trick in my situation is that CMake configuration (in my case CPM.cmake) figure out where the file is. So I can’t actually source it before running cmake.
The only workaround I can think of right now is to do something like
find_file(SetEnvFile
NAME set-env.sh
PATHS ${path-discovered-during-configuration}/*
REQUIRED
)
add_custom_target(Foo
COMMAND ./customBuildScript.sh ${SetEnvFile}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)