]> granicus.if.org Git - icinga2/blob - cmake/InstallConfig.cmake
Change a bunch more copyright headers for 2018
[icinga2] / cmake / InstallConfig.cmake
1 # Icinga 2
2 # Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com)
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 function(install_if_not_exists src dest)
19   set(real_dest "${dest}")
20   if(NOT IS_ABSOLUTE "${src}")
21     set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
22   endif()
23   get_filename_component(src_name "${src}" NAME)
24   get_filename_component(basename_dest "${src}" NAME)
25   string(REPLACE "/" "\\\\" nsis_src "${src}")
26   string(REPLACE "/" "\\\\" nsis_dest_dir "${real_dest}")
27   string(REPLACE "/" "\\\\" nsis_dest "${real_dest}/${basename_dest}")
28   install(CODE "
29    if(\"\$ENV{DESTDIR}\" STREQUAL \"\")
30       set(target_dir \${CMAKE_INSTALL_PREFIX})
31     else()
32       set(target_dir \$ENV{DESTDIR})
33     endif()
34     if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.* OR NOT EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/\${skel_prefix}${dest}/${src_name}\")
35       message(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\")
36       if(\${CMAKE_INSTALL_PREFIX} MATCHES .*/_CPack_Packages/.*)
37         set(skel_prefix \"share/skel/\")
38       else()
39         set(skel_prefix \"\")
40       endif()
41       execute_process(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
42                       \"\${target_dir}/\${skel_prefix}${dest}/${src_name}\"
43                       RESULT_VARIABLE copy_result
44                       ERROR_VARIABLE error_output)
45       if(copy_result)
46         message(FATAL_ERROR \${error_output})
47       endif()
48     else()
49       message(STATUS \"Skipping  : \${target_dir}/${dest}/${src_name}\")
50     endif()
51   ")
52 endfunction(install_if_not_exists)