I was having some troubles using the GENERATE_EXE_SCRIPT macro from cmake/modules/FairMacros.cmake.
I wanted to place the created .sh files under ${PROJECT_BINARY_DIR}/bin.
However, the scripts were not created under ${PROJECT_BINARY_DIR}/bin, due to my path naming:
${PROJECT_BINARY_DIR} = ${PROJECT_SOURCE_DIR}_build.
Due to the string replacement done in the GENERATE_EXE_SCRIPT macro, it replaces the ${PROJECT_SOURCE_DIR} part in the passed in path and replaces it with the ${PROJECT_BINARY_DIR}. This resulted for me in a final path of
${PROJECT_BINARY_DIR}_build/bin instead of ${PROJECT_BINARY_DIR}/bin, which was unexpected.
I am blissfully ignorant to why the GENERATE_EXE_SCRIPT does this string replacement. Would it not be possible to take the target path and the exe name as input parameters? This would make the behaviour of the macro more predictable.
Macro(Generate_Exe_Script _TargetPath _ExeName)
Message("PATH: ${_TargetPath}")
Message("ExeName: ${_ExeName}")
set(shell_script_name "${_ExeName}.sh")
Message("shell_script_name: ${shell_script_name}")
set(my_exe_name ${EXECUTABLE_OUTPUT_PATH}/${_ExeName})
Write_Geant4Data_Variables_sh()
configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/run_binary.sh.in
${_TargetPath}/${shell_script_name}
)
EXEC_PROGRAM(/bin/chmod ARGS "u+x ${_TargetPath}/${shell_script_name}" OUTPUT_VARIABLE tmp )
EndMacro(Generate_Exe_Script)
Otherwise the path parameter passed to GENERATE_EXE_SCRIPT as to be given in such a way that it accounts for the implicit transformation in the GENERATE_EXE_SCRIPT macro, which makes using it confusing and less straight forward.
I was having some troubles using the
GENERATE_EXE_SCRIPTmacro from cmake/modules/FairMacros.cmake.I wanted to place the created .sh files under
${PROJECT_BINARY_DIR}/bin.However, the scripts were not created under
${PROJECT_BINARY_DIR}/bin, due to my path naming:${PROJECT_BINARY_DIR} = ${PROJECT_SOURCE_DIR}_build.Due to the string replacement done in the
GENERATE_EXE_SCRIPTmacro, it replaces the${PROJECT_SOURCE_DIR}part in the passed in path and replaces it with the${PROJECT_BINARY_DIR}. This resulted for me in a final path of${PROJECT_BINARY_DIR}_build/bininstead of${PROJECT_BINARY_DIR}/bin, which was unexpected.I am blissfully ignorant to why the
GENERATE_EXE_SCRIPTdoes this string replacement. Would it not be possible to take the target path and the exe name as input parameters? This would make the behaviour of the macro more predictable.Otherwise the path parameter passed to
GENERATE_EXE_SCRIPTas to be given in such a way that it accounts for the implicit transformation in theGENERATE_EXE_SCRIPTmacro, which makes using it confusing and less straight forward.