[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [extra-cmake-modules] modules: Rename CMakePackageConfigHelpers to ECMPackageConfigHelpers
From:       Alex Merry <kde () randomguy3 ! me ! uk>
Date:       2014-02-18 15:26:10
Message-ID: E1WFmYk-00035E-93 () scm ! kde ! org
[Download RAW message or body]

Git commit 139f60d81653888f696ef433bff5a9f5849b252c by Alex Merry.
Committed on 05/02/2014 at 14:46.
Pushed by alexmerry into branch 'master'.

Rename CMakePackageConfigHelpers to ECMPackageConfigHelpers

Overriding a CMake package like this will just cause all sorts of
headaches later on.  In this particular case, projects that depended on
CMake 2.8.13 or later (more likely 3.0.0) would fail with a message
about removing the CMakePackageConfigHelpers file, but would have no way
to do that while still using ECM.

This also renames the configure_package_config_file() macro to
ecm_configure_package_config_file(), so that anything including
CMakePackageConfigHelpers afterwards does not overwrite the macro
unexpectedly.

For now, we keep a CMakePackageConfigHelpers.cmake file that just wraps
ecm_configure_package_config_file() as configure_package_config_file()
to keep the frameworks building while they are ported.

REVIEW: 115496
Reviewed by Sune Vuorela <kde@pusling.com>

M  +6    -129  modules/CMakePackageConfigHelpers.cmake
C  +29   -9    modules/ECMPackageConfigHelpers.cmake [from: modules/CMakePa=
ckageConfigHelpers.cmake - 071% similarity]

http://commits.kde.org/extra-cmake-modules/139f60d81653888f696ef433bff5a9f5=
849b252c

diff --git a/modules/CMakePackageConfigHelpers.cmake b/modules/CMakePackage=
ConfigHelpers.cmake
index 5d65e65..6d5281a 100644
--- a/modules/CMakePackageConfigHelpers.cmake
+++ b/modules/CMakePackageConfigHelpers.cmake
@@ -1,132 +1,9 @@
+# Compatibility hack to make porting frameworks easier
+# TODO: remove before releasing 1.0.0
 =

-include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake)
-
-# This file is a hack to add the find_dependency macro to config files. It
-# will be in a future version of CMake, so we fork the configure_package_c=
onfig_file
-# function until we depend on that version of CMake.
-
-if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13)
-  message(FATAL_ERROR "Remove this file. The find_dependency macro or some=
thing
- like it should be in cmake by now.")
-endif()
-
-function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
-  set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
-  set(oneValueArgs INSTALL_DESTINATION )
-  set(multiValueArgs PATH_VARS )
-
-  cmake_parse_arguments(CCF "${options}" "${oneValueArgs}" "${multiValueAr=
gs}"  ${ARGN})
-
-  if(CCF_UNPARSED_ARGUMENTS)
-    message(FATAL_ERROR "Unknown keywords given to CONFIGURE_PACKAGE_CONFI=
G_FILE(): \"${CCF_UNPARSED_ARGUMENTS}\"")
-  endif()
-
-  if(NOT CCF_INSTALL_DESTINATION)
-    message(FATAL_ERROR "No INSTALL_DESTINATION given to CONFIGURE_PACKAGE=
_CONFIG_FILE()")
-  endif()
-
-  if(IS_ABSOLUTE "${CCF_INSTALL_DESTINATION}")
-    set(absInstallDir "${CCF_INSTALL_DESTINATION}")
-  else()
-    set(absInstallDir "${CMAKE_INSTALL_PREFIX}/${CCF_INSTALL_DESTINATION}")
-  endif()
-
-  file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${absInstallDir}" "${CMAKE_INS=
TALL_PREFIX}" )
-
-  foreach(var ${CCF_PATH_VARS})
-    if(NOT DEFINED ${var})
-      message(FATAL_ERROR "Variable ${var} does not exist")
-    else()
-      if(IS_ABSOLUTE "${${var}}")
-        string(REPLACE "${CMAKE_INSTALL_PREFIX}" "\${PACKAGE_PREFIX_DIR}"
-                        PACKAGE_${var} "${${var}}")
-      else()
-        set(PACKAGE_${var} "\${PACKAGE_PREFIX_DIR}/${${var}}")
-      endif()
-    endif()
-  endforeach()
-
-  get_filename_component(inputFileName "${_inputFile}" NAME)
-
-  set(PACKAGE_INIT "
-####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ##=
#####
-####### Any changes to this file will be overwritten by the next CMake run=
 ####
-####### The input file was ${inputFileName}                            ###=
#####
-
-get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${P=
ACKAGE_RELATIVE_PATH}\" ABSOLUTE)
-")
-
-  if("${absInstallDir}" MATCHES "^(/usr)?/lib(64)?/.+")
-    # Handle "/usr move" symlinks created by some Linux distros.
-    set(PACKAGE_INIT "${PACKAGE_INIT}
-# Use original install prefix when loaded through a \"/usr move\"
-# cross-prefix symbolic link such as /lib -> /usr/lib.
-get_filename_component(_realCurr \"\${CMAKE_CURRENT_LIST_DIR}\" REALPATH)
-get_filename_component(_realOrig \"${absInstallDir}\" REALPATH)
-if(_realCurr STREQUAL _realOrig)
-  set(PACKAGE_PREFIX_DIR \"${CMAKE_INSTALL_PREFIX}\")
-endif()
-unset(_realOrig)
-unset(_realCurr)
-")
-  endif()
-
-  if(NOT CCF_NO_SET_AND_CHECK_MACRO)
-    set(PACKAGE_INIT "${PACKAGE_INIT}
-macro(set_and_check _var _file)
-  set(\${_var} \"\${_file}\")
-  if(NOT EXISTS \"\${_file}\")
-    message(FATAL_ERROR \"File or directory \${_file} referenced by variab=
le \${_var} does not exist !\")
-  endif()
-endmacro()
-
-macro(find_dependency dep version)
-  if (NOT \${dep}_FOUND)
-
-    set(exact_arg)
-    if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION_EXACT)
-      set(exact_arg EXACT)
-    endif()
-    set(quiet_arg)
-    if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
-      set(quiet_arg QUIET)
-    endif()
-    set(required_arg)
-    if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
-      set(required_arg REQUIRED)
-    endif()
-
-    find_package(\${dep} \${version} \${exact_arg} \${quiet_arg} \${requir=
ed_arg})
-    if (NOT \${dep}_FOUND)
-      set(\${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE \"\${CMAKE_FIND_PA=
CKAGE_NAME} could not be found because dependency \${dep} could not be foun=
d.\")
-    endif()
-    set(required_arg)
-    set(quiet_arg)
-    set(exact_arg)
-  endif()
-endmacro()
-
-")
-  endif()
-
-
-  if(NOT CCF_NO_CHECK_REQUIRED_COMPONENTS_MACRO)
-    set(PACKAGE_INIT "${PACKAGE_INIT}
-macro(check_required_components _NAME)
-  foreach(comp \${\${_NAME}_FIND_COMPONENTS})
-    if(NOT \${_NAME}_\${comp}_FOUND)
-      if(\${_NAME}_FIND_REQUIRED_\${comp})
-        set(\${_NAME}_FOUND FALSE)
-      endif()
-    endif()
-  endforeach()
-endmacro()
-")
-  endif()
-
-  set(PACKAGE_INIT "${PACKAGE_INIT}
-##########################################################################=
##########")
-
-  configure_file("${_inputFile}" "${_outputFile}" @ONLY)
+include(${CMAKE_CURRENT_LIST_DIR}/ECMPackageConfigHelpers.cmake)
 =

+function(CONFIGURE_PACKAGE_CONFIG_FILE)
+    message(AUTHOR_WARNING "Use ecm_configure_package_config_file() from E=
CMPackageConfigHelpers instead of configure_package_config_file()")
+    ecm_configure_package_config_file(${ARGV})
 endfunction()
diff --git a/modules/CMakePackageConfigHelpers.cmake b/modules/ECMPackageCo=
nfigHelpers.cmake
similarity index 71%
copy from modules/CMakePackageConfigHelpers.cmake
copy to modules/ECMPackageConfigHelpers.cmake
index 5d65e65..7801739 100644
--- a/modules/CMakePackageConfigHelpers.cmake
+++ b/modules/ECMPackageConfigHelpers.cmake
@@ -1,16 +1,36 @@
+# - ECM_CONFIGURE_PACKAGE_CONFIG_FILE(), WRITE_BASIC_PACKAGE_VERSION_FILE()
+#
+# WRITE_BASIC_PACKAGE_VERSION_FILE() is actually just the macro from the
+# CMakePackageConfigHelpers module.
+#
+# ECM_CONFIGURE_PACKAGE_CONFIG_FILE() behaves like
+# CONFIGURE_PACKAGE_CONFIG_FILE() from CMake 2.8.12, except that it adds an
+# extra helper macro: find_dependency().
+#
+# find_dependency() should be used instead of find_package() to find packa=
ge
+# dependencies.  It forwards the correct parameters for EXACT, QUIET and
+# REQUIRED which were passed to the original find_package() call.  It also=
 sets
+# an informative diagnostic message if the dependency could not be found.
+#
+# Note that there is no argument to disable the find_dependency() macro; i=
f you
+# do not require this macro, you should just use the CMakeFindDependencyMa=
cro
+# module directly.
+#
+# CMake 3.0.0 will include a CMakeFindDependencyMacro module that will pro=
vide
+# the find_dependency macro (which you can include() in your *Config.cmake
+# file), so this file is only useful for projects whose minimum required v=
ersion
+# is 2.8.12.
+#
 =

 include(${CMAKE_ROOT}/Modules/CMakePackageConfigHelpers.cmake)
 =

-# This file is a hack to add the find_dependency macro to config files. It
-# will be in a future version of CMake, so we fork the configure_package_c=
onfig_file
-# function until we depend on that version of CMake.
+set(_ecm_package_config_helpers_included TRUE)
 =

 if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.13)
-  message(FATAL_ERROR "Remove this file. The find_dependency macro or some=
thing
- like it should be in cmake by now.")
+    message(AUTHOR_WARNING "Your project already requires a version of CMa=
ke that includes the find_dependency macro via the CMakeFindDependencyMacro=
 module. You should use CMakePackageConfigHelpers instead of ECMPackageConf=
igHelpers.")
 endif()
 =

-function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
+function(ECM_CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _outputFile)
   set(options NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
   set(oneValueArgs INSTALL_DESTINATION )
   set(multiValueArgs PATH_VARS )
@@ -49,9 +69,9 @@ function(CONFIGURE_PACKAGE_CONFIG_FILE _inputFile _output=
File)
   get_filename_component(inputFileName "${_inputFile}" NAME)
 =

   set(PACKAGE_INIT "
-####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() ##=
#####
-####### Any changes to this file will be overwritten by the next CMake run=
 ####
-####### The input file was ${inputFileName}                            ###=
#####
+####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() (E=
CM variant) #######
+####### Any changes to this file will be overwritten by the next CMake run=
            #######
+####### The input file was ${inputFileName}                               =
            #######
 =

 get_filename_component(PACKAGE_PREFIX_DIR \"\${CMAKE_CURRENT_LIST_DIR}/${P=
ACKAGE_RELATIVE_PATH}\" ABSOLUTE)
 ")
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic