@@ -14,12 +14,37 @@ foreach( i RANGE 0 ${last_arg_idx})
1414 endif ()
1515endforeach ()
1616
17- set ( path_list_file ${CMAKE_ARGV${actual_args_start_idx} } )
17+ # Copy args to temp vars
18+ math ( EXPR arg_binary_dir_idx "${actual_args_start_idx} + 0" )
19+ set ( binary_dir ${CMAKE_ARGV${arg_binary_dir_idx} } )
20+
21+ math ( EXPR arg_component_idx "${actual_args_start_idx} + 1" )
22+ set ( component_name ${CMAKE_ARGV${arg_component_idx} } )
23+
24+ math ( EXPR arg_config_idx "${actual_args_start_idx} + 2" )
25+ set ( config_name ${CMAKE_ARGV${arg_component_idx} } )
26+
27+ math ( EXPR arg_path_list_idx "${actual_args_start_idx} + 3" )
28+ set ( path_list_file ${CMAKE_ARGV${arg_path_list_idx} } )
29+
30+ # Check that args are set
31+ if ( NOT binary_dir )
32+ message ( FATAL_ERROR "Binary dir path not specified." )
33+ endif ()
34+
35+ if ( NOT component_name )
36+ message ( FATAL_ERROR "Component name not specified." )
37+ endif ()
1838
1939if ( NOT path_list_file )
2040 message ( FATAL_ERROR "Path list file not specified." )
2141endif ()
2242
43+ # Check that paths exist
44+ if ( NOT EXISTS "${binary_dir} " )
45+ message ( FATAL_ERROR "Binary dir ${FATAL_ERROR} doesn't exist." )
46+ endif ()
47+
2348if ( NOT EXISTS "${path_list_file} " )
2449 message ( NOTICE "No deployment path specified. Create file ${path_list_file} with folder paths on separate lines for auto deployment." )
2550 return ()
@@ -30,17 +55,25 @@ file( STRINGS ${path_list_file} deploy_paths )
3055
3156# Iterate over all paths in the file
3257foreach ( deploy_path IN LISTS deploy_paths)
33- # Convert to full path
34- file ( REAL_PATH ${deploy_path} deploy_path_full )
35-
36- # Iterate over all files to copy
37- math ( EXPR path_arg_start "${actual_args_start_idx} + 1" )
38- foreach ( i RANGE ${path_arg_start} ${last_arg_idx} )
39- file ( REAL_PATH "${CMAKE_ARGV${i} }" file_to_copy )
40- message (STATUS "${file_to_copy} -> ${deploy_path} " )
41- file (
42- COPY ${file_to_copy}
43- DESTINATION ${deploy_path_full}
44- )
45- endforeach ()
58+ cmake_path ( IS_ABSOLUTE deploy_path is_path_absolute )
59+
60+ if ( NOT is_path_absolute )
61+ message ( SEND_ERROR "Path must be absolute: ${deploy_path_full} " )
62+ continue ()
63+ endif ()
64+
65+ if ( NOT EXISTS "${deploy_path} " )
66+ message ( SEND_ERROR "Path doesn't exist: ${deploy_path} " )
67+ continue ()
68+ endif ()
69+
70+ # Run cmake --install for the path
71+ execute_process (
72+ COMMAND
73+ ${CMAKE_COMMAND}
74+ --install ${binary_dir}
75+ --config "${config_name} "
76+ --component ${component_name}
77+ --prefix ${deploy_path}
78+ )
4679endforeach ()
0 commit comments