diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/BundleUtilities.cmake | 64 | ||||
-rw-r--r-- | Modules/CPackDeb.cmake | 145 | ||||
-rw-r--r-- | Modules/ExternalProject.cmake | 12 | ||||
-rw-r--r-- | Modules/FindBISON.cmake | 6 | ||||
-rw-r--r-- | Modules/FindLibArchive.cmake | 63 | ||||
-rw-r--r-- | Modules/FindOpenSSL.cmake | 18 | ||||
-rw-r--r-- | Modules/FindPackageHandleStandardArgs.cmake | 248 | ||||
-rw-r--r-- | Modules/FindTIFF.cmake | 2 | ||||
-rw-r--r-- | Modules/MacroAddFileDependencies.cmake | 2 | ||||
-rw-r--r-- | Modules/Platform/GNU.cmake | 3 |
10 files changed, 488 insertions, 75 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index d9c41f4..4d3baf8 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -13,6 +13,7 @@ # set_bundle_key_values # get_bundle_keys # copy_resolved_item_into_bundle +# copy_resolved_framework_into_bundle # fixup_bundle_item # fixup_bundle # copy_and_fixup_bundle @@ -433,6 +434,59 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) endfunction(copy_resolved_item_into_bundle) +# copy_resolved_framework_into_bundle +# +# Copy a resolved framework into the bundle if necessary. Copy is not necessary +# if the resolved_item is "the same as" the resolved_embedded_item. +# +# By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want full +# frameworks embedded in your bundles, set BU_COPY_FULL_FRAMEWORK_CONTENTS to +# ON before calling fixup_bundle. By default, +# copy_resolved_framework_into_bundle copies the framework dylib itself plus +# any framework Resources. +# +function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_item) + if(WIN32) + # ignore case on Windows + string(TOLOWER "${resolved_item}" resolved_item_compare) + string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare) + else() + set(resolved_item_compare "${resolved_item}") + set(resolved_embedded_item_compare "${resolved_embedded_item}") + endif() + + if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}") + message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...") + else() + if(BU_COPY_FULL_FRAMEWORK_CONTENTS) + # Full Framework (everything): + get_filename_component(resolved_dir "${resolved_item}" PATH) + get_filename_component(resolved_dir "${resolved_dir}/../.." ABSOLUTE) + get_filename_component(resolved_embedded_dir "${resolved_embedded_item}" PATH) + get_filename_component(resolved_embedded_dir "${resolved_embedded_dir}/../.." ABSOLUTE) + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_dir}' '${resolved_embedded_dir}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_dir}" "${resolved_embedded_dir}") + else() + # Framework lib itself: + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}") + + # Plus Resources, if they exist: + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}") + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}") + if(EXISTS "${resolved_resources}") + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}") + endif() + endif() + endif() + + if(UNIX AND NOT APPLE) + file(RPATH_REMOVE FILE "${resolved_embedded_item}") + endif(UNIX AND NOT APPLE) +endfunction(copy_resolved_framework_into_bundle) + + # fixup_bundle_item # # Get the direct/non-system prerequisites of the resolved embedded item. For each @@ -528,8 +582,14 @@ function(fixup_bundle app libs dirs) endif(show_status) if(${${key}_COPYFLAG}) - copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" - "${${key}_RESOLVED_EMBEDDED_ITEM}") + set(item "${${key}_ITEM}") + if(item MATCHES "[^/]+\\.framework/") + copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + else() + copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + endif() endif(${${key}_COPYFLAG}) endforeach(key) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index f5ca592..18acfb7 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -1,15 +1,18 @@ # - The builtin (binary) CPack Deb generator (Unix only) # CPackDeb may be used to create Deb package using CPack. # CPackDeb is a CPack generator thus it uses the CPACK_XXX variables -# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration +# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration. +# CPackDeb generator should work on any linux host but it will +# produce better deb package when Debian specific tools 'dpkg-xxx' +# are usable on the build system. # -# However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on -# the wiki: +# CPackDeb has specific features which are controlled by +# the specifics CPACK_DEBIAN_XXX variables.You'll find a detailed usage on +# the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 # However as a handy reminder here comes the list of specific variables: # -# CPACK_DEBIAN_PACKAGE_NAME +# CPACK_DEBIAN_PACKAGE_NAME # Mandatory : YES # Default : CPACK_PACKAGE_NAME (lower case) # The debian package summary @@ -19,12 +22,12 @@ # The debian package version # CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # Mandatory : YES -# Default : Output of dpkg --print-architecture or i386 +# Default : Output of dpkg --print-architecture (or i386 if dpkg is not found) # The debian package architecture # CPACK_DEBIAN_PACKAGE_DEPENDS # Mandatory : NO # Default : - -# May be used to set deb dependencies. +# May be used to set deb dependencies. # CPACK_DEBIAN_PACKAGE_MAINTAINER # Mandatory : YES # Default : CPACK_PACKAGE_CONTACT @@ -41,6 +44,25 @@ # Mandatory : YES # Default : 'optional' # The debian package priority +# CPACK_DEBIAN_PACKAGE_HOMEPAGE +# Mandatory : NO +# Default : - +# The URL of the web site for this package +# CPACK_DEBIAN_PACKAGE_SHLIBDEPS +# Mandatory : NO +# Default : OFF +# May be set to ON in order to use dpkg-shlibdeps to generate +# better package dependency list. +# You may need set CMAKE_INSTALL_RPATH toi appropriate value +# if you use this feature, because if you don't dpkg-shlibdeps +# may fail to find your own shared libs. +# See http://www.cmake.org/Wiki/CMake_RPATH_handling. +# CPACK_DEBIAN_PACKAGE_DEBUG +# Mandatory : NO +# Default : - +# May be set when invoking cpack in order to trace debug informations +# during CPackDeb run. + #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -69,6 +91,103 @@ IF(NOT UNIX) MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") ENDIF(NOT UNIX) +# CPACK_DEBIAN_PACKAGE_SHLIBDEPS +# If specify OFF, only user depends are used +IF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) +ENDIF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + +IF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + # dpkg-shlibdeps is a Debian utility for generating dependency list + FIND_PROGRAM(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) + + # Check version of the dpkg-shlibdeps tool using CPackRPM method + IF(SHLIBDEPS_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --version + OUTPUT_VARIABLE _TMP_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + STRING(REGEX MATCH "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)" + SHLIBDEPS_EXECUTABLE_VERSION + ${_TMP_VERSION}) + SET(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + + # Generating binary list - Get type of all install files + EXECUTE_PROCESS(COMMAND find -type f + COMMAND xargs file + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES) + + # Convert to CMake list + STRING(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) + + # Only dynamically linked ELF files are included + # Extract only file name infront of ":" + FOREACH ( _FILE ${CPACK_DEB_INSTALL_FILES}) + IF ( ${_FILE} MATCHES "ELF.*dynamically linked") + STRING(REGEX MATCH "(^.*):" _FILE_NAME ${_FILE}) + LIST(APPEND CPACK_DEB_BINARY_FILES ${CMAKE_MATCH_1}) + ENDIF() + ENDFOREACH() + + MESSAGE( "CPackDeb: - Generating dependency list") + + # Create blank control file for running dpkg-shlibdeps + # There might be some other way to invoke dpkg-shlibdeps without creating this file + # but standard debian package should not have anything that can collide with this file or directory + FILE(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) + FILE(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") + + # Execute dpkg-shlibdeps + # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package + # -O : print to STDOUT + EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --ignore-missing-info -O ${CPACK_DEB_BINARY_FILES} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE SHLIBDEPS_OUTPUT + RESULT_VARIABLE SHLIBDEPS_RESULT + ERROR_VARIABLE SHLIBDEPS_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + # dpkg-shlibdeps will throw some warnings if some input files are not binary + MESSAGE( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + IF (NOT SHLIBDEPS_RESULT EQUAL 0) + MESSAGE (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: ${SHLIBDEPS_ERROR}") + ENDIF (NOT SHLIBDEPS_RESULT EQUAL 0) + + #Get rid of prefix generated by dpkg-shlibdeps + string (REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS ${SHLIBDEPS_OUTPUT}) + + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + + # Remove blank control file + # Might not be safe if package actual contain file or directory named debian + FILE(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") + + # Append user depend if set + IF (CPACK_DEBIAN_PACKAGE_DEPENDS) + SET (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") + ELSE (CPACK_DEBIAN_PACKAGE_DEPENDS) + SET (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + ENDIF (CPACK_DEBIAN_PACKAGE_DEPENDS) + + ELSE (SHLIBDEPS_EXECUTABLE) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Using only user-provided depends because dpkg-shlibdeps is not found.") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + ENDIF(SHLIBDEPS_EXECUTABLE) + +ELSE (CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Using only user-provided depends") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) +ENDIF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + # Let's define the control file found in debian package: # Binary package: @@ -84,7 +203,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME) # Version: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_VERSION) IF(NOT CPACK_PACKAGE_VERSION) - MESSAGE(FATAL_ERROR "Debian package requires a package version") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a package version") ENDIF(NOT CPACK_PACKAGE_VERSION) SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION) @@ -95,7 +214,7 @@ IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # $ dpkg --print-architecture FIND_PROGRAM(DPKG_CMD dpkg) IF(NOT DPKG_CMD) - MESSAGE(STATUS "Can not find dpkg in your path, default to i386.") + MESSAGE(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.") SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) ENDIF(NOT DPKG_CMD) EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture @@ -116,7 +235,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) # Maintainer: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) IF(NOT CPACK_PACKAGE_CONTACT) - MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") ENDIF(NOT CPACK_PACKAGE_CONTACT) SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) @@ -124,7 +243,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) # Description: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) @@ -147,13 +266,13 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY ) # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive) -# Typical examples are: +# Typical examples are: # - conffiles # - postinst # - postrm # - prerm" # Usage: -# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA +# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index b4359c8..fcb5199 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -154,8 +154,8 @@ function(_ep_parse_arguments f name ns args) # correctly based on target properties. # # We loop through ARGN and consider the namespace starting with an - # upper-case letter followed by at least two more upper-case letters - # or underscores to be keywords. + # upper-case letter followed by at least two more upper-case letters, + # numbers or underscores to be keywords. set(key) foreach(arg IN LISTS args) @@ -166,14 +166,6 @@ function(_ep_parse_arguments f name ns args) NOT arg MATCHES "^(TRUE|FALSE)$") if(_ep_keywords_${f} AND arg MATCHES "${_ep_keywords_${f}}") set(is_value 0) - else() - if(NOT (key STREQUAL "COMMAND") - AND NOT (key STREQUAL "CVS_MODULE") - AND NOT (key STREQUAL "DEPENDS") - AND NOT (key STREQUAL "DOWNLOAD_COMMAND") - ) - message(AUTHOR_WARNING "unknown ${f} keyword: ${arg}") - endif() endif() endif() diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index b604d0b..b1b5010 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -5,6 +5,9 @@ # BISON_VERSION - version of bison # BISON_FOUND - true if the program was found # +# The minimum required version of bison can be specified using the +# standard CMake syntax, e.g. find_package(BISON 2.1.3) +# # If bison is found, the module defines the macros: # BISON_TARGET(<Name> <YaccInput> <CodeOutput> [VERBOSE <file>] # [COMPILE_FLAGS <string>]) @@ -149,6 +152,7 @@ IF(BISON_EXECUTABLE) ENDIF(BISON_EXECUTABLE) INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON DEFAULT_MSG BISON_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE + VERSION_VAR BISON_VERSION) # FindBISON.cmake ends here diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake new file mode 100644 index 0000000..fab5160 --- /dev/null +++ b/Modules/FindLibArchive.cmake @@ -0,0 +1,63 @@ +# - Find libarchive library and headers +# The module defines the following variables: +# +# LibArchive_FOUND - true if libarchive was found +# LibArchive_INCLUDE_DIRS - include search path +# LibArchive_LIBRARIES - libraries to link +# LibArchive_VERSION - libarchive 3-component version number + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) + +find_path(LibArchive_INCLUDE_DIR + NAMES archive.h + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/include" + ) + +find_library(LibArchive_LIBRARY + NAMES archive libarchive + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/lib" + ) + +mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY) + +# Extract the version number from the header. +if(LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h") + # The version string appears in one of two known formats in the header: + # #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12" + # #define ARCHIVE_VERSION_STRING "libarchive 2.8.4" + # Match either format. + set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"libarchive +([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$") + file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}") + if(_LibArchive_VERSION_STRING) + string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1.\\2.\\3" LibArchive_VERSION "${_LibArchive_VERSION_STRING}") + endif() + unset(_LibArchive_VERSION_REGEX) + unset(_LibArchive_VERSION_STRING) +endif() + +# Handle the QUIETLY and REQUIRED arguments and set LIBARCHIVE_FOUND +# to TRUE if all listed variables are TRUE. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibArchive DEFAULT_MSG + LibArchive_LIBRARY LibArchive_INCLUDE_DIR + ) +set(LibArchive_FOUND ${LIBARCHIVE_FOUND}) +unset(LIBARCHIVE_FOUND) + +if(LibArchive_FOUND) + set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR}) + set(LibArchive_LIBRARIES ${LibArchive_LIBRARY}) +endif() diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 826ae09..bf47ab8 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -40,7 +40,7 @@ MARK_AS_ADVANCED(OPENSSL_ROOT_DIR) # Re-use the previous path: FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h - ${OPENSSL_ROOT_DIR}/include + PATHS ${OPENSSL_ROOT_DIR}/include ) IF(WIN32 AND NOT CYGWIN) @@ -61,16 +61,16 @@ IF(WIN32 AND NOT CYGWIN) # libeay32MD.lib is identical to ../libeay32.lib, and # ssleay32MD.lib is identical to ../ssleay32.lib FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) set( OPENSSL_LIBRARIES @@ -85,20 +85,20 @@ IF(WIN32 AND NOT CYGWIN) ELSEIF(MINGW) # same player, for MingW FIND_LIBRARY(LIB_EAY NAMES libeay32 - ${OPENSSL_ROOT_DIR}/lib/MinGW + PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - ${OPENSSL_ROOT_DIR}/lib/MinGW + PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW ) MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) ELSE(MSVC) # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: FIND_LIBRARY(LIB_EAY NAMES libeay32 - ${OPENSSL_ROOT_DIR}/lib + PATHS ${OPENSSL_ROOT_DIR}/lib ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - ${OPENSSL_ROOT_DIR}/lib + PATHS ${OPENSSL_ROOT_DIR}/lib ) MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index e17105c..389697e 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -1,21 +1,58 @@ -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... ) -# This macro is intended to be used in FindXXX.cmake modules files. -# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and -# it also sets the <UPPERCASED_NAME>_FOUND variable. -# The package is found if all variables listed are TRUE. -# Example: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... ) # -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE(). +# It also sets the <UPPERCASED_NAME>_FOUND variable. +# The package is considered found if all variables <var1>... listed contain +# valid results, e.g. valid filepaths. # -# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and -# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. -# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, -# independent whether QUIET was used or not. -# If it is found, the location is reported using the VAR1 argument, so -# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out. -# If the second argument is DEFAULT_MSG, the message in the failure case will -# be "Could NOT find LibXml2", if you don't like this message you can specify -# your own custom failure message there. +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> ) +# If the variables <var1> to <varN> are all valid, then <UPPERCASED_NAME>_FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS <var1>...<varN>] +# [VERSION_VAR <versionvar> +# [FAIL_MESSAGE "Custom failure message"] ) +# +# As above, if <var1> through <varN> are all valid, <UPPERCASED_NAME>_FOUND +# will be set to TRUE. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# +# Example for mode 1: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of <var1>. +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE +# VERSION_VAR BISON_VERSION) +# In this case, BISON is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case. +# Also the version of BISON will be checked by using the version contained +# in BISON_VERSION. +# Since no FAIL_MESSAGE is given, the default messages will be printed. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -31,13 +68,89 @@ # License text for the above reference.) INCLUDE(FindPackageMessage) -FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) - IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") +# Checks a list of strings (typically function/macro parameters) whether it contains a keyword +# (_keyword) and return the value(s) following this keyword in _outputVar. +# If _multipleValues is true, this can be more than one value. +# Then end of the values for a keyword is then determined by checking whether the +# next argument is contained in _allKeywordsList. +FUNCTION(FPHSA_GET_OPTION_VALUE _keyword _outputVar _allArgsList _allKeywordsList _multipleValues) + UNSET(${_outputVar}) + UNSET(_removeIndices) + + SET(_insideValues FALSE) + SET(_counter 0) + FOREACH(_currentArg ${${_allArgsList}}) + IF(NOT _insideValues) # first check that we find the keyword we are currently interested in... + IF("${_currentArg}" STREQUAL "${_keyword}") + SET(_insideValues TRUE) + LIST(APPEND _removeIndices ${_counter}) + ENDIF("${_currentArg}" STREQUAL "${_keyword}") + ELSE(NOT _insideValues) + + LIST(FIND ${_allKeywordsList} "${_currentArg}" _index) # ... then this marks the end of the arguments belonging to this keyword + IF(${_index} EQUAL -1) + LIST(APPEND _result ${_currentArg}) + LIST(APPEND _removeIndices ${_counter}) # collect the indices of the strings we found to remove them from the list afterwards + IF(NOT _multipleValues) + BREAK() + ENDIF(NOT _multipleValues) + ELSE(${_index} EQUAL -1) + SET(_insideValues FALSE) + BREAK() + ENDIF(${_index} EQUAL -1) + ENDIF(NOT _insideValues) + + MATH(EXPR _counter "${_counter} + 1") + + ENDFOREACH(_currentArg ${${_allArgsList}}) + + IF(DEFINED _removeIndices) + LIST(REMOVE_AT ${_allArgsList} ${_removeIndices}) + ENDIF(DEFINED _removeIndices) + + SET(${_outputVar} ${_result} PARENT_SCOPE) + SET(${_allArgsList} ${${_allArgsList}} PARENT_SCOPE) + +ENDFUNCTION(FPHSA_GET_OPTION_VALUE _keyword _outputVar _allArgsList _allKeywordsList _multipleValues) + + +FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG _VAR1) + + SET(_KEYWORDS_FOR_EXTENDED_MODE FAIL_MESSAGE REQUIRED_VARS VERSION_VAR ) + LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + IF(${INDEX} EQUAL -1) + SET(_FAIL_MESSAGE ${_FIRST_ARG}) + SET(_REQUIRED_VARS ${_VAR1} ${ARGN}) + SET(_VERSION_VAR) + ELSE(${INDEX} EQUAL -1) + SET(ALL_ARGS ${_FIRST_ARG} ${_VAR1} ${ARGN}) + + FPHSA_GET_OPTION_VALUE("FAIL_MESSAGE" _FAIL_MESSAGE ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE FALSE) + FPHSA_GET_OPTION_VALUE("REQUIRED_VARS" _REQUIRED_VARS ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE TRUE) + FPHSA_GET_OPTION_VALUE("VERSION_VAR" _VERSION_VAR ALL_ARGS _KEYWORDS_FOR_EXTENDED_MODE FALSE) + + IF(ALL_ARGS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${ALL_ARGS}\"") + ENDIF(ALL_ARGS) + + IF(NOT _FAIL_MESSAGE) + SET(_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT _FAIL_MESSAGE) + ENDIF(${INDEX} EQUAL -1) + +# now that we collected all arguments, process them + + IF("${_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") SET(_FAIL_MESSAGE "Could NOT find ${_NAME}") - ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") - SET(_FAIL_MESSAGE "${_FAIL_MSG}") - ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") + ENDIF("${_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + + IF(NOT _REQUIRED_VARS) + MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + ENDIF(NOT _REQUIRED_VARS) + + LIST(GET _REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) STRING(TOUPPER ${_NAME} _NAME_UPPER) @@ -46,15 +159,8 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) SET(MISSING_VARS "") SET(DETAILS "") SET(${_NAME_UPPER}_FOUND TRUE) - IF(NOT ${_VAR1}) - SET(${_NAME_UPPER}_FOUND FALSE) - SET(MISSING_VARS " ${_VAR1}") - ELSE(NOT ${_VAR1}) - SET(DETAILS "${DETAILS}[${${_VAR1}}]") - ENDIF(NOT ${_VAR1}) - # check if all passed variables are valid - FOREACH(_CURRENT_VAR ${ARGN}) + FOREACH(_CURRENT_VAR ${_REQUIRED_VARS}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") @@ -63,18 +169,84 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) ENDIF(NOT ${_CURRENT_VAR}) ENDFOREACH(_CURRENT_VAR) + + # version handling: + SET(VERSION_MSG "") + SET(VERSION_OK TRUE) + IF (${_NAME}_FIND_VERSION) + + # if the package was found, check for the version using <NAME>_FIND_VERSION + IF (${_NAME_UPPER}_FOUND) + SET(VERSION ${${_VERSION_VAR}} ) + + IF(VERSION) + + IF(${_NAME}_FIND_VERSION_EXACT) # exact version required + IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG " Found version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG " (found exact version \"${VERSION}\")") + ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + + ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified: + IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG " Found version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG " (found version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")") + ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + +# Uncomment the following two lines to see to which Find-modules the VERSION_VAR keywords still need to be added: +# ELSE(VERSION) +# SET(VERSION_MSG " (WARNING: Required version is \"${${_NAME}_FIND_VERSION}\", but version of ${_NAME} is unknown)") + ENDIF(VERSION) + + # if the package was not found, but a version was given, add that to the output: + ELSE (${_NAME_UPPER}_FOUND) + IF(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG " (Required is exact version \"${${_NAME}_FIND_VERSION}\")") + ELSE(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG " (Required is at least version \"${${_NAME}_FIND_VERSION}\")") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + ENDIF (${_NAME_UPPER}_FOUND) + ENDIF (${_NAME}_FIND_VERSION) + + IF(VERSION_OK) + SET(DETAILS "${DETAILS}[v${${VERSION}}]") + ELSE(VERSION_OK) + SET(${_NAME_UPPER}_FOUND FALSE) + ENDIF(VERSION_OK) + + + # print the result: IF (${_NAME_UPPER}_FOUND) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_VAR1}}" "${DETAILS}") + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG}" "${DETAILS}") ELSE (${_NAME_UPPER}_FOUND) - IF (${_NAME}_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") - ELSE (${_NAME}_FIND_REQUIRED) - IF (NOT ${_NAME}_FIND_QUIETLY) - MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") - ENDIF (NOT ${_NAME}_FIND_QUIETLY) - ENDIF (${_NAME}_FIND_REQUIRED) + IF(NOT VERSION_OK) + + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) + + ELSE(NOT VERSION_OK) + + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) + ENDIF(NOT VERSION_OK) + ENDIF (${_NAME_UPPER}_FOUND) SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE) -ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS) +ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 8711634..62cc5c5 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -22,7 +22,7 @@ FIND_PATH(TIFF_INCLUDE_DIR tiff.h) -SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff libtiff3) +SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if diff --git a/Modules/MacroAddFileDependencies.cmake b/Modules/MacroAddFileDependencies.cmake index e4a82d1..785352e 100644 --- a/Modules/MacroAddFileDependencies.cmake +++ b/Modules/MacroAddFileDependencies.cmake @@ -1,6 +1,6 @@ # - MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) # Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There are usually -# better ways to specifiy the correct dependencies. +# better ways to specify the correct dependencies. # # MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a convenience # wrapper around the OBJECT_DEPENDS source file property. You can just diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake index fe3d47b..e0ed86c 100644 --- a/Modules/Platform/GNU.cmake +++ b/Modules/Platform/GNU.cmake @@ -4,5 +4,8 @@ SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") +SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") + INCLUDE(Platform/UnixPaths) |