forked from Slicer/Slicer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlicerMacroBuildScriptedCLI.cmake
89 lines (76 loc) · 2.76 KB
/
SlicerMacroBuildScriptedCLI.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
macro(SlicerMacroBuildScriptedCLI)
set(options
NO_INSTALL
VERBOSE
)
set(oneValueArgs
NAME
FOLDER
)
set(multiValueArgs
)
cmake_parse_arguments(LOCAL_SEM
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)
message(STATUS "Configuring CLI Scripted module: ${LOCAL_SEM_NAME}")
# --------------------------------------------------------------------------
# Print information helpful for debugging checks
# --------------------------------------------------------------------------
if(LOCAL_SEM_VERBOSE)
foreach(curr_opt IN LISTS options oneValueArgs multiValueArgs)
message(STATUS "${curr_opt} = ${LOCAL_SEM_${curr_opt}}")
endforeach()
endif()
# --------------------------------------------------------------------------
# Sanity checks
# --------------------------------------------------------------------------
if(LOCAL_SEM_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "Unknown keywords given to SEMMacroBuildScriptedCLI(): \"${LOCAL_SEM_UNPARSED_ARGUMENTS}\"")
endif()
if(NOT DEFINED LOCAL_SEM_NAME)
message(FATAL_ERROR "NAME is mandatory")
endif()
set(cli_script_file "${CMAKE_CURRENT_SOURCE_DIR}/${LOCAL_SEM_NAME}.py")
set(cli_xml_file "${CMAKE_CURRENT_SOURCE_DIR}/${LOCAL_SEM_NAME}.xml")
set(binary_dir "${CMAKE_BINARY_DIR}/${Slicer_CLIMODULES_BIN_DIR}")
if(CMAKE_CONFIGURATION_TYPES)
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.20")
set(binary_dir "${binary_dir}/$<CONFIG>")
else()
set(binary_dir "${binary_dir}/${CMAKE_CFG_INTDIR}")
endif()
endif()
add_custom_command(
OUTPUT "${binary_dir}/${LOCAL_SEM_NAME}.py" "${binary_dir}/${LOCAL_SEM_NAME}.xml"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${binary_dir}"
COMMAND "${CMAKE_COMMAND}" -E copy "${cli_script_file}" "${binary_dir}"
COMMAND "${CMAKE_COMMAND}" -E copy "${cli_xml_file}" "${binary_dir}"
DEPENDS "${cli_script_file}" "${cli_xml_file}"
COMMENT "Copying ${LOCAL_SEM_NAME} files to ${binary_dir}"
)
add_custom_target(${LOCAL_SEM_NAME} ALL
SOURCES "${cli_script_file}" "${cli_xml_file}"
DEPENDS "${binary_dir}/${LOCAL_SEM_NAME}.py" "${binary_dir}/${LOCAL_SEM_NAME}.xml"
)
set(cli_targets ${LOCAL_SEM_NAME})
if(NOT LOCAL_SEM_NO_INSTALL)
install(
FILES
${cli_script_file}
${cli_xml_file}
DESTINATION "${Slicer_INSTALL_CLIMODULES_BIN_DIR}"
COMPONENT Runtime
)
endif()
# Folder
if(NOT DEFINED LOCAL_SEM_FOLDER)
set(LOCAL_SEM_FOLDER "${SlicerExecutionModel_DEFAULT_CLI_TARGETS_FOLDER_PREFIX}${LOCAL_SEM_NAME}")
endif()
foreach(target ${cli_targets})
set_target_properties(${target} PROPERTIES FOLDER ${LOCAL_SEM_FOLDER})
endforeach()
set(${LOCAL_SEM_NAME}_TARGETS_FOLDER ${LOCAL_SEM_FOLDER})
endmacro()