mirror of https://github.com/Icinga/icinga2.git
26 lines
920 B
CMake
26 lines
920 B
CMake
|
function(install_if_not_exists src dest)
|
||
|
if(NOT IS_ABSOLUTE "${src}")
|
||
|
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
||
|
endif()
|
||
|
get_filename_component(src_name "${src}" NAME)
|
||
|
if (NOT IS_ABSOLUTE "${dest}")
|
||
|
set(dest "${CMAKE_INSTALL_PREFIX}/${dest}")
|
||
|
endif()
|
||
|
install(CODE "
|
||
|
if(NOT EXISTS \"\$ENV{DESTDIR}${dest}/${src_name}\")
|
||
|
#file(INSTALL \"${src}\" DESTINATION \"${dest}\")
|
||
|
message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\")
|
||
|
execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
|
||
|
\"\$ENV{DESTDIR}${dest}/${src_name}\"
|
||
|
RESULT_VARIABLE copy_result
|
||
|
ERROR_VARIABLE error_output)
|
||
|
if(copy_result)
|
||
|
message(FATAL_ERROR \${error_output})
|
||
|
endif()
|
||
|
else()
|
||
|
message(STATUS \"Skipping : \$ENV{DESTDIR}${dest}/${src_name}\")
|
||
|
endif()
|
||
|
")
|
||
|
endfunction(install_if_not_exists)
|
||
|
|