include_guard() include(JPPGetDirInfo) include(JPPInitCustomProperties) # # jpp_add_script(scripts) is a convenience function # to copy and install scripts into dest in a single command. # scripts should be file(s), not directories # # The install occurs only in the installation phase (if any) # and puts each script of scripts into : # # - ${CMAKE_INSTALL_BINDIR} # - ${CMAKE_INSTALL_PREFIX}/examples if script is an example # (as computed by the jpp_get_dir_info function) # # The copy always happens at configure time # and puts each script of scripts into : # # - ${KM3NET_JPP_STAGE_DIR}/${CMAKE_INSTALL_BINDIR} # - ${KM3NET_JPP_STAGE_DIR}/examples if # script is an example # (as computed by the jpp_get_dir_info function) # function(jpp_add_script scripts) jpp_get_dir_info(IS_EXAMPLE is_example PACKAGE package BASE base) foreach(script ${scripts}) get_filename_component(adir ${script} ABSOLUTE) if(IS_DIRECTORY ${adir}) message(FATAL_ERROR "${script} is a directory. Expecting a file") else() cmake_path(GET script FILENAME basename) cmake_path(REMOVE_EXTENSION basename OUTPUT_VARIABLE targetBaseName) jpp_name_target(${targetBaseName} NAME targetName IS_SCRIPT) add_custom_target(${targetName}) jpp_init_custom_properties(${targetName}) set_property(TARGET ${targetName} PROPERTY KM3NET_JPP_SCRIPT TRUE) set_target_properties(${targetName} PROPERTIES RUNTIME_OUTPUT_NAME ${basename} RUNTIME_OUTPUT_DIRECTORY ${KM3NET_JPP_STAGE_DIR}/${base}) install(PROGRAMS ${script} DESTINATION ${base}) file(COPY ${script} DESTINATION ${KM3NET_JPP_STAGE_DIR}/${base}) endif() endforeach() endfunction()