1 # WRF Macro for adding target symlinks/copies to be run after internal install() code
2 macro( wrf_setup_targets )
4 set( options USE_SYMLINKS )
5 set( oneValueArgs DEST_PATH )
6 set( multiValueArgs TARGETS )
10 "${options}" "${oneValueArgs}" "${multiValueArgs}"
13 set( WRF_SETUP_CMD copy_if_different )
14 if ( ${WRF_SETUP_USE_SYMLINKS} )
15 set( WRF_SETUP_CMD create_symlink )
19 foreach ( WRF_SETUP_TARGET ${WRF_SETUP_TARGETS} )
21 # Generate install code for each target
22 # https://stackoverflow.com/a/56528615
23 #!TODO Do we *need* the rm for symlinks beforehand?
24 # get_filename_component( WRF_SETUP_FILE_ONLY $<TARGET_FILE:${WRF_SETUP_TARGET}> NAME
26 # If we ever wanted to link or copy things other than binaries we could change this
27 set( WRF_SETUP_INSTALL_LOCATION ${CMAKE_INSTALL_PREFIX}/bin )
31 message( STATUS \"Setting up $<TARGET_FILE_NAME:${WRF_SETUP_TARGET}> via ${WRF_SETUP_CMD}\" )
32 execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_INSTALL_LOCATION}/$<TARGET_FILE_NAME:${WRF_SETUP_TARGET}> ${WRF_SETUP_DEST_PATH}/$<TARGET_FILE_NAME:${WRF_SETUP_TARGET}> )
37 # Add .exe link as well
40 message( STATUS \"Creating symlink for $<TARGET_FILE_NAME:${WRF_SETUP_TARGET}>.exe\" )
41 execute_process( COMMAND ${CMAKE_COMMAND} -E create_symlink ${WRF_SETUP_DEST_PATH}/$<TARGET_FILE_NAME:${WRF_SETUP_TARGET}> ${WRF_SETUP_DEST_PATH}/$<TARGET_FILE_NAME:${WRF_SETUP_TARGET}>.exe )
50 # WRF Macro for adding file symlinks/copies to be run after internal install() code
51 macro( wrf_setup_files )
53 set( options USE_SYMLINKS )
54 set( oneValueArgs DEST_PATH )
55 set( multiValueArgs FILES )
57 cmake_parse_arguments(
59 "${options}" "${oneValueArgs}" "${multiValueArgs}"
62 set( WRF_SETUP_CMD copy_if_different )
63 if ( ${WRF_SETUP_USE_SYMLINKS} )
64 set( WRF_SETUP_CMD create_symlink )
67 foreach ( WRF_SETUP_FILE ${WRF_SETUP_FILES} )
69 # Generate install code for each file, this could be done in a simpler manner
70 # with regular commands but to preserve order of operations it will be done via install( CODE ... )
71 # https://stackoverflow.com/a/56528615
72 get_filename_component( WRF_SETUP_FULL_FILE ${WRF_SETUP_FILE} ABSOLUTE )
73 get_filename_component( WRF_SETUP_FILE_ONLY ${WRF_SETUP_FILE} NAME )
74 # Left here for debug purposes, may want to turn this into a trace-level debug msg
75 # message( "Generating install commands for ${WRF_SETUP_FILE_ONLY} into ${WRF_SETUP_DEST_PATH}" )
78 message( STATUS \"Setting up ${WRF_SETUP_FILE_ONLY} via ${WRF_SETUP_CMD}\" )
79 execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_FULL_FILE} ${WRF_SETUP_DEST_PATH}/${WRF_SETUP_FILE_ONLY} )
88 # WRF Macro for adding file symlink to be run after internal install() code
89 macro( wrf_setup_file_new_name )
91 set( options USE_SYMLINKS )
92 set( oneValueArgs FILE NEW_NAME )
95 cmake_parse_arguments(
97 "${options}" "${oneValueArgs}" "${multiValueArgs}"
101 set( WRF_SETUP_CMD copy_if_different )
102 if ( ${WRF_SETUP_USE_SYMLINKS} )
103 set( WRF_SETUP_CMD create_symlink )
106 # Generate install code for each file, this could be done in a simpler manner
107 # with regular commands but to preserve order of operations it will be done via install( CODE ... )
108 # https://stackoverflow.com/a/56528615
109 get_filename_component( WRF_SETUP_FULL_FILE ${WRF_SETUP_FILE} ABSOLUTE )
110 get_filename_component( WRF_SETUP_FILE_ONLY ${WRF_SETUP_FILE} NAME )
111 get_filename_component( WRF_SETUP_NEW_NAME_FULL_FILE ${WRF_SETUP_NEW_NAME} ABSOLUTE )
112 get_filename_component( WRF_SETUP_NEW_NAME_FILE_ONLY ${WRF_SETUP_NEW_NAME} NAME )
113 # Left here for debug purposes, may want to turn this into a trace-level debug msg
114 # message( "Generating install commands for ${WRF_SETUP_FILE_ONLY} to ${WRF_SETUP_NEW_NAME_FILE_ONLY}" )
117 message( STATUS \"Setting up ${WRF_SETUP_FILE_ONLY} (rename ${WRF_SETUP_NEW_NAME_FILE_ONLY}) via ${WRF_SETUP_CMD}\" )
118 execute_process( COMMAND ${CMAKE_COMMAND} -E ${WRF_SETUP_CMD} ${WRF_SETUP_FULL_FILE} ${WRF_SETUP_NEW_NAME_FULL_FILE} )