aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2009-01-06 22:04:12 +0000
committerAlexander Neundorf <neundorf@kde.org>2009-01-06 22:04:12 +0000
commit3dfdda2dc0367ccae61938b2a1b835c8612322a8 (patch)
treed32102b463455927f0f5e42259f9324a27fc23b4
parentcab30f1102a6a326e32616aa5ed483493751bbfb (diff)
downloadextra-cmake-modules-3dfdda2dc0367ccae61938b2a1b835c8612322a8.tar.gz
extra-cmake-modules-3dfdda2dc0367ccae61938b2a1b835c8612322a8.tar.bz2
-before installing the exports files, compate the new and the already installed one, and if they are different, delete
any previously installed configuration specific exports files Alex svn path=/trunk/KDE/kdelibs/; revision=906811
-rw-r--r--modules/check_installed_exports_file.cmake119
1 files changed, 73 insertions, 46 deletions
diff --git a/modules/check_installed_exports_file.cmake b/modules/check_installed_exports_file.cmake
index ab36b9cf..d1d0c718 100644
--- a/modules/check_installed_exports_file.cmake
+++ b/modules/check_installed_exports_file.cmake
@@ -1,46 +1,73 @@
-# INSTALL_DIR - set it to the install destination
-# INSTALL_PREFIX - set it to CMAKE_INSTALL_PREFIX
-# CURRENT_BINARY_DIR - set it to CMAKE_CURRENT_BINARY_DIR
-# FILENAME - the filename of the exports file
-
-# get the absolute install directory, consider absolute and relative paths and also DESTDIR
-if(IS_ABSOLUTE "${INSTALL_DIR}")
- set(installDir "$ENV{DESTDIR}${INSTALL_DIR}")
-else(IS_ABSOLUTE "${INSTALL_DIR}")
- set(installDir "$ENV{DESTDIR}${INSTALL_PREFIX}/${INSTALL_DIR}")
-endif(IS_ABSOLUTE "${INSTALL_DIR}")
-
-set(installedExportsFile "${installDir}/${FILENAME}")
-
-
-# if the file already exists at the install location, and if we can
-# find the exports file in the build dir, read both, and if their contents differ,
-# remove all configuration-specific exports files from the install dir, since
-# they may create conflicts if the new targets have been added/targets have been
-# removed/ targets have been renamed/ the namespace for the exported targets has changed
-if(EXISTS "${installedExportsFile}")
- if (${INSTALL_DIR} MATCHES "^(/)(.+)$")
- set(binaryDirExportFileDir "_${CMAKE_MATCH_2}")
- set(binaryDirExportsFile "${CURRENT_BINARY_DIR}/CMakeFiles/Export/${binaryDirExportFileDir}/${FILENAME}")
- else (${INSTALL_DIR} MATCHES "^(/)(.+)$")
- set(binaryDirExportsFile "${CURRENT_BINARY_DIR}/CMakeFiles/Export/${INSTALL_DIR}/${FILENAME}")
- endif (${INSTALL_DIR} MATCHES "^(/)(.+)$")
-
- if(EXISTS "${binaryDirExportsFile}")
- file(READ "${installedExportsFile}" installedExportsFileContents)
- file(READ "${binaryDirExportsFile}" binaryDirExportsFileContents)
-
- if(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
-
- if("${FILENAME}" MATCHES "^(.+)(\\.cmake)$")
- message(STATUS "Installed and new ${FILENAME} differ, removing installed ${CMAKE_MATCH_1}-*.cmake files")
- file(GLOB files "${installDir}/${CMAKE_MATCH_1}-*.cmake")
- file(REMOVE ${files})
- endif("${FILENAME}" MATCHES "^(.+)(\\.cmake)$")
- else(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
- message(STATUS "FILES are the same")
- endif(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
-
- endif(EXISTS "${binaryDirExportsFile}")
-
-endif(EXISTS "${installedExportsFile}")
+
+# This file is executed via install(SCRIPT).
+# This means it is include()d into the cmake_install.cmake file
+# Due to this the following variables already have the correct value:
+# CMAKE_INSTALL_PREFIX
+# CMAKE_CURRENT_BINARY_DIR
+#
+# Additionally the following two variables have to be set:
+# EXPORT_INSTALL_DIR - set it to the install destination
+# EXPORT_FILES - the filenames of the exports file
+#
+# Alex
+
+
+# put all the code into a function so all variables used here are local
+# which makes sure including this file multiple times in a cmake_install.cmake works
+function(CHECK_INSTALLED_EXPORTS_FILE _filename)
+
+ # get the absolute install directory, consider absolute and relative paths and also DESTDIR
+ if(IS_ABSOLUTE "${EXPORT_INSTALL_DIR}")
+ set(installDir "$ENV{DESTDIR}${EXPORT_INSTALL_DIR}")
+ else(IS_ABSOLUTE "${EXPORT_INSTALL_DIR}")
+ set(installDir "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${EXPORT_INSTALL_DIR}")
+ endif(IS_ABSOLUTE "${EXPORT_INSTALL_DIR}")
+
+ set(installedExportsFile "${installDir}/${_filename}")
+
+ #message(STATUS "************ bin dir: ${CMAKE_CURRENT_BINARY_DIR}")
+ #message(STATUS "************ prefix: ${CMAKE_INSTALL_PREFIX}")
+ #message(STATUS "************ exportsfile: ${installedExportsFile}")
+
+ # if the file already exists at the install location, and if we can
+ # find the exports file in the build dir, read both, and if their contents differ,
+ # remove all configuration-specific exports files from the install dir, since
+ # they may create conflicts if the new targets have been added/targets have been
+ # removed/ targets have been renamed/ the namespace for the exported targets has changed
+ if(EXISTS "${installedExportsFile}")
+ if (${EXPORT_INSTALL_DIR} MATCHES "^(/)(.+)$")
+ set(binaryDirExportFileDir "_${CMAKE_MATCH_2}")
+ set(binaryDirExportsFile "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Export/${binaryDirExportFileDir}/${_filename}")
+ else (${EXPORT_INSTALL_DIR} MATCHES "^(/)(.+)$")
+ set(binaryDirExportsFile "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Export/${EXPORT_INSTALL_DIR}/${_filename}")
+ endif (${EXPORT_INSTALL_DIR} MATCHES "^(/)(.+)$")
+
+ # message(STATUS "************* binaryDirExportsFile: ${binaryDirExportsFile}")
+
+ if(EXISTS "${binaryDirExportsFile}")
+ file(READ "${installedExportsFile}" installedExportsFileContents)
+ file(READ "${binaryDirExportsFile}" binaryDirExportsFileContents)
+
+ if(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
+
+ if("${_filename}" MATCHES "^(.+)(\\.cmake)$")
+ message(STATUS "XXX Installed and new ${_filename} differ, removing installed ${CMAKE_MATCH_1}-*.cmake files")
+ file(GLOB exportFiles "${installDir}/${CMAKE_MATCH_1}-*.cmake")
+# message(STATUS "XXX files: ${exportFiles}")
+ file(REMOVE ${exportFiles})
+ endif("${_filename}" MATCHES "^(.+)(\\.cmake)$")
+ else(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
+# message(STATUS "XXX FILES ${_filename} are the same")
+ endif(NOT "${installedExportsFileContents}" STREQUAL "${binaryDirExportsFileContents}")
+
+ endif(EXISTS "${binaryDirExportsFile}")
+
+ endif(EXISTS "${installedExportsFile}")
+
+endfunction(CHECK_INSTALLED_EXPORTS_FILE)
+
+# call the function for each exports file
+foreach(_currentExportsFile ${EXPORT_FILES})
+ check_installed_exports_file("${_currentExportsFile}")
+endforeach(_currentExportsFile ${EXPORT_FILES})
+