diff options
| author | Alexander Neundorf <neundorf@kde.org> | 2009-01-05 21:50:36 +0000 | 
|---|---|---|
| committer | Alexander Neundorf <neundorf@kde.org> | 2009-01-05 21:50:36 +0000 | 
| commit | 6280df3dd62e0fea5d8cf35f63ea5a6453841c66 (patch) | |
| tree | 3e2ae3f508f7329b134ef814041bc103976520d2 /modules | |
| parent | 51a0fee9a7674449106206f98058ab1571cc0505 (diff) | |
| download | extra-cmake-modules-6280df3dd62e0fea5d8cf35f63ea5a6453841c66.tar.gz extra-cmake-modules-6280df3dd62e0fea5d8cf35f63ea5a6453841c66.tar.bz2 | |
-add a file which can take care of checking whether the already installed and the about to be installed exports files are identical
Alex
svn path=/trunk/KDE/kdelibs/; revision=906298
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/check_installed_exports_file.cmake | 44 | 
1 files changed, 44 insertions, 0 deletions
| diff --git a/modules/check_installed_exports_file.cmake b/modules/check_installed_exports_file.cmake new file mode 100644 index 00000000..454d2a09 --- /dev/null +++ b/modules/check_installed_exports_file.cmake @@ -0,0 +1,44 @@ +# 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}") + +      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 (${INSTALL_DIR} MATCHES "^(/)(.+)$") + +endif(EXISTS "${installedExportsFile}") | 
