diff options
Diffstat (limited to 'Modules')
84 files changed, 2208 insertions, 1045 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/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index c495810..0fad25d 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -42,10 +42,45 @@ IF(NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-ASM OPTIONAL) ENDIF(NOT _INCLUDED_FILE) +# Set default assembler file extensions: IF(NOT CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS) SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS s;S;asm) ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS) + +# Support for CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT and friends: +SET(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT "$ENV{ASM${ASM_DIALECT}FLAGS} ${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}") +# avoid just having a space as the initial value for the cache +IF(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT STREQUAL " ") + SET(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT) +ENDIF(CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT STREQUAL " ") +SET (CMAKE_ASM${ASM_DIALECT}_FLAGS "${CMAKE_ASM${ASM_DIALECT}_FLAGS_INIT}" CACHE STRING + "Flags used by the assembler during all build types.") + +IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) +# default build type is none + IF(NOT CMAKE_NO_BUILD_TYPE) + SET (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING + "Choose the type of build, options are: None, Debug Release RelWithDebInfo MinSizeRel.") + ENDIF(NOT CMAKE_NO_BUILD_TYPE) + SET (CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG "${CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG_INIT}" CACHE STRING + "Flags used by the assembler during debug builds.") + SET (CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL "${CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Flags used by the assembler during release minsize builds.") + SET (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE_INIT}" CACHE STRING + "Flags used by the assembler during release builds.") + SET (CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO "${CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Flags used by the assembler during Release with Debug Info builds.") +ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + +MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_FLAGS + CMAKE_ASM${ASM_DIALECT}_FLAGS_DEBUG + CMAKE_ASM${ASM_DIALECT}_FLAGS_MINSIZEREL + CMAKE_ASM${ASM_DIALECT}_FLAGS_RELEASE + CMAKE_ASM${ASM_DIALECT}_FLAGS_RELWITHDEBINFO + ) + + IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -o <OBJECT> <SOURCE>") ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 5d004c7..accda32 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -9,6 +9,9 @@ #if defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" +#elif defined(__clang__) +# define COMPILER_ID "Clang" + #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 00ab8e2..4a32823 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -11,6 +11,9 @@ #elif defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" +#elif defined(__clang__) +# define COMPILER_ID "Clang" + #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" diff --git a/Modules/CMakeCompilerABI.h b/Modules/CMakeCompilerABI.h index 8980abb..26ae4db 100644 --- a/Modules/CMakeCompilerABI.h +++ b/Modules/CMakeCompilerABI.h @@ -17,6 +17,16 @@ const char info_sizeof_dptr[] = { # define ABI_ID "ELF N32" #elif defined(__sgi) && defined(_ABI64) # define ABI_ID "ELF 64" + +/* Check for (some) ARM ABIs. + * See e.g. http://wiki.debian.org/ArmEabiPort for some information on this. */ +#elif defined(__GNU__) && defined(__ELF__) && defined(__ARM_EABI__) +# define ABI_ID "ELF ARMEABI" +#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEB__) +# define ABI_ID "ELF ARM" +#elif defined(__GNU__) && defined(__ELF__) && defined(__ARMEL__) +# define ABI_ID "ELF ARM" + #elif defined(__ELF__) # define ABI_ID "ELF" #endif diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index c8f4c99..aa4733b 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -49,12 +49,10 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) IF(ABI_SIZEOF_DPTR) SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE) - SET(CMAKE_SIZEOF_VOID_P "${ABI_SIZEOF_DPTR}" PARENT_SCOPE) ENDIF(ABI_SIZEOF_DPTR) IF(ABI_NAME) SET(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE) - SET(CMAKE_INTERNAL_PLATFORM_ABI "${ABI_NAME}" PARENT_SCOPE) ENDIF(ABI_NAME) # Parse implicit linker information for this language, if available. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index bddd6a1..4a800a8 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -19,6 +19,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Make sure the compiler arguments are clean. STRING(STRIP "${CMAKE_${lang}_COMPILER_ARG1}" CMAKE_${lang}_COMPILER_ID_ARG1) + STRING(REGEX REPLACE " +" ";" CMAKE_${lang}_COMPILER_ID_ARG1 "${CMAKE_${lang}_COMPILER_ID_ARG1}") # Make sure user-specified compiler flags are used. IF(CMAKE_${lang}_FLAGS) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 0637d20..34477a1 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -49,6 +49,7 @@ IF(NOT CMAKE_Fortran_COMPILER) # gfortran: putative GNU Fortran 95+ compiler (in progress) # fort77: native F77 compiler under HP-UX (and some older Crays) # frt: Fujitsu F77 compiler + # pathf90/pathf95/pathf2003: PathScale Fortran compiler # pgf77/pgf90/pgf95: Portland Group F77/F90/F95 compilers # xlf/xlf90/xlf95: IBM (AIX) F77/F90/F95 compilers # lf95: Lahey-Fujitsu F95 compiler @@ -63,14 +64,16 @@ IF(NOT CMAKE_Fortran_COMPILER) # then 77 or older compilers, gnu is always last in the group, # so if you paid for a compiler it is picked by default. SET(CMAKE_Fortran_COMPILER_LIST - ifort ifc efc f95 pgf95 lf95 xlf95 fort gfortran gfortran-4 g95 f90 - pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77 + ifort ifc efc f95 pathf2003 pathf95 pgf95 lf95 xlf95 fort + gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 + frt pgf77 xlf fl32 af77 g77 f77 ) # Vendor-specific compiler names. SET(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) SET(_Fortran_COMPILER_NAMES_Intel ifort ifc efc) SET(_Fortran_COMPILER_NAMES_PGI pgf95 pgf90 pgf77) + SET(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90) SET(_Fortran_COMPILER_NAMES_XL xlf) SET(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf) diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index ba2b46d..5558651 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -34,9 +34,9 @@ ENDIF(UNIX) SET(CMAKE_Fortran_SIZEOF_DATA_PTR "@CMAKE_Fortran_SIZEOF_DATA_PTR@") SET(CMAKE_Fortran_COMPILER_ABI "@CMAKE_Fortran_COMPILER_ABI@") -IF(CMAKE_Fortran_SIZEOF_DATA_PTR) +IF(CMAKE_Fortran_SIZEOF_DATA_PTR AND NOT CMAKE_SIZEOF_VOID_P) SET(CMAKE_SIZEOF_VOID_P "${CMAKE_Fortran_SIZEOF_DATA_PTR}") -ENDIF(CMAKE_Fortran_SIZEOF_DATA_PTR) +ENDIF() IF(CMAKE_Fortran_COMPILER_ABI) SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_Fortran_COMPILER_ABI}") diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake index 1d3d805..3f33ce8 100644 --- a/Modules/CMakePrintSystemInformation.cmake +++ b/Modules/CMakePrintSystemInformation.cmake @@ -27,7 +27,7 @@ MESSAGE("CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS is ${CMAKE_SHARED_LIBRARY_CREATE_ MESSAGE("CMAKE_DL_LIBS is ${CMAKE_DL_LIBS}") MESSAGE("CMAKE_SHARED_LIBRARY_PREFIX is ${CMAKE_SHARED_LIBRARY_PREFIX}") MESSAGE("CMAKE_SHARED_LIBRARY_SUFFIX is ${CMAKE_SHARED_LIBRARY_SUFFIX}") -MESSAGE("CMAKE_COMPILER_IS_GNUGCC = ${CMAKE_COMPILER_IS_GNUGCC}") +MESSAGE("CMAKE_COMPILER_IS_GNUCC = ${CMAKE_COMPILER_IS_GNUCC}") MESSAGE("CMAKE_COMPILER_IS_GNUCXX = ${CMAKE_COMPILER_IS_GNUCXX}") MESSAGE("CMAKE_CXX_CREATE_SHARED_LIBRARY is ${CMAKE_CXX_CREATE_SHARED_LIBRARY}") diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index eeaff7d..bac9932 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -74,6 +74,7 @@ ELSE(NOT CMAKE_C_COMPILER_WORKS) ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) + INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake) ENDIF(CMAKE_C_COMPILER_FORCED) ENDIF(NOT CMAKE_C_COMPILER_WORKS) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 72bb8f2..06ef301 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -67,5 +67,6 @@ ELSE(NOT CMAKE_CXX_COMPILER_WORKS) ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) + INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake) ENDIF(CMAKE_CXX_COMPILER_FORCED) ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 6f419c2..61d6336 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -90,5 +90,6 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS) ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 ) + INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake) ENDIF(CMAKE_Fortran_COMPILER_FORCED) ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake index 8233e52..460de25 100644 --- a/Modules/CMakeVS10FindMake.cmake +++ b/Modules/CMakeVS10FindMake.cmake @@ -12,38 +12,14 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -# VCExpress does not support cross compiling, which is necessary for Win CE -SET( _CMAKE_MAKE_PROGRAM_NAMES devenv) -IF(NOT CMAKE_CROSSCOMPILING) - SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) -ENDIF(NOT CMAKE_CROSSCOMPILING) - +# We use MSBuild as the build tool for VS 10 FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES MSBuild - HINTS + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir] "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" - ) - -FIND_PROGRAM(CMAKE_MAKE_PROGRAM - NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} - HINTS - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;EnvironmentDirectory] - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup;Dbghelp_path] - "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio10.0/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio 10/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio10/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10.0/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10/Common7/IDE" - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10/Common7/IDE" - "/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/" - "/Program Files/Microsoft Visual Studio 10/Common7/IDE/" - PATHS - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio .NET/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" - + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/" ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) diff --git a/Modules/CMakeVS8FindMake.cmake b/Modules/CMakeVS8FindMake.cmake index 6f45ed5..2f03e60 100644 --- a/Modules/CMakeVS8FindMake.cmake +++ b/Modules/CMakeVS8FindMake.cmake @@ -28,9 +28,6 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 8/Common7/IDE" "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio8/Common7/IDE" "/Program Files/Microsoft Visual Studio 8/Common7/IDE/" - PATHS - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio .NET/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC80 1) diff --git a/Modules/CMakeVS9FindMake.cmake b/Modules/CMakeVS9FindMake.cmake index 2741f77..4704bcc 100644 --- a/Modules/CMakeVS9FindMake.cmake +++ b/Modules/CMakeVS9FindMake.cmake @@ -33,10 +33,6 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio9/Common7/IDE" "/Program Files/Microsoft Visual Studio 9.0/Common7/IDE/" "/Program Files/Microsoft Visual Studio 9/Common7/IDE/" - PATHS - "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio .NET/Common7/IDE" - "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" - ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC90 1) 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/CPackRPM.cmake b/Modules/CPackRPM.cmake index 29a1218..f7687e4 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,14 +4,14 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on -# the wiki: +# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on +# the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 # However as a handy reminder here comes the list of specific variables: # -# CPACK_RPM_PACKAGE_SUMMARY +# CPACK_RPM_PACKAGE_SUMMARY # Mandatory : YES -# Default : CPACK_PACKAGE_DESCRIPTION +# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY # The RPM package summary # CPACK_RPM_PACKAGE_NAME # Mandatory : YES @@ -24,14 +24,14 @@ # CPACK_RPM_PACKAGE_ARCHITECTURE # Mandatory : NO # Default : - -# The RPM package architecture. This may be set to "noarch" if you +# The RPM package architecture. This may be set to "noarch" if you # know you are building a noarch package. # CPACK_RPM_PACKAGE_RELEASE # Mandatory : YES # Default : 1 -# The RPM package release. This is the numbering of the RPM package -# itself, i.e. the version of the packaging and not the version of the -# content (see CPACK_RPM_PACKAGE_VERSION). One may change the default +# The RPM package release. This is the numbering of the RPM package +# itself, i.e. the version of the packaging and not the version of the +# content (see CPACK_RPM_PACKAGE_VERSION). One may change the default # value if the previous packaging was buggy and/or you want to put here # a fancy Linux distro specific numbering. # CPACK_RPM_PACKAGE_LICENSE @@ -42,29 +42,62 @@ # Mandatory : YES # Default : "unknown" # The RPM package group. -# CPACK_RPM_PACKAGE_VENDOR +# CPACK_RPM_PACKAGE_VENDOR # Mandatory : YES # Default : CPACK_PACKAGE_VENDOR if set or "unknown" -# The RPM package group. +# The RPM package vendor. +# CPACK_RPM_PACKAGE_URL +# Mandatory : NO +# Default : - +# The projects URL. # CPACK_RPM_PACKAGE_DESCRIPTION # Mandatory : YES # Default : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package description available" +# CPACK_RPM_COMPRESSION_TYPE +# Mandatory : NO +# Default : - +# May be used to override RPM compression type to be used +# to build the RPM. For example some Linux distribution now default +# to lzma or xz compression whereas older cannot use such RPM. +# Using this one can enforce compression type to be used. +# Possible value are: lzma, xz, bzip2 and gzip. # CPACK_RPM_PACKAGE_REQUIRES # Mandatory : NO # Default : - # May be used to set RPM dependencies (requires). -# Note that you must enclose the complete requires string between quotes, +# Note that you must enclose the complete requires string between quotes, # for example: # set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8") -# CPACK_RPM_PACKAGES_PROVIDES +# CPACK_RPM_PACKAGE_SUGGESTS +# Mandatory : NO +# Default : - +# May be used to set weak RPM dependencies (suggests). +# Note that you must enclose the complete requires string between quotes. +# CPACK_RPM_PACKAGE_PROVIDES # Mandatory : NO # Default : - # May be used to set RPM dependencies (provides). +# CPACK_RPM_PACKAGE_OBSOLETES +# Mandatory : NO +# Default : - +# May be used to set RPM packages that are obsoleted by this one. +# CPACK_RPM_PACKAGE_RELOCATABLE +# Mandatory : NO +# Default : - +# If this variable is set to TRUE or ON CPackRPM will try +# to build a relocatable RPM package. A relocatable RPM may +# be installed using rpm --prefix or --relocate in order to +# install it at an alternate place see rpm(8). +# Note that currently this may fail if the package contains +# files installed with absolute path or CPACK_SET_DESTDIR is set to ON. +# If CPACK_SET_DESTDIR is set then you will get a warning message +# but if there is file installed with absolute path you'll get +# unexpected behavior. # CPACK_RPM_SPEC_INSTALL_POST # Mandatory : NO # Default : - -# May be used to set an RPM post-install command inside the spec file. -# For example setting it to "/bin/true" may be used to prevent +# May be used to set an RPM post-install command inside the spec file. +# For example setting it to "/bin/true" may be used to prevent # rpmbuild to strip binaries. # CPACK_RPM_SPEC_MORE_DEFINE # Mandatory : NO @@ -73,19 +106,19 @@ # CPACK_RPM_PACKAGE_DEBUG # Mandatory : NO # Default : - -# May be set when invoking cpack in order to trace debug informations -# during CPack RPM run. For example you may launch CPack like this +# May be set when invoking cpack in order to trace debug information +# during CPack RPM run. For example you may launch CPack like this # cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM # CPACK_RPM_USER_BINARY_SPECFILE # Mandatory : NO -# Default : - +# Default : - # May be set by the user in order to specify a USER binary spec file # to be used by CPackRPM instead of generating the file. # The specified file will be processed by CONFIGURE_FILE( @ONLY). # CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE # Mandatory : NO # Default : - -# If set CPack will generate a template for USER specified binary +# If set CPack will generate a template for USER specified binary # spec file and stop with an error. For example launch CPack like this # cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM # The user may then use this file in order to hand-craft is own @@ -108,6 +141,12 @@ # put after the %post or %postun section # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm +# CPACK_RPM_CHANGELOG_FILE +# Mandatory : NO +# Default : - +# May be used to embbed a changelog in the spec file. +# The refered file will be read and directly put after the %changelog +# section. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -133,23 +172,23 @@ IF(NOT UNIX) ENDIF(NOT UNIX) # rpmbuild is the basic command for building RPM package -# it may be a simple (symbolic) link to rpmb command. +# it may be a simple (symbolic) link to rpm command. FIND_PROGRAM(RPMBUILD_EXECUTABLE rpmbuild) -# Check version of the rpmbuild tool this would be easier to +# Check version of the rpmbuild tool this would be easier to # track bugs with users and CPackRPM debug mode. -# We may use RPM version in order to check for available version dependent features +# We may use RPM version in order to check for available version dependent features IF(RPMBUILD_EXECUTABLE) execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version OUTPUT_VARIABLE _TMP_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^.*\ " "" + string(REGEX REPLACE "^.*\ " "" RPMBUILD_EXECUTABLE_VERSION - ${_TMP_VERSION}) + ${_TMP_VERSION}) IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + ENDIF(CPACK_RPM_PACKAGE_DEBUG) ENDIF(RPMBUILD_EXECUTABLE) IF(NOT RPMBUILD_EXECUTABLE) @@ -157,14 +196,14 @@ IF(NOT RPMBUILD_EXECUTABLE) ENDIF(NOT RPMBUILD_EXECUTABLE) # We may use RPM version in the future in order -# to shut down warning about space in buildtree +# to shut down warning about space in buildtree # some recent RPM version should support space in different places. # not checked [yet]. IF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") MESSAGE(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") ENDIF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") -# If rpmbuild is found +# If rpmbuild is found # we try to discover alien since we may be on non RPM distro like Debian. # In this case we may try to to use more advanced features # like generating RPM directly from DEB using alien. @@ -174,7 +213,7 @@ IF(ALIEN_EXECUTABLE) MESSAGE(STATUS "alien found, we may be on a Debian based distro.") ENDIF(ALIEN_EXECUTABLE) -# +# # Use user-defined RPM specific variables value # or generate reasonable default value from # CPACK_xxx generic values. @@ -189,10 +228,10 @@ IF(NOT CPACK_RPM_PACKAGE_SUMMARY) IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) ELSE(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) ENDIF(NOT CPACK_RPM_PACKAGE_SUMMARY) - + # CPACK_RPM_PACKAGE_NAME (mandatory) IF(NOT CPACK_RPM_PACKAGE_NAME) STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) @@ -205,6 +244,11 @@ IF(NOT CPACK_RPM_PACKAGE_VERSION) ENDIF(NOT CPACK_PACKAGE_VERSION) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) ENDIF(NOT CPACK_RPM_PACKAGE_VERSION) +# Replace '-' in version with '_' +# '-' character is an Illegal RPM version character +# it is illegal because it is used to separate +# RPM "Version" from RPM "Release" +STRING(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) # CPACK_RPM_PACKAGE_ARCHITECTURE (optional) IF(CPACK_RPM_PACKAGE_ARCHITECTURE) @@ -252,7 +296,7 @@ ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR) # CPACK_RPM_PACKAGE_DESCRIPTION # The variable content may be either -# - explicitely given by tthe user or +# - explicitly given by the user or # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE # if it is defined # - set to a default value @@ -265,25 +309,54 @@ IF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) ENDIF (CPACK_PACKAGE_DESCRIPTION_FILE) ENDIF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) -# CPACK_RPM_PACKAGE_REQUIRES -# Placeholder used to specify binary RPM dependencies (if any) -# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html -IF(CPACK_RPM_PACKAGE_REQUIRES) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined Requires:\n ${CPACK_RPM_PACKAGE_REQUIRES}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_REQUIRES "Requires: ${CPACK_RPM_PACKAGE_REQUIRES}") -ENDIF(CPACK_RPM_PACKAGE_REQUIRES) - -# CPACK_RPM_PACKAGE_PROVIDES -# Placeholder used to specify binary RPM dependencies (if any) -# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html -IF(CPACK_RPM_PACKAGE_PROVIDES) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined Provides:\n ${CPACK_RPM_PACKAGE_PROVIDES}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_PROVIDES "Provides: ${CPACK_RPM_PACKAGE_PROVIDES}") -ENDIF(CPACK_RPM_PACKAGE_PROVIDES) +# CPACK_RPM_COMPRESSION_TYPE +# +IF (CPACK_RPM_COMPRESSION_TYPE) + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") + ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7.xzdio") + ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") + ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + IF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") + SET(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") + ENDIF(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") +ELSE(CPACK_RPM_COMPRESSION_TYPE) + SET(CPACK_RPM_COMPRESSION_TYPE_TMP "") +ENDIF(CPACK_RPM_COMPRESSION_TYPE) + +if(CPACK_RPM_PACKAGE_RELOCATABLE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Trying to build a relocatable package") + endif(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_SET_DESTDIR) + message(SEND_ERROR "CPackRPM:Warning: CPACK_SET_DESTDIR is set while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + else(CPACK_SET_DESTDIR) + set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) + endif(CPACK_SET_DESTDIR) +endif(CPACK_RPM_PACKAGE_RELOCATABLE) + +# check if additional fields for RPM spec header are given +FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX) + IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) + MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") + STRING(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) + STRING(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) + STRING(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) + SET(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") + ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) +ENDFOREACH(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST # May be used to define a RPM post intallation script @@ -319,7 +392,7 @@ endif(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE -# May be used to embbed a pre (un)installation script in the spec file. +# May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section if(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) @@ -338,6 +411,19 @@ if(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) endif(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) +# CPACK_RPM_CHANGELOG_FILE +# May be used to embed a changelog in the spec file. +# The refered file will be read and directly put after the %changelog section +if(CPACK_RPM_CHANGELOG_FILE) + if(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) + file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG) + else(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) + message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) +else(CPACK_RPM_CHANGELOG_FILE) + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk <eric.noulard@gmail.com>\n Generated by CPack RPM (no Changelog file were provided)") +endif(CPACK_RPM_CHANGELOG_FILE) + # CPACK_RPM_SPEC_MORE_DEFINE # This is a generated spec rpm file spaceholder IF(CPACK_RPM_SPEC_MORE_DEFINE) @@ -367,18 +453,19 @@ SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) -# We must remove the './' due to the local search (thus the sed) +# We must remove the './' due to the local search and escape the +# file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files EXECUTE_PROCESS(COMMAND find -type f -o -type l - COMMAND sed {s/\\.//} - COMMAND sed {s/.*man.*\\/.*/&*/} + COMMAND sed {s:.*/man.*/.*:&*:} + COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) # The name of the final spec file to be used by rpmbuild SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}.spec") - + # Print out some debug information if we were asked for that IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") @@ -391,7 +478,7 @@ IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) - + # USER generated spec file handling. # We should generate a spec file template: # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE @@ -400,7 +487,7 @@ ENDIF(CPACK_RPM_PACKAGE_DEBUG) IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- -Buildroot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ +BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ Name: \@CPACK_RPM_PACKAGE_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ @@ -408,18 +495,21 @@ Release: \@CPACK_RPM_PACKAGE_RELEASE\@ License: \@CPACK_RPM_PACKAGE_LICENSE\@ Group: \@CPACK_RPM_PACKAGE_GROUP\@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ +\@TMP_RPM_URL\@ \@TMP_RPM_REQUIRES\@ \@TMP_RPM_PROVIDES\@ +\@TMP_RPM_OBSOLETES\@ \@TMP_RPM_BUILDARCH\@ - -#p define prefix \@CMAKE_INSTALL_PREFIX\@ +\@TMP_RPM_PREFIX\@ + %define _rpmdir \@CPACK_RPM_DIRECTORY\@ %define _rpmfilename \@CPACK_RPM_FILE_NAME\@ %define _unpackaged_files_terminate_build 0 %define _topdir \@CPACK_RPM_DIRECTORY\@ \@TMP_RPM_SPEC_INSTALL_POST\@ \@CPACK_RPM_SPEC_MORE_DEFINE\@ - +\@CPACK_RPM_COMPRESSION_TYPE_TMP\@ + %description \@CPACK_RPM_PACKAGE_DESCRIPTION\@ @@ -431,14 +521,14 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ mv $RPM_BUILD_ROOT \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot #p build - + %install if [ -e $RPM_BUILD_ROOT ]; then - mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot/* $RPM_BUILD_ROOT + mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot/* $RPM_BUILD_ROOT else - mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot $RPM_BUILD_ROOT -fi + mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot $RPM_BUILD_ROOT +fi %clean @@ -459,59 +549,39 @@ fi ${CPACK_RPM_INSTALL_FILES} %changelog -* Sat Nov 28 2009 Erk <eric.noulard@gmail.com> - Refix backup/restore install tree for OpenSuSE 11.2 -* Sun Nov 22 2009 Erk <eric.noulard@gmail.com> - Include symlinks in the file list. -* Sat Nov 14 2009 Erk <eric.noulard@gmail.com> - Replace prep and build step with backup and restore - of the previously CPack installed tree. This should - mimic what is expected in rpmbuild usual steps -* Wed Nov 11 2009 Erk <eric.noulard@gmail.com> - Add support for USER defined pre/post[un]install scripts -* Wed Oct 07 2009 Erk <eric.noulard@gmail.com> - Add user custom spec file support -* Sat Oct 03 2009 Kami <cmoidavid@gmail.com> - Update to handle more precisely the files section -* Mon Oct 03 2008 Erk <eric.noulard@gmail.com> - Update generator to handle optional dependencies using Requires - Update DEBUG output typos. -* Mon Aug 25 2008 Erk <eric.noulard@gmail.com> - Update generator to handle optional post-install -* Tue Aug 16 2007 Erk <eric.noulard@gmail.com> - Generated by CPack RPM Generator and associated macros +\@CPACK_RPM_SPEC_CHANGELOG\@ ") # Stop here if we were asked to only generate a template USER spec file # The generated file may then be used as a template by user who wants - # to customize their own spec file. + # to customize their own spec file. IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) MESSAGE(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) # After that we may either use a user provided spec file -# or generate one using appropriate variables value. +# or generate one using appropriate variables value. IF(CPACK_RPM_USER_BINARY_SPECFILE) # User may have specified SPECFILE just use it MESSAGE("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") # The user provided file is processed for @var replacement CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ELSE(CPACK_RPM_USER_BINARY_SPECFILE) - # No User specified spec file, will use the generated spec file - MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") - # Note the just created file is processed for @var replacement + # No User specified spec file, will use the generated spec file + MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") + # Note the just created file is processed for @var replacement CONFIGURE_FILE(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ENDIF(CPACK_RPM_USER_BINARY_SPECFILE) IF(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE EXECUTE_PROCESS( - COMMAND "${RPMBUILD_EXECUTABLE}" -bb - --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" + COMMAND "${RPMBUILD_EXECUTABLE}" -bb + --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" "${CPACK_RPM_BINARY_SPECFILE}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err" - OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err") diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 2d0702e..bdaf911 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -163,6 +163,11 @@ IF(BUILD_TESTING) SET(DART_TESTING_TIMEOUT 1500 CACHE STRING "Maximum time allowed before CTest will kill the test.") + SET(CTEST_SUBMIT_RETRY_DELAY 5 CACHE STRING + "How long to wait between timed-out CTest submissions.") + SET(CTEST_SUBMIT_RETRY_COUNT 3 CACHE STRING + "How many times to retry timed-out CTest submissions.") + FIND_PROGRAM(MEMORYCHECK_COMMAND NAMES purify valgrind boundscheck PATHS @@ -262,7 +267,9 @@ IF(BUILD_TESTING) SCPCOMMAND SLURM_SBATCH_COMMAND SLURM_SRUN_COMMAND - SITE + SITE + CTEST_SUBMIT_RETRY_DELAY + CTEST_SUBMIT_RETRY_COUNT ) # BUILDNAME IF(NOT RUN_FROM_DART) diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake new file mode 100644 index 0000000..f7baf68 --- /dev/null +++ b/Modules/Compiler/Clang-C.cmake @@ -0,0 +1 @@ +include(Compiler/GNU-C) diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake new file mode 100644 index 0000000..d3c403a --- /dev/null +++ b/Modules/Compiler/Clang-CXX.cmake @@ -0,0 +1 @@ +include(Compiler/GNU-CXX) diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 4ac918e..656eea6 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,11 +1,11 @@ +SET(CMAKE_C_VERBOSE_FLAG "-#") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-h") -SET(CMAKE_C_VERBOSE_FLAG "-#") - SET(CMAKE_C_FLAGS_INIT "") SET(CMAKE_C_FLAGS_DEBUG_INIT "-g") SET(CMAKE_C_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index fe549d6..3e07e8e 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,11 +1,11 @@ +SET(CMAKE_CXX_VERBOSE_FLAG "-v") + SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-h") -SET(CMAKE_CXX_VERBOSE_FLAG "-v") - SET(CMAKE_CXX_FLAGS_INIT "") SET(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") SET(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index ae38f86..a41b454 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_Fortran_VERBOSE_FLAG "-v") + SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "-R") @@ -12,4 +14,3 @@ SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-g -xO2") SET(CMAKE_Fortran_MODDIR_FLAG "-moddir=") SET(CMAKE_Fortran_MODPATH_FLAG "-M") -SET(CMAKE_Fortran_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index 6133f56..cf9b2b6 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -1,4 +1,5 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-V") + SET(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 0b05865..caf0afe 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -46,6 +46,11 @@ CVSUpdateOptions: @CVS_UPDATE_OPTIONS@ SVNCommand: @SVNCOMMAND@ SVNUpdateOptions: @SVN_UPDATE_OPTIONS@ +# Git options +GITCommand: @GITCOMMAND@ +GITUpdateOptions: @GIT_UPDATE_OPTIONS@ +GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@ + # Generic update command UpdateCommand: @UPDATE_COMMAND@ UpdateOptions: @UPDATE_OPTIONS@ @@ -79,3 +84,7 @@ CurlOptions: @CTEST_CURL_OPTIONS@ # warning, if you add new options here that have to do with submit, # you have to update cmCTestSubmitCommand.cxx +# For CTest submissions that timeout, these options +# specify behavior for retrying the submission +CTestSubmitRetryDelay: @CTEST_SUBMIT_RETRY_DELAY@ +CTestSubmitRetryCount: @CTEST_SUBMIT_RETRY_COUNT@ diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 0302d5c..b42e42b 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -16,7 +16,12 @@ # [CVS_TAG tag] # Tag to checkout from CVS repo # [SVN_REPOSITORY url] # URL of Subversion repo # [SVN_REVISION rev] # Revision to checkout from Subversion repo +# [SVN_USERNAME john ] # Username for Subversion checkout and update +# [SVN_PASSWORD doe ] # Password for Subversion checkout and update +# [GIT_REPOSITORY url] # URL of git repo +# [GIT_TAG tag] # Git branch name, commit id or tag # [URL /.../src.tgz] # Full path or URL of source +# [URL_MD5 md5] # MD5 checksum of file at URL # [TIMEOUT seconds] # Time allowed for file download operations # #--Update/Patch step---------- # [UPDATE_COMMAND cmd...] # Source work-tree update command @@ -38,6 +43,13 @@ # [TEST_BEFORE_INSTALL 1] # Add test step executed before install step # [TEST_AFTER_INSTALL 1] # Add test step executed after install step # [TEST_COMMAND cmd...] # Command to drive test +# #--Output logging------------- +# [LOG_DOWNLOAD 1] # Wrap download in script to log output +# [LOG_UPDATE 1] # Wrap update in script to log output +# [LOG_CONFIGURE 1] # Wrap configure in script to log output +# [LOG_BUILD 1] # Wrap build in script to log output +# [LOG_TEST 1] # Wrap test in script to log output +# [LOG_INSTALL 1] # Wrap install in script to log output # ) # The *_DIR options specify directories for the project, with default # directories computed as follows. @@ -81,6 +93,7 @@ # [DEPENDS files...] # Files on which this step depends # [ALWAYS 1] # No stamp file, step always runs # [WORKING_DIRECTORY dir] # Working directory for command +# [LOG 1] # Wrap step in script to log output # ) # The command line, comment, and working directory of every standard # and custom step is processed to replace tokens @@ -111,19 +124,19 @@ # License text for the above reference.) # Pre-compute a regex to match documented keywords for each command. -file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 100 - REGEX "^# ( \\[[A-Z_]+ [^]]*\\] +#.*$|[A-Za-z_]+\\()") +file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 103 + REGEX "^# ( \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()") foreach(line IN LISTS lines) - if("${line}" MATCHES "^# [A-Za-z_]+\\(") + if("${line}" MATCHES "^# [A-Za-z0-9_]+\\(") if(_ep_func) set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$") endif() - string(REGEX REPLACE "^# ([A-Za-z_]+)\\(.*" "\\1" _ep_func "${line}") + string(REGEX REPLACE "^# ([A-Za-z0-9_]+)\\(.*" "\\1" _ep_func "${line}") #message("function [${_ep_func}]") set(_ep_keywords_${_ep_func} "^(") set(_ep_keyword_sep) else() - string(REGEX REPLACE "^# \\[([A-Z_]+) .*" "\\1" _ep_key "${line}") + string(REGEX REPLACE "^# \\[([A-Z0-9_]+) .*" "\\1" _ep_key "${line}") #message(" keyword [${_ep_key}]") set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}}${_ep_keyword_sep}${_ep_key}") @@ -141,25 +154,18 @@ 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) set(is_value 1) - if(arg MATCHES "^[A-Z][A-Z_][A-Z_]+$" AND + if(arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND NOT ((arg STREQUAL "${key}") AND (key STREQUAL "COMMAND")) AND 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") - ) - message(AUTHOR_WARNING "unknown ${f} keyword: ${arg}") - endif() endif() endif() @@ -203,7 +209,63 @@ define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED ) -function(_ep_write_downloadfile_script script_filename remote local timeout) +function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir) + file(WRITE ${script_filename} +"if(\"${git_tag}\" STREQUAL \"\") + message(FATAL_ERROR \"Tag for git checkout should not be empty.\") +endif() + +execute_process( + COMMAND \${CMAKE_COMMAND} -E remove_directory \"${source_dir}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" clone \"${git_repository}\" \"${src_name}\" + WORKING_DIRECTORY \"${work_dir}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to clone repository: '${git_repository}'\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag} + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" submodule init + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\") +endif() + +execute_process( + COMMAND \"${git_EXECUTABLE}\" submodule update --recursive + WORKING_DIRECTORY \"${work_dir}/${src_name}\" + RESULT_VARIABLE error_code + ) +if(error_code) + message(FATAL_ERROR \"Failed to update submodules in: '${work_dir}/${src_name}'\") +endif() + +" +) + +endfunction(_ep_write_gitclone_script) + + +function(_ep_write_downloadfile_script script_filename remote local timeout md5) if(timeout) set(timeout_args TIMEOUT ${timeout}) set(timeout_msg "${timeout} seconds") @@ -212,6 +274,12 @@ function(_ep_write_downloadfile_script script_filename remote local timeout) set(timeout_msg "none") endif() + if(md5) + set(md5_args EXPECTED_MD5 ${md5}) + else() + set(md5_args "# no EXPECTED_MD5") + endif() + file(WRITE ${script_filename} "message(STATUS \"downloading... src='${remote}' @@ -221,6 +289,8 @@ function(_ep_write_downloadfile_script script_filename remote local timeout) file(DOWNLOAD \"${remote}\" \"${local}\" + SHOW_PROGRESS + ${md5_args} ${timeout_args} STATUS status LOG log) @@ -243,23 +313,64 @@ message(STATUS \"downloading... done\") endfunction(_ep_write_downloadfile_script) -function(_ep_write_extractfile_script script_filename filename tmp directory) - set(args "") +function(_ep_write_verifyfile_script script_filename local md5) + file(WRITE ${script_filename} +"message(STATUS \"verifying file... + file='${local}'\") - if(filename MATCHES ".tar$") - set(args xf) +set(verified 0) + +# If an expected md5 checksum exists, compare against it: +# +if(NOT \"${md5}\" STREQUAL \"\") + execute_process(COMMAND \${CMAKE_COMMAND} -E md5sum \"${local}\" + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE rv) + + if(NOT rv EQUAL 0) + message(FATAL_ERROR \"error: computing md5sum of '${local}' failed\") endif() - if(filename MATCHES ".tgz$") - set(args xfz) + string(REGEX MATCH \"^([0-9A-Fa-f]+)\" md5_actual \"\${ov}\") + + string(TOLOWER \"\${md5_actual}\" md5_actual) + string(TOLOWER \"${md5}\" md5) + + if(NOT \"\${md5}\" STREQUAL \"\${md5_actual}\") + message(FATAL_ERROR \"error: md5sum of '${local}' does not match expected value + md5_expected: \${md5} + md5_actual: \${md5_actual} +\") endif() - if(filename MATCHES ".tar.gz$") + set(verified 1) +endif() + +if(verified) + message(STATUS \"verifying file... done\") +else() + message(STATUS \"verifying file... warning: did not verify file - no URL_MD5 checksum argument? corrupt file?\") +endif() +" +) + +endfunction(_ep_write_verifyfile_script) + + +function(_ep_write_extractfile_script script_filename name filename directory) + set(args "") + + if(filename MATCHES "(\\.bz2|\\.tar\\.gz|\\.tgz|\\.zip)$") set(args xfz) endif() + if(filename MATCHES "\\.tar$") + set(args xf) + endif() + if(args STREQUAL "") - message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .tar, .tgz and .tar.gz") + message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .bz2, .tar, .tar.gz, .tgz and .zip") return() endif() @@ -267,20 +378,23 @@ function(_ep_write_extractfile_script script_filename filename tmp directory) "# Make file names absolute: # get_filename_component(filename \"${filename}\" ABSOLUTE) -get_filename_component(tmp \"${tmp}\" ABSOLUTE) get_filename_component(directory \"${directory}\" ABSOLUTE) message(STATUS \"extracting... src='\${filename}' dst='\${directory}'\") +if(NOT EXISTS \"\${filename}\") + message(FATAL_ERROR \"error: file to extract does not exist: '\${filename}'\") +endif() + # Prepare a space for extracting: # -set(i 1) -while(EXISTS \"\${tmp}/extract\${i}\") +set(i 1234) +while(EXISTS \"\${directory}/../ex-${name}\${i}\") math(EXPR i \"\${i} + 1\") endwhile() -set(ut_dir \"\${tmp}/extract\${i}\") +set(ut_dir \"\${directory}/../ex-${name}\${i}\") file(MAKE_DIRECTORY \"\${ut_dir}\") # Extract it: @@ -305,10 +419,12 @@ if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\") set(contents \"\${ut_dir}\") endif() -# Copy \"the one\" directory to the final directory: +# Move \"the one\" directory to the final directory: # -message(STATUS \"extracting... [copy]\") -file(COPY \"\${contents}/\" DESTINATION \${directory}) +message(STATUS \"extracting... [rename]\") +file(REMOVE_RECURSE \${directory}) +get_filename_component(contents \${contents} ABSOLUTE) +file(RENAME \${contents} \${directory}) # Clean up: # @@ -439,8 +555,9 @@ function(_ep_get_build_command name step cmd_var) if(cfg_cmd_id STREQUAL "cmake") # CMake project. Select build command based on generator. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - if("${cmake_generator}" MATCHES "Make" AND - "${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}") + if("${CMAKE_GENERATOR}" MATCHES "Make" AND + ("${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}" OR + NOT cmake_generator)) # The project uses the same Makefile generator. Use recursive make. set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") @@ -469,7 +586,8 @@ function(_ep_get_build_command name step cmd_var) endif() else() # if(cfg_cmd_id STREQUAL "configure") # Non-CMake project. Guess "make" and "make install" and "make test". - set(cmd "make") + # But use "$(MAKE)" to get recursive parallel make. + set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") set(args install) endif() @@ -490,6 +608,101 @@ function(_ep_get_build_command name step cmd_var) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction(_ep_get_build_command) +function(_ep_write_log_script name step cmd_var) + ExternalProject_Get_Property(${name} stamp_dir) + set(command "${${cmd_var}}") + + set(make "") + set(code_cygpath_make "") + if("${command}" MATCHES "^\\$\\(MAKE\\)") + # GNU make recognizes the string "$(MAKE)" as recursive make, so + # ensure that it appears directly in the makefile. + string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}") + set(make "-Dmake=$(MAKE)") + + if(WIN32 AND NOT CYGWIN) + set(code_cygpath_make " +if(\${make} MATCHES \"^/\") + execute_process( + COMMAND cygpath -w \${make} + OUTPUT_VARIABLE cygpath_make + ERROR_VARIABLE cygpath_make + RESULT_VARIABLE cygpath_error + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT cygpath_error) + set(make \${cygpath_make}) + endif() +endif() +") + endif() + endif() + + set(config "") + if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$") + string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}") + set(config "-Dconfig=${CMAKE_CFG_INTDIR}") + endif() + + # Wrap multiple 'COMMAND' lines up into a second-level wrapper + # script so all output can be sent to one log file. + if("${command}" MATCHES ";COMMAND;") + set(code_execute_process " +${code_cygpath_make} +execute_process(COMMAND \${command} RESULT_VARIABLE result) +if(result) + set(msg \"Command failed (\${result}):\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + message(FATAL_ERROR \"\${msg}\") +endif() +") + set(code "") + set(cmd "") + set(sep "") + foreach(arg IN LISTS command) + if("x${arg}" STREQUAL "xCOMMAND") + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + set(cmd "") + set(sep "") + else() + set(cmd "${cmd}${sep}${arg}") + set(sep ";") + endif() + endforeach() + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + file(WRITE ${stamp_dir}/${name}-${step}-impl.cmake "${code}") + set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-impl.cmake) + endif() + + # Wrap the command in a script to log output to files. + set(script ${stamp_dir}/${name}-${step}.cmake) + set(logbase ${stamp_dir}/${name}-${step}) + file(WRITE ${script} " +${code_cygpath_make} +set(command \"${command}\") +execute_process( + COMMAND \${command} + RESULT_VARIABLE result + OUTPUT_FILE \"${logbase}-out.log\" + ERROR_FILE \"${logbase}-err.log\" + ) +if(result) + set(msg \"Command failed: \${result}\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\\n\") + message(FATAL_ERROR \"\${msg}\") +else() + set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\\n\") + message(STATUS \"\${msg}\") +endif() +") + set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script}) + set(${cmd_var} "${command}" PARENT_SCOPE) +endfunction(_ep_write_log_script) # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced # makefiles with "/./" in paths for custom command dependencies. Which @@ -579,6 +792,12 @@ function(ExternalProject_Add_Step name step) set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}${cfgdir}/${name}-${step}) endif() + # Wrap with log script? + get_property(log TARGET ${name} PROPERTY _EP_${step}_LOG) + if(command AND log) + _ep_write_log_script(${name} ${step} command) + endif() + add_custom_command( OUTPUT ${stamp_dir}${cfgdir}/${name}-${step} COMMENT ${comment} @@ -609,6 +828,29 @@ function(_ep_add_mkdir_command name) endfunction(_ep_add_mkdir_command) +function(_ep_get_git_version git_EXECUTABLE git_version_var) + if(git_EXECUTABLE) + execute_process( + COMMAND "${git_EXECUTABLE}" --version + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + string(REGEX REPLACE "^git version (.+)$" "\\1" version "${ov}") + set(${git_version_var} "${version}" PARENT_SCOPE) + endif() +endfunction() + + +function(_ep_is_dir_empty dir empty_var) + file(GLOB gr "${dir}/*") + if("${gr}" STREQUAL "") + set(${empty_var} 1 PARENT_SCOPE) + else() + set(${empty_var} 0 PARENT_SCOPE) + endif() +endfunction() + + function(_ep_add_download_command name) ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir) @@ -616,6 +858,7 @@ function(_ep_add_download_command name) get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND) get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY) get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY) + get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY) get_property(url TARGET ${name} PROPERTY _EP_URL) # TODO: Perhaps file:// should be copied to download dir before extraction. @@ -661,8 +904,10 @@ function(_ep_add_download_command name) endif() get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) + get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) + get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) - set(repository ${svn_repository}) + set(repository "${svn_repository} user=${svn_username} password=${svn_password}") set(module) set(tag ${svn_revision}) configure_file( @@ -674,13 +919,55 @@ function(_ep_add_download_command name) get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) set(comment "Performing download step (SVN checkout) for '${name}'") - set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} ${src_name}) + set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} + --username=${svn_username} --password=${svn_password} ${src_name}) list(APPEND depends ${stamp_dir}/${name}-svninfo.txt) + elseif(git_repository) + find_package(Git) + if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "error: could not find git for clone of ${name}") + endif() + + # The git submodule update '--recursive' flag requires git >= v1.6.5 + # + _ep_get_git_version("${GIT_EXECUTABLE}" git_version) + if(git_version VERSION_LESS 1.6.5) + message(FATAL_ERROR "error: git version 1.6.5 or later required for 'git submodule update --recursive': git_version='${git_version}'") + endif() + + get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) + if(NOT git_tag) + set(git_tag "master") + endif() + + set(repository ${git_repository}) + set(module) + set(tag ${git_tag}) + configure_file( + "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" + "${stamp_dir}/${name}-gitinfo.txt" + @ONLY + ) + + get_filename_component(src_name "${source_dir}" NAME) + get_filename_component(work_dir "${source_dir}" PATH) + + # Since git clone doesn't succeed if the non-empty source_dir exists, + # create a cmake script to invoke as download command. + # The script will delete the source directory and then call git clone. + # + _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} + ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${src_name} ${work_dir} + ) + set(comment "Performing download step (git clone) for '${name}'") + set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake) + list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt) elseif(url) get_filename_component(work_dir "${source_dir}" PATH) + get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) set(repository "external project URL") set(module "${url}") - set(tag "") + set(tag "${md5}") configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-urlinfo.txt" @@ -696,25 +983,36 @@ function(_ep_add_download_command name) if("${url}" MATCHES "^[a-z]+://") # TODO: Should download and extraction be different steps? string(REGEX MATCH "[^/]*$" fname "${url}") - if(NOT "${fname}" MATCHES "\\.(tar|tgz|tar\\.gz)$") + if(NOT "${fname}" MATCHES "\\.(bz2|tar|tgz|tar\\.gz|zip)$") message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}") endif() set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) - _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}") + _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}") set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake COMMAND) - set(comment "Performing download step (download and extract) for '${name}'") + set(comment "Performing download step (download, verify and extract) for '${name}'") else() set(file "${url}") - set(comment "Performing download step (extract) for '${name}'") + set(comment "Performing download step (verify and extract) for '${name}'") endif() - # TODO: Support other archive formats. - _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${file}" "${tmp_dir}" "${source_dir}") + _ep_write_verifyfile_script("${stamp_dir}/verify-${name}.cmake" "${file}" "${md5}") + list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake) + _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}") list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake) endif() else() - message(SEND_ERROR "error: no download info for '${name}' -- please specify existing SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY or DOWNLOAD_COMMAND") + _ep_is_dir_empty("${source_dir}" empty) + if(${empty}) + message(SEND_ERROR "error: no download info for '${name}' -- please specify existing/non-empty SOURCE_DIR or one of URL, CVS_REPOSITORY and CVS_MODULE, SVN_REPOSITORY, GIT_REPOSITORY or DOWNLOAD_COMMAND") + endif() + endif() + + get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD) + if(log) + set(log LOG 1) + else() + set(log "") endif() ExternalProject_Add_Step(${name} download @@ -723,6 +1021,7 @@ function(_ep_add_download_command name) WORKING_DIRECTORY ${work_dir} DEPENDS ${depends} DEPENDEES mkdir + ${log} ) endfunction(_ep_add_download_command) @@ -734,6 +1033,7 @@ function(_ep_add_update_command name) get_property(cmd TARGET ${name} PROPERTY _EP_UPDATE_COMMAND) get_property(cvs_repository TARGET ${name} PROPERTY _EP_CVS_REPOSITORY) get_property(svn_repository TARGET ${name} PROPERTY _EP_SVN_REPOSITORY) + get_property(git_repository TARGET ${name} PROPERTY _EP_GIT_REPOSITORY) set(work_dir) set(comment) @@ -757,8 +1057,33 @@ function(_ep_add_update_command name) set(work_dir ${source_dir}) set(comment "Performing update step (SVN update) for '${name}'") get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) - set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision}) + get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) + get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) + set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} + --username=${svn_username} --password=${svn_password}) set(always 1) + elseif(git_repository) + if(NOT GIT_EXECUTABLE) + message(FATAL_ERROR "error: could not find git for fetch of ${name}") + endif() + set(work_dir ${source_dir}) + set(comment "Performing update step (git fetch) for '${name}'") + get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) + if(NOT git_tag) + set(git_tag "master") + endif() + set(cmd ${GIT_EXECUTABLE} fetch + COMMAND ${GIT_EXECUTABLE} checkout ${git_tag} + COMMAND ${GIT_EXECUTABLE} submodule update --recursive + ) + set(always 1) + endif() + + get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE) + if(log) + set(log LOG 1) + else() + set(log "") endif() ExternalProject_Add_Step(${name} update @@ -767,6 +1092,7 @@ function(_ep_add_update_command name) ALWAYS ${always} WORKING_DIRECTORY ${work_dir} DEPENDEES download + ${log} ) endfunction(_ep_add_update_command) @@ -793,7 +1119,7 @@ endfunction(_ep_add_patch_command) # TODO: Make sure external projects use the proper compiler function(_ep_add_configure_command name) - ExternalProject_Get_Property(${name} source_dir binary_dir) + ExternalProject_Get_Property(${name} source_dir binary_dir tmp_dir) _ep_get_configuration_subdir_suffix(cfgdir) @@ -827,11 +1153,29 @@ function(_ep_add_configure_command name) endif() endif() + # If anything about the configure command changes, (command itself, cmake + # used, cmake args or cmake generator) then re-run the configure step. + # Fixes issue http://public.kitware.com/Bug/view.php?id=10258 + # + if(NOT EXISTS ${tmp_dir}/${name}-cfgcmd.txt.in) + file(WRITE ${tmp_dir}/${name}-cfgcmd.txt.in "cmd='@cmd@'\n") + endif() + configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt) + list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt) + + get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} configure COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES update patch DEPENDS ${file_deps} + ${log} ) endfunction(_ep_add_configure_command) @@ -846,10 +1190,18 @@ function(_ep_add_build_command name) _ep_get_build_command(${name} BUILD cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ${log} ) endfunction(_ep_add_build_command) @@ -864,10 +1216,18 @@ function(_ep_add_install_command name) _ep_get_build_command(${name} INSTALL cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} install COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES build + ${log} ) endfunction(_ep_add_install_command) @@ -895,10 +1255,18 @@ function(_ep_add_test_command name) set(dep_args DEPENDEES install) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} test COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} ${dep_args} + ${log} ) endif() endfunction(_ep_add_test_command) diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake index c11c2e3..a211ab0 100644 --- a/Modules/FindASPELL.cmake +++ b/Modules/FindASPELL.cmake @@ -20,11 +20,6 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (ASPELL_INCLUDE_DIR AND ASPELL_LIBRARIES) - # Already in cache, be silent - SET(ASPELL_FIND_QUIETLY TRUE) -ENDIF (ASPELL_INCLUDE_DIR AND ASPELL_LIBRARIES) - FIND_PATH(ASPELL_INCLUDE_DIR aspell.h ) FIND_LIBRARY(ASPELL_LIBRARIES NAMES aspell aspell-15 libaspell-15 libaspell) @@ -34,5 +29,4 @@ FIND_LIBRARY(ASPELL_LIBRARIES NAMES aspell aspell-15 libaspell-15 libaspell) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASPELL DEFAULT_MSG ASPELL_LIBRARIES ASPELL_INCLUDE_DIR) - MARK_AS_ADVANCED(ASPELL_INCLUDE_DIR ASPELL_LIBRARIES) diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index ff140f6..7272ba6 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -35,16 +35,14 @@ IF (UNIX) ENDIF (UNIX) -SET (AVIFILE_FOUND "NO") - -IF(AVIFILE_INCLUDE_DIR) - IF(AVIFILE_AVIPLAY_LIBRARY) - SET( AVIFILE_LIBRARIES ${AVIFILE_AVIPLAY_LIBRARY} ) - SET( AVIFILE_FOUND "YES" ) - SET( AVIFILE_DEFINITIONS "") - - ENDIF(AVIFILE_AVIPLAY_LIBRARY) -ENDIF(AVIFILE_INCLUDE_DIR) - +# handle the QUIETLY and REQUIRED arguments and set AVIFILE_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVIFile DEFAULT_MSG AVIFILE_INCLUDE_DIR AVIFILE_AVIPLAY_LIBRARY) + +IF (AVIFILE_FOUND) + SET(AVIFILE_LIBRARIES ${AVIFILE_AVIPLAY_LIBRARY}) + SET(AVIFILE_DEFINITIONS "") +ENDIF() MARK_AS_ADVANCED(AVIFILE_INCLUDE_DIR AVIFILE_AVIPLAY_LIBRARY) 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/FindBZip2.cmake b/Modules/FindBZip2.cmake index c969e43..2dcc9b4 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -4,7 +4,6 @@ # BZIP2_FOUND - system has BZip2 # BZIP2_INCLUDE_DIR - the BZip2 include directory # BZIP2_LIBRARIES - Link these to use BZip2 -# BZIP2_DEFINITIONS - Compiler switches required for using BZip2 # BZIP2_NEED_PREFIX - this is set if the functions are prefixed with BZ2_ #============================================================================= @@ -21,10 +20,6 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES) - SET(BZip2_FIND_QUIETLY TRUE) -ENDIF (BZIP2_INCLUDE_DIR AND BZIP2_LIBRARIES) - FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ) FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2 ) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index ea9eb25..0b47843 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -63,7 +63,7 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 1.36.0, 1.36.1, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, -# 1.40, 1.40.0, 1.41, 1.41.0 +# 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -297,6 +297,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33") diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 6539057..81d082a 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -165,7 +165,7 @@ # and will link in the resulting object file automatically. # # This script will also generate a separate cmake script that is used at -# build time to invoke nvcc. This is for serveral reasons. +# build time to invoke nvcc. This is for several reasons. # # 1. nvcc can return negative numbers as return values which confuses # Visual Studio into thinking that the command succeeded. The script now @@ -418,6 +418,10 @@ if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") unset(CUDA_VERSION CACHE) unset(CUDA_TOOLKIT_INCLUDE CACHE) unset(CUDA_CUDART_LIBRARY CACHE) + if(CUDA_VERSION VERSION_EQUAL "3.0") + # This only existed in the 3.0 version of the CUDA toolkit + unset(CUDA_CUDARTEMU_LIBRARY CACHE) + endif() unset(CUDA_CUDA_LIBRARY CACHE) unset(CUDA_cublas_LIBRARY CACHE) unset(CUDA_cublasemu_LIBRARY CACHE) @@ -484,6 +488,10 @@ if(CUDA_NVCC_EXECUTABLE AND NOT CUDA_VERSION) string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT}) set(CUDA_VERSION "${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}" CACHE STRING "Version of CUDA as computed from nvcc.") mark_as_advanced(CUDA_VERSION) +else() + # Need to set these based off of the cached value + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR "${CUDA_VERSION}") + string(REGEX REPLACE "([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR "${CUDA_VERSION}") endif() # Always set this convenience variable @@ -545,11 +553,28 @@ endmacro() # CUDA_LIBRARIES find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") -set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +if(CUDA_VERSION VERSION_EQUAL "3.0") + # The cudartemu library only existed for the 3.0 version of CUDA. + find_library_local_first(CUDA_CUDARTEMU_LIBRARY cudartemu "\"cudartemu\" library") + mark_as_advanced( + CUDA_CUDARTEMU_LIBRARY + ) +endif() +# If we are using emulation mode and we found the cudartemu library then use +# that one instead of cudart. +if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + set(CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY}) +else() + set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +endif() if(APPLE) # We need to add the path to cudart to the linker using rpath, since the # library name for the cuda libraries is prepended with @rpath. - get_filename_component(_cuda_path_to_cudart "${CUDA_CUDART_LIBRARY}" PATH) + if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) + get_filename_component(_cuda_path_to_cudart "${CUDA_CUDARTEMU_LIBRARY}" PATH) + else() + get_filename_component(_cuda_path_to_cudart "${CUDA_CUDART_LIBRARY}" PATH) + endif() if(_cuda_path_to_cudart) list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}") endif() @@ -786,7 +811,7 @@ endfunction() ############################################################################## # This helper macro populates the following variables and setups up custom # commands and targets to invoke the nvcc compiler to generate C or PTX source -# dependant upon the format parameter. The compiler is invoked once with -M +# dependent upon the format parameter. The compiler is invoked once with -M # to generate a dependency file and a second time with -cuda or -ptx to generate # a .cpp or .ptx file. # INPUT: diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index fa68190..791e6a9 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -33,6 +33,15 @@ SET(CURSES_USE_NCURSES FALSE) IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) SET(CURSES_USE_NCURSES TRUE) ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) +# http://cygwin.com/ml/cygwin-announce/2010-01/msg00002.html +# cygwin ncurses stopped providing curses.h symlinks see above +# message. Cygwin is an ncurses package, so force ncurses on +# cygwin if the curses.h is missing +IF(CYGWIN) + IF(NOT EXISTS /usr/include/curses.h) + SET(CURSES_USE_NCURSES TRUE) + ENDIF() +ENDIF() # Not sure the logic is correct here. diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake index 5b2bc59..7bf481f 100644 --- a/Modules/FindCygwin.cmake +++ b/Modules/FindCygwin.cmake @@ -17,7 +17,8 @@ IF (WIN32) FIND_PATH(CYGWIN_INSTALL_PATH cygwin.bat - "C:/Cygwin" + "C:/Cygwin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygwin\\setup;rootdir]" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/;native]" ) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 2c3fce5..d35433a 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -1,7 +1,7 @@ # - find DCMTK libraries and applications # -# DCMTK_INCLUDE_DIR - Directories to include to use DCMTK +# DCMTK_INCLUDE_DIRS - Directories to include to use DCMTK # DCMTK_LIBRARIES - Files to link against to use DCMTK # DCMTK_FOUND - If false, don't try to use DCMTK # DCMTK_DIR - (optional) Source directory for DCMTK @@ -13,7 +13,8 @@ #============================================================================= # Copyright 2004-2009 Kitware, Inc. -# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> +# Copyright 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com> +# Copyright 2010 Thomas Sondergaard <ts@medical-insight.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -28,155 +29,124 @@ # # Written for VXL by Amitha Perera. # Upgraded for GDCM by Mathieu Malaterre. -# - -IF( NOT DCMTK_FOUND ) - SET( DCMTK_DIR "/usr/include/dcmtk/" - CACHE PATH "Root of DCMTK source tree (optional)." ) - MARK_AS_ADVANCED( DCMTK_DIR ) -ENDIF( NOT DCMTK_FOUND ) - - -FIND_PATH( DCMTK_config_INCLUDE_DIR osconfig.h - ${DCMTK_DIR}/config/include - ${DCMTK_DIR}/config - ${DCMTK_DIR}/include -) - -FIND_PATH( DCMTK_ofstd_INCLUDE_DIR ofstdinc.h - ${DCMTK_DIR}/ofstd/include - ${DCMTK_DIR}/ofstd - ${DCMTK_DIR}/include/ofstd -) - -FIND_LIBRARY( DCMTK_ofstd_LIBRARY ofstd - ${DCMTK_DIR}/ofstd/libsrc - ${DCMTK_DIR}/ofstd/libsrc/Release - ${DCMTK_DIR}/ofstd/libsrc/Debug - ${DCMTK_DIR}/ofstd/Release - ${DCMTK_DIR}/ofstd/Debug - ${DCMTK_DIR}/lib -) - - -FIND_PATH( DCMTK_dcmdata_INCLUDE_DIR dctypes.h - ${DCMTK_DIR}/include/dcmdata - ${DCMTK_DIR}/dcmdata - ${DCMTK_DIR}/dcmdata/include -) - -FIND_LIBRARY( DCMTK_dcmdata_LIBRARY dcmdata - ${DCMTK_DIR}/dcmdata/libsrc - ${DCMTK_DIR}/dcmdata/libsrc/Release - ${DCMTK_DIR}/dcmdata/libsrc/Debug - ${DCMTK_DIR}/dcmdata/Release - ${DCMTK_DIR}/dcmdata/Debug - ${DCMTK_DIR}/lib -) - - -FIND_PATH( DCMTK_dcmimgle_INCLUDE_DIR dcmimage.h - ${DCMTK_DIR}/dcmimgle/include - ${DCMTK_DIR}/dcmimgle - ${DCMTK_DIR}/include/dcmimgle -) - -FIND_LIBRARY( DCMTK_dcmimgle_LIBRARY dcmimgle - ${DCMTK_DIR}/dcmimgle/libsrc - ${DCMTK_DIR}/dcmimgle/libsrc/Release - ${DCMTK_DIR}/dcmimgle/libsrc/Debug - ${DCMTK_DIR}/dcmimgle/Release - ${DCMTK_DIR}/dcmimgle/Debug - ${DCMTK_DIR}/lib -) - -# MM: I could not find this library on debian system / dcmtk 3.5.4 -FIND_LIBRARY(DCMTK_imagedb_LIBRARY imagedb - ${DCMTK_DIR}/imagectn/libsrc/Release - ${DCMTK_DIR}/imagectn/libsrc/ - ${DCMTK_DIR}/imagectn/libsrc/Debug - ) - -FIND_LIBRARY(DCMTK_dcmnet_LIBRARY dcmnet - ${DCMTK_DIR}/dcmnet/libsrc/Release - ${DCMTK_DIR}/dcmnet/libsrc/Debug - ${DCMTK_DIR}/dcmnet/libsrc/ - ) - - -IF( DCMTK_config_INCLUDE_DIR - AND DCMTK_ofstd_INCLUDE_DIR - AND DCMTK_ofstd_LIBRARY - AND DCMTK_dcmdata_INCLUDE_DIR - AND DCMTK_dcmdata_LIBRARY - AND DCMTK_dcmimgle_INCLUDE_DIR - AND DCMTK_dcmimgle_LIBRARY ) - - SET( DCMTK_FOUND "YES" ) - SET( DCMTK_INCLUDE_DIR - ${DCMTK_config_INCLUDE_DIR} +# Modified for EasyViz by Thomas Sondergaard. +# + +if(NOT DCMTK_FOUND AND NOT DCMTK_DIR) + set(DCMTK_DIR + "/usr/include/dcmtk/" + CACHE + PATH + "Root of DCMTK source tree (optional).") + mark_as_advanced(DCMTK_DIR) +endif() + + +foreach(lib + dcmdata + dcmimage + dcmimgle + dcmjpeg + dcmnet + dcmpstat + dcmqrdb + dcmsign + dcmsr + dcmtls + ijg12 + ijg16 + ijg8 + ofstd) + + find_library(DCMTK_${lib}_LIBRARY + ${lib} + PATHS + ${DCMTK_DIR}/${lib}/libsrc + ${DCMTK_DIR}/${lib}/libsrc/Release + ${DCMTK_DIR}/${lib}/libsrc/Debug + ${DCMTK_DIR}/${lib}/Release + ${DCMTK_DIR}/${lib}/Debug + ${DCMTK_DIR}/lib) + + mark_as_advanced(DCMTK_${lib}_LIBRARY) + + if(DCMTK_${lib}_LIBRARY) + list(APPEND DCMTK_LIBRARIES ${DCMTK_${lib}_LIBRARY}) + endif() + +endforeach() + + +set(DCMTK_config_TEST_HEADER osconfig.h) +set(DCMTK_dcmdata_TEST_HEADER dctypes.h) +set(DCMTK_dcmimage_TEST_HEADER dicoimg.h) +set(DCMTK_dcmimgle_TEST_HEADER dcmimage.h) +set(DCMTK_dcmjpeg_TEST_HEADER djdecode.h) +set(DCMTK_dcmnet_TEST_HEADER assoc.h) +set(DCMTK_dcmpstat_TEST_HEADER dcmpstat.h) +set(DCMTK_dcmqrdb_TEST_HEADER dcmqrdba.h) +set(DCMTK_dcmsign_TEST_HEADER sicert.h) +set(DCMTK_dcmsr_TEST_HEADER dsrtree.h) +set(DCMTK_dcmtls_TEST_HEADER tlslayer.h) +set(DCMTK_ofstd_TEST_HEADER ofstdinc.h) + +foreach(dir + config + dcmdata + dcmimage + dcmimgle + dcmjpeg + dcmnet + dcmpstat + dcmqrdb + dcmsign + dcmsr + dcmtls + ofstd) + find_path(DCMTK_${dir}_INCLUDE_DIR + ${DCMTK_${dir}_TEST_HEADER} + PATHS + ${DCMTK_DIR}/${dir}/include + ${DCMTK_DIR}/${dir} + ${DCMTK_DIR}/include/${dir}) + + mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR) + + if(DCMTK_${dir}_INCLUDE_DIR) + list(APPEND + DCMTK_INCLUDE_DIRS + ${DCMTK_${dir}_INCLUDE_DIR}) + endif() +endforeach() + +if(WIN32) + list(APPEND DCMTK_LIBRARIES netapi32 wsock32) +endif() + +if(DCMTK_ofstd_INCLUDE_DIR) + get_filename_component(DCMTK_dcmtk_INCLUDE_DIR ${DCMTK_ofstd_INCLUDE_DIR} - ${DCMTK_dcmdata_INCLUDE_DIR} - ${DCMTK_dcmimgle_INCLUDE_DIR} - ) - - SET( DCMTK_LIBRARIES - ${DCMTK_dcmimgle_LIBRARY} - ${DCMTK_dcmdata_LIBRARY} - ${DCMTK_ofstd_LIBRARY} - ${DCMTK_config_LIBRARY} - ) - - IF(DCMTK_imagedb_LIBRARY) - SET( DCMTK_LIBRARIES - ${DCMTK_LIBRARIES} - ${DCMTK_imagedb_LIBRARY} - ) - ENDIF(DCMTK_imagedb_LIBRARY) - - IF(DCMTK_dcmnet_LIBRARY) - SET( DCMTK_LIBRARIES - ${DCMTK_LIBRARIES} - ${DCMTK_dcmnet_LIBRARY} - ) - ENDIF(DCMTK_dcmnet_LIBRARY) - - IF( WIN32 ) - SET( DCMTK_LIBRARIES ${DCMTK_LIBRARIES} netapi32 ) - ENDIF( WIN32 ) - -ENDIF( DCMTK_config_INCLUDE_DIR - AND DCMTK_ofstd_INCLUDE_DIR - AND DCMTK_ofstd_LIBRARY - AND DCMTK_dcmdata_INCLUDE_DIR - AND DCMTK_dcmdata_LIBRARY - AND DCMTK_dcmimgle_INCLUDE_DIR - AND DCMTK_dcmimgle_LIBRARY ) - -FIND_PROGRAM(DCMTK_DCMDUMP_EXECUTABLE dcmdump - ${DCMTK_DIR}/bin - ) - -FIND_PROGRAM(DCMTK_DCMDJPEG_EXECUTABLE dcmdjpeg - ${DCMTK_DIR}/bin - ) - -FIND_PROGRAM(DCMTK_DCMDRLE_EXECUTABLE dcmdrle - ${DCMTK_DIR}/bin - ) - -MARK_AS_ADVANCED( - DCMTK_DCMDUMP_EXECUTABLE - DCMTK_DCMDJPEG_EXECUTABLE - DCMTK_DCMDRLE_EXECUTABLE + PATH + CACHE) + list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR}) + mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(DCMTK DEFAULT_MSG DCMTK_config_INCLUDE_DIR + DCMTK_ofstd_INCLUDE_DIR + DCMTK_ofstd_LIBRARY DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmdata_LIBRARY DCMTK_dcmimgle_INCLUDE_DIR - DCMTK_dcmimgle_LIBRARY - DCMTK_imagedb_LIBRARY - DCMTK_dcmnet_LIBRARY - DCMTK_ofstd_INCLUDE_DIR - DCMTK_ofstd_LIBRARY - ) + DCMTK_dcmimgle_LIBRARY) + +# Compatibility: This variable is deprecated +set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS}) +foreach(executable dcmdump dcmdjpeg dcmdrle) + string(TOUPPER ${executable} EXECUTABLE) + find_program(DCMTK_${EXECUTABLE}_EXECUTABLE ${executable} ${DCMTK_DIR}/bin) + mark_as_advanced(DCMTK_${EXECUTABLE}_EXECUTABLE) +endforeach() diff --git a/Modules/FindDart.cmake b/Modules/FindDart.cmake index f8c2747..65da21a 100644 --- a/Modules/FindDart.cmake +++ b/Modules/FindDart.cmake @@ -27,3 +27,10 @@ FIND_PATH(DART_ROOT README.INSTALL [HKEY_LOCAL_MACHINE\\SOFTWARE\\Dart\\InstallPath] DOC "If you have Dart installed, where is it located?" ) + +# handle the QUIETLY and REQUIRED arguments and set DART_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Dart DEFAULT_MSG DART_ROOT) + +MARK_AS_ADVANCED(DART_ROOT) diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 1c4c163..22743b1 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -33,9 +33,6 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_ IF(EXPAT_FOUND) SET(EXPAT_LIBRARIES ${EXPAT_LIBRARY}) SET(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR}) -ELSE(EXPAT_FOUND) - SET(EXPAT_LIBRARIES) - SET(EXPAT_INCLUDE_DIRS) ENDIF(EXPAT_FOUND) MARK_AS_ADVANCED(EXPAT_INCLUDE_DIR EXPAT_LIBRARY) diff --git a/Modules/FindGCCXML.cmake b/Modules/FindGCCXML.cmake index d618487..52390c3 100644 --- a/Modules/FindGCCXML.cmake +++ b/Modules/FindGCCXML.cmake @@ -1,4 +1,7 @@ # - Find the GCC-XML front-end executable. +# +# This module will define the following variables: +# GCCXML - the GCC-XML front-end executable. #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -20,3 +23,5 @@ FIND_PROGRAM(GCCXML "$ENV{ProgramFiles}/GCC_XML" "C:/Program Files/GCC_XML" ) + +MARK_AS_ADVANCED(GCCXML) diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake index 96b6dc9..81b3364 100644 --- a/Modules/FindGLU.cmake +++ b/Modules/FindGLU.cmake @@ -15,7 +15,9 @@ # Use of this file is deprecated, and is here for backwards compatibility with CMake 1.4 # GLU library is now found by FindOpenGL.cmake # -# + +MESSAGE(STATUS + "WARNING: you are using the obsolete 'GLU' package, please use 'OpenGL' instead") INCLUDE(FindOpenGL) diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake new file mode 100644 index 0000000..2d82142 --- /dev/null +++ b/Modules/FindGit.cmake @@ -0,0 +1,46 @@ +# The module defines the following variables: +# GIT_EXECUTABLE - path to git command line client +# GIT_FOUND - true if the command line client was found +# Example usage: +# find_package(Git) +# if(GIT_FOUND) +# message("git found: ${GIT_EXECUTABLE}") +# endif() + +#============================================================================= +# 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.) + +# Look for 'git' or 'eg' (easy git) +# +set(git_names git eg) + +# Prefer .cmd variants on Windows unless running in a Makefile +# in the MSYS shell. +# +if(WIN32) + if(NOT CMAKE_GENERATOR MATCHES "MSYS") + set(git_names git.cmd git eg.cmd eg) + endif() +endif() + +find_program(GIT_EXECUTABLE + NAMES ${git_names} + DOC "git command line client" + ) +mark_as_advanced(GIT_EXECUTABLE) + +# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if +# all listed variables are TRUE + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE) diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake index 9ae4a52..21bc5fd 100644 --- a/Modules/FindHSPELL.cmake +++ b/Modules/FindHSPELL.cmake @@ -1,10 +1,14 @@ -# - Try to find HSPELL +# - Try to find Hspell # Once done this will define # -# HSPELL_FOUND - system has HSPELL -# HSPELL_INCLUDE_DIR - the HSPELL include directory -# HSPELL_LIBRARIES - The libraries needed to use HSPELL -# HSPELL_DEFINITIONS - Compiler switches required for using HSPELL +# HSPELL_FOUND - system has Hspell +# HSPELL_INCLUDE_DIR - the Hspell include directory +# HSPELL_LIBRARIES - The libraries needed to use Hspell +# HSPELL_DEFINITIONS - Compiler switches required for using Hspell +# +# HSPELL_VERSION_STRING - The version of Hspell found (x.y) +# HSPELL_MAJOR_VERSION - the major version of Hspell +# HSPELL_MINOR_VERSION - The minor version of Hspell #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -20,21 +24,20 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (HSPELL_INCLUDE_DIR AND HSPELL_LIBRARIES) - # Already in cache, be silent - SET(HSPELL_FIND_QUIETLY TRUE) -ENDIF (HSPELL_INCLUDE_DIR AND HSPELL_LIBRARIES) - +FIND_PATH(HSPELL_INCLUDE_DIR hspell.h) -FIND_PATH(HSPELL_INCLUDE_DIR hspell.h ) +FIND_LIBRARY(HSPELL_LIBRARIES NAMES hspell) -FIND_LIBRARY(HSPELL_LIBRARIES NAMES hspell ) +IF (HSPELL_INCLUDE_DIR) + FILE(READ "${HSPELL_INCLUDE_DIR}/hspell.h" HSPELL_H) + STRING(REGEX REPLACE ".*#define HSPELL_VERSION_MAJOR ([0-9]+).*" "\\1" HSPELL_VERSION_MAJOR "${HSPELL_H}") + STRING(REGEX REPLACE ".*#define HSPELL_VERSION_MINOR ([0-9]+).*" "\\1" HSPELL_VERSION_MINOR "${HSPELL_H}") +ENDIF() # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(HSPELL DEFAULT_MSG HSPELL_LIBRARIES HSPELL_INCLUDE_DIR) - MARK_AS_ADVANCED(HSPELL_INCLUDE_DIR HSPELL_LIBRARIES) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index a61c683..edb76cb 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -29,24 +29,49 @@ # Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var} MACRO(java_append_library_directories _var) # Determine java arch-specific library subdir - IF (CMAKE_SYSTEM_NAME MATCHES "Linux") - # Based on openjdk/jdk/make/common/shared/Platform.gmk as of 6b16 - # and kaffe as of 1.1.8 which uses the first part of the - # GNU config.guess platform triplet. - IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - SET(_java_libarch "i386") - ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - SET(_java_libarch "amd64" "x86_64") - ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc") - SET(_java_libarch "ppc" "powerpc" "ppc64") - ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") - SET(_java_libarch "sparc" "sparcv9") - ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") - ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux") - SET(_java_libarch "i386" "amd64" "ppc") # previous default - ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk + # 1.6.0_18 + icedtea patches. However, it would be much better to base the + # guess on the first part of the GNU config.guess platform triplet. + IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "amd64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + SET(_java_libarch "i386") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") + SET(_java_libarch "alpha") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + # Subdir is "arm" for both big-endian (arm) and little-endian (armel). + SET(_java_libarch "arm") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") + # mips* machines are bi-endian mostly so processor does not tell + # endianess of the underlying system. + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") + SET(_java_libarch "ppc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") + SET(_java_libarch "ppc") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") + # Both flavours can run on the same processor + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)") + SET(_java_libarch "parisc" "parisc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390") + # s390 binaries can run on s390x machines + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh") + SET(_java_libarch "sh") + ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") + ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + + # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or + # system is non-Linux (where the code above has not been well tested) + IF(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux")) + LIST(APPEND _java_libarch "i386" "amd64" "ppc") + ENDIF(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux")) + + # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer + # current value to a hardcoded list. Remove possible duplicates. + LIST(REMOVE_DUPLICATES _java_libarch) FOREACH(_path ${ARGN}) IF(_path MATCHES "{libarch}") diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index 553654e..4f8ccb7 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -21,19 +21,10 @@ FIND_PACKAGE(JPEG) -IF (JASPER_INCLUDE_DIR AND JASPER_LIBRARIES AND JPEG_LIBRARIES) - # Already in cache, be silent - SET(Jasper_FIND_QUIETLY TRUE) -ENDIF (JASPER_INCLUDE_DIR AND JASPER_LIBRARIES AND JPEG_LIBRARIES) - FIND_PATH(JASPER_INCLUDE_DIR jasper/jasper.h) FIND_LIBRARY(JASPER_LIBRARY NAMES jasper libjasper) -IF (JASPER_INCLUDE_DIR AND JASPER_LIBRARY AND JPEG_LIBRARIES) - SET(JASPER_LIBRARIES ${JASPER_LIBRARY} ${JPEG_LIBRARIES} ) -ENDIF (JASPER_INCLUDE_DIR AND JASPER_LIBRARY AND JPEG_LIBRARIES) - # handle the QUIETLY and REQUIRED arguments and set JASPER_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) @@ -43,4 +34,4 @@ IF (JASPER_FOUND) SET(JASPER_LIBRARIES ${JASPER_LIBRARY} ${JPEG_LIBRARIES} ) ENDIF (JASPER_FOUND) -MARK_AS_ADVANCED(JASPER_INCLUDE_DIR JASPER_LIBRARIES JASPER_LIBRARY) +MARK_AS_ADVANCED(JASPER_INCLUDE_DIR JASPER_LIBRARY) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 7eb6d900c..4cd4389 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -24,9 +24,18 @@ # and # Java_VERSION = 1.6.0 # -# NOTE: At the moment this script will look for javac and jar component, -# which means it will fail if javac or jar is not found.:w -# See Bug #9840 +# For these components the following variables are set: +# +# Java_FOUND - TRUE if all components are found. +# Java_INCLUDE_DIRS - Full paths to all include dirs. +# Java_LIBRARIES - Full paths to all libraries. +# Java_<component>_FOUND - TRUE if <component> is found. +# +# Example Usages: +# FIND_PACKAGE(Java) +# FIND_PACKAGE(Java COMPONENTS Runtime) +# FIND_PACKAGE(Java COMPONENTS Development) +# #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -82,7 +91,11 @@ IF(Java_JAVA_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) IF( res ) - MESSAGE( FATAL_ERROR "Error executing java -version" ) + IF(${Java_FIND_REQUIRED}) + MESSAGE( FATAL_ERROR "Error executing java -version" ) + ELSE() + MESSAGE( STATUS "Warning, could not run java --version") + ENDIF() ELSE() # extract major/minor version and patch level from "java -version" output # Tested on linux using @@ -148,12 +161,36 @@ FIND_PROGRAM(Java_JAVAC_EXECUTABLE ) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - Java_JAR_EXECUTABLE - Java_JAVAC_EXECUTABLE - _java_version_acceptable -) +if(Java_FIND_COMPONENTS) + foreach(component ${Java_FIND_COMPONENTS}) + # User just want to execute some Java byte-compiled + if(component STREQUAL "Runtime") + find_package_handle_standard_args(Java DEFAULT_MSG + Java_JAVA_EXECUTABLE + _java_version_acceptable + ) + elseif(component STREQUAL "Development") + find_package_handle_standard_args(Java DEFAULT_MSG + Java_JAVA_EXECUTABLE + Java_JAR_EXECUTABLE + Java_JAVAC_EXECUTABLE + _java_version_acceptable + ) + else() + message(FATAL_ERROR "Comp: ${component} is not handled") + endif() + set(Java_${component}_FOUND TRUE) + endforeach(component) +else() + # Check for everything + find_package_handle_standard_args(Java DEFAULT_MSG + Java_JAVA_EXECUTABLE + Java_JAR_EXECUTABLE + Java_JAVAC_EXECUTABLE + _java_version_acceptable + ) +endif() + MARK_AS_ADVANCED( Java_JAVA_EXECUTABLE diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake index 12fd304..42a1530 100644 --- a/Modules/FindKDE4.cmake +++ b/Modules/FindKDE4.cmake @@ -73,7 +73,7 @@ IF(NOT KDE4_DATA_DIR) EXECUTE_PROCESS(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) FILE(TO_CMAKE_PATH "${_data_DIR}" _data_DIR) # then check the data dirs for FindKDE4Internal.cmake - FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake ${_data_DIR}) + FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake HINTS ${_data_DIR}) ENDIF(KDE4_KDECONFIG_EXECUTABLE) ENDIF(CMAKE_CROSSCOMPILING) ENDIF(NOT KDE4_DATA_DIR) 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/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 9139aad..67db321 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -24,7 +24,7 @@ # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) +PKG_CHECK_MODULES(PC_LIBXML libxml-2.0 QUIET) SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) FIND_PATH(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h @@ -44,10 +44,9 @@ FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint) # for backwards compat. with KDE 4.0.x: SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") -INCLUDE(FindPackageHandleStandardArgs) - # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index d16d1ff..a03aa7c 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -26,9 +26,8 @@ FIND_PACKAGE(PkgConfig) PKG_CHECK_MODULES(PC_LIBXSLT libxslt) SET(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER}) - FIND_PATH(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h - HINTS + HINTS ${PC_LIBXSLT_INCLUDEDIR} ${PC_LIBXSLT_INCLUDE_DIRS} ) @@ -39,12 +38,10 @@ FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt ${PC_LIBXSLT_LIBRARY_DIRS} ) -INCLUDE(FindPackageHandleStandardArgs) - # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR) - MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES) diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake index a19f73e..0c06c94 100644 --- a/Modules/FindMPEG.cmake +++ b/Modules/FindMPEG.cmake @@ -35,8 +35,10 @@ FIND_LIBRARY( MPEG_vo_LIBRARY vo # handle the QUIETLY and REQUIRED arguments and set MPEG2_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY) IF(MPEG_FOUND) SET( MPEG_LIBRARIES ${MPEG_mpeg2_LIBRARY} ${MPEG_vo_LIBRARY} ) ENDIF(MPEG_FOUND) + +MARK_AS_ADVANCED(MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 094f9e6..21dadd9 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -86,6 +86,7 @@ set(_MPI_PACKAGE_DIR set(_MPI_PREFIX_PATH) if(WIN32) list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") + list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]") endif() foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) @@ -187,7 +188,7 @@ if (MPI_INCLUDE_PATH AND MPI_LIBRARY) # the cache, and we don't want to override those settings. elseif (MPI_COMPILE_CMDLINE) # Extract compile flags from the compile command line. - string(REGEX MATCHALL "-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") set(MPI_COMPILE_FLAGS_WORK) foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) if (MPI_COMPILE_FLAGS_WORK) @@ -198,10 +199,10 @@ elseif (MPI_COMPILE_CMDLINE) endforeach(FLAG) # Extract include paths from compile command line - string(REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") set(MPI_INCLUDE_PATH_WORK) foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) - string(REGEX REPLACE "^-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) string(REGEX REPLACE "//" "/" IPATH ${IPATH}) list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) endforeach(IPATH) @@ -229,10 +230,10 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_INCLUDE_PATH_WORK) # Extract linker paths from the link command line - string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") set(MPI_LINK_PATH) foreach(LPATH ${MPI_ALL_LINK_PATHS}) - string(REGEX REPLACE "^-L" "" LPATH ${LPATH}) + string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) string(REGEX REPLACE "//" "/" LPATH ${LPATH}) list(APPEND MPI_LINK_PATH ${LPATH}) endforeach(LPATH) @@ -250,7 +251,7 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_LINK_PATH) # Extract linker flags from the link command line - string(REGEX MATCHALL "-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") set(MPI_LINK_FLAGS_WORK) foreach(FLAG ${MPI_ALL_LINK_FLAGS}) if (MPI_LINK_FLAGS_WORK) @@ -262,20 +263,20 @@ elseif (MPI_COMPILE_CMDLINE) # Extract the set of libraries to link against from the link command # line - string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") # Determine full path names for all of the libraries that one needs # to link against in an MPI program set(MPI_LIBRARIES) foreach(LIB ${MPI_LIBNAMES}) - string(REGEX REPLACE "^-l" "" LIB ${LIB}) + string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) if (MPI_LIB) list(APPEND MPI_LIBRARIES ${MPI_LIB}) - else (MPI_LIB) - message(SEND_ERROR "Unable to find MPI library ${LIB}") - endif (MPI_LIB) + elseif (NOT MPI_FIND_QUIETLY) + message(WARNING "Unable to find MPI library ${LIB}") + endif () endforeach(LIB) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) @@ -331,12 +332,6 @@ else (MPI_COMPILE_CMDLINE) set(MPI_LINK_FLAGS "" CACHE STRING "MPI linking flags") endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) -# on BlueGene/L the MPI lib is named libmpich.rts.a, there also these additional libs are required -if("${MPI_LIBRARY}" MATCHES "mpich.rts") - set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY} msglayer.rts devices.rts rts.rts devices.rts) - set(MPI_LIBRARY ${MPI_LIBRARY} msglayer.rts devices.rts rts.rts devices.rts) -endif("${MPI_LIBRARY}" MATCHES "mpich.rts") - # Set up extra variables to conform to if (MPI_EXTRA_LIBRARY) set(MPI_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index b9b7078..f42a69a 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -95,8 +95,9 @@ FIND_LIBRARY(OPENAL_LIBRARY ) -SET(OPENAL_FOUND "NO") -IF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR) - SET(OPENAL_FOUND "YES") -ENDIF(OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR) +# handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) +MARK_AS_ADVANCED(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index b056020..bf47ab8 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -1,6 +1,9 @@ # - Try to find the OpenSSL encryption library # Once done this will define # +# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL +# +# Read-Only variables: # OPENSSL_FOUND - system has the OpenSSL library # OPENSSL_INCLUDE_DIR - the OpenSSL include directory # OPENSSL_LIBRARIES - The libraries needed to use OpenSSL @@ -8,7 +11,7 @@ #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006 Alexander Neundorf <neundorf@kde.org> -# Copyright 2009 Mathieu Malaterre <mathieu.malaterre@gmail.com> +# Copyright 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -21,8 +24,23 @@ # License text for the above reference.) # http://www.slproweb.com/products/Win32OpenSSL.html +SET(_OPENSSL_ROOT_HINTS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" + ) +SET(_OPENSSL_ROOT_PATHS + "C:/OpenSSL/" + ) +FIND_PATH(OPENSSL_ROOT_DIR + NAMES include/openssl/ssl.h + HINTS ${_OPENSSL_ROOT_HINTS} + PATHS ${_OPENSSL_ROOT_PATHS} +) +MARK_AS_ADVANCED(OPENSSL_ROOT_DIR) + +# Re-use the previous path: FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/include" + PATHS ${OPENSSL_ROOT_DIR}/include ) IF(WIN32 AND NOT CYGWIN) @@ -43,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 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/VC" + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) set( OPENSSL_LIBRARIES @@ -67,20 +85,20 @@ IF(WIN32 AND NOT CYGWIN) ELSEIF(MINGW) # same player, for MingW FIND_LIBRARY(LIB_EAY NAMES libeay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib/MinGW" + PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/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 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib" + PATHS ${OPENSSL_ROOT_DIR}/lib ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]/lib" + PATHS ${OPENSSL_ROOT_DIR}/lib ) MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index 8df3573..bfc5d4a 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -33,7 +33,7 @@ if(ZLIB_FOUND) /usr/local/include/libpng # OpenBSD ) - set(PNG_NAMES ${PNG_NAMES} png libpng png12 libpng12) + set(PNG_NAMES ${PNG_NAMES} png libpng png14 libpng14 png14d libpng14d png12 libpng12 png12d libpng12d) find_library(PNG_LIBRARY NAMES ${PNG_NAMES} ) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) 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/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index 4775a8e..98bebe6 100644 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -54,8 +54,8 @@ FIND_LIBRARY(PHYSFS_LIBRARY /opt ) -SET(PHYSFS_FOUND "NO") -IF(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR) - SET(PHYSFS_FOUND "YES") -ENDIF(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR) +# handle the QUIETLY and REQUIRED arguments and set PHYSFS_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 6e6b802..3cbb7af 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -1,15 +1,17 @@ # - a pkg-config module for CMake # # Usage: -# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*) +# pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) # checks for all the given modules # -# pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*) +# pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) # checks for given modules and uses the first working one # # When the 'REQUIRED' argument was set, macros will fail with an error # when module(s) could not be found # +# When the 'QUIET' argument is set, no status messages will be printed. +# # It sets the following variables: # PKG_CONFIG_FOUND ... true if pkg-config works on the system # PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program @@ -138,17 +140,22 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro(_pkgconfig_invoke_dyn) # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req) +macro(_pkgconfig_parse_options _result _is_req _is_silent) set(${_is_req} 0) + set(${_is_silent} 0) foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") set(${_is_req} 1) endif (_pkg STREQUAL "REQUIRED") + if (_pkg STREQUAL "QUIET") + set(${_is_silent} 1) + endif (_pkg STREQUAL "QUIET") endforeach(_pkg ${ARGN}) set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") + list(REMOVE_ITEM ${_result} "QUIET") endmacro(_pkgconfig_parse_options) ### @@ -279,7 +286,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir ) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) - message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + if (NOT ${_is_silent}) + message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + endif (NOT ${_is_silent}) endforeach(_pkg_check_modules_pkg) # set variables which are combined for multiple modules @@ -307,8 +316,8 @@ endmacro(_pkg_check_modules_internal) macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) @@ -319,9 +328,11 @@ macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) - message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + if (NOT ${_pkg_is_silent}) + message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + endif (NOT ${_pkg_is_silent}) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake new file mode 100644 index 0000000..e96e1d9 --- /dev/null +++ b/Modules/FindPostgreSQL.cmake @@ -0,0 +1,181 @@ +# Find the PostgreSQL installation. +# +# ---------------------------------------------------------------------------- +# Usage: +# In your CMakeLists.txt file do something like this: +# ... +# # PostgreSQL +# FIND_PACKAGE(PostgreSQL) +# ... +# if( PostgreSQL_FOUND ) +# include_directories(${PostgreSQL_INCLUDE_DIRS}) +# link_directories(${PostgreSQL_LIBRARY_DIRS}) +# endif( PostgreSQL_FOUND ) +# ... +# Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement. +# +# +# In Windows, we make the assumption that, if the PostgreSQL files are installed, the default directory +# will be C:\Program Files\PostgreSQL. +# + +#============================================================================= +# Copyright 2004-2009 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.) + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version mumber of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling FIND_PACKAGE(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that <Your Path> +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. <Your Path>. +# +# ---------------------------------------------------------------------------- + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_ROOT_DIRECTORIES $ENV{PostgreSQL_ROOT}) +if(PostgreSQL_ROOT_DIRECTORIES) + file(TO_CMAKE_PATH ${PostgreSQL_ROOT_DIRECTORIES} PostgreSQL_ROOT_DIRECTORIES) +endif(PostgreSQL_ROOT_DIRECTORIES) + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + +# Define additional search paths for root directories. +if ( WIN32 ) + foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} ) + set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" ) + endforeach(suffix) +endif( WIN32 ) +set( PostgreSQL_ROOT_DIRECTORIES + ${PostgreSQL_ROOT_DIRECTORIES} + ${PostgreSQL_ROOT} + ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} +) + +# +# Look for an installation. +# +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + postgresql + include + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + +# The PostgreSQL library. +set (PostgreSQL_LIBRARY_TO_FIND pq) +# Setting some more prefixes for the library +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() + +find_library( PostgreSQL_LIBRARY + NAMES ${PostgreSQL_LIBRARY_TO_FIND} + PATHS + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib +) +get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) + +# Did we find anything? +set( PostgreSQL_FOUND 0 ) +if ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + set( PostgreSQL_FOUND 1 ) +else ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + if ( POSTGRES_REQUIRED ) + message( FATAL_ERROR "PostgreSQL is required. ${PostgreSQL_ROOT_DIR_MESSAGE}" ) + endif ( POSTGRES_REQUIRED ) +endif (EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) + +# Now try to get the include and library path. +if(PostgreSQL_FOUND) + + if(EXISTS "${PostgreSQL_INCLUDE_DIR}") + set(PostgreSQL_INCLUDE_DIRS + ${PostgreSQL_INCLUDE_DIR} + ) + endif(EXISTS "${PostgreSQL_INCLUDE_DIR}") + + if(EXISTS "${PostgreSQL_LIBRARY_DIR}") + set(PostgreSQL_LIBRARY_DIRS + ${PostgreSQL_LIBRARY_DIR} + ) + set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) + endif(EXISTS "${PostgreSQL_LIBRARY_DIR}") + + #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}") + #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}") + #message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}") +endif(PostgreSQL_FOUND) + +if(NOT PostgreSQL_FOUND) + if(NOT PostgreSQL_FIND_QUIETLY) + message(STATUS "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") + else(NOT PostgreSQL_FIND_QUIETLY) + if(PostgreSQL_FIND_REQUIRED) + message(FATAL_ERROR "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") + endif(PostgreSQL_FIND_REQUIRED) + endif(NOT PostgreSQL_FIND_QUIETLY) +endif(NOT PostgreSQL_FOUND) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 76d7950..0a813a4 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -358,35 +358,95 @@ SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) SET( QT_DEFINITIONS "") -SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) +# convenience macro for dealing with debug/release library names +MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) + + STRING(TOUPPER "${_camelCaseBasename}" basename) + + # The name of the imported targets, i.e. the prefix "Qt4::" must not change, + # since it is stored in EXPORT-files as name of a required library. If the name would change + # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. + IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF(NOT TARGET Qt4::${_camelCaseBasename}) + ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) + + IF (QT_${basename}_LIBRARY_RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + ENDIF (QT_${basename}_LIBRARY_RELEASE) + + IF (QT_${basename}_LIBRARY_DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + ENDIF (QT_${basename}_LIBRARY_DEBUG) + ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) + + # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these + # imported targets. This works better in general, and is also in almost all cases fully + # backward compatible. The only issue is when a project A which had this enabled then exports its + # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project + # A will depend on the imported Qt targets, and the names of these imported targets will be stored + # in the dependency files on disk. This means when a project B then uses project A, these imported + # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a + # library file on disk, and not as a target, and linking will fail: + IF(QT_USE_IMPORTED_TARGETS) + SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) + SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) + ELSE(QT_USE_IMPORTED_TARGETS) + + # if the release- as well as the debug-version of the library have been found: + IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + # if the generator supports configuration types then set + # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value + IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + # if there are no configuration types and CMAKE_BUILD_TYPE has no value + # then just use the release libraries + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) + ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + + # if only the release version was found, set the debug variable also to the release version + IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) + ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + + # if only the debug version was found, set the release variable also to the debug version + IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + + # put the value in the cache: + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF(QT_USE_IMPORTED_TARGETS) + + SET(QT_${basename}_FOUND 1) + + ELSE (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + SET(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF (QT_${basename}_INCLUDE_DIR) + #add the include directory to QT_INCLUDES + SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) + ENDIF (QT_${basename}_INCLUDE_DIR) + + # Make variables changeble to the advanced user + MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) +ENDMACRO (_QT4_ADJUST_LIB_VARS) -# macro for asking qmake to process pro files -MACRO(QT_QUERY_QMAKE outvar invar) - IF(QT_QMAKE_EXECUTABLE) - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro - "message(CMAKE_MESSAGE<$$${invar}>)") - - # Invoke qmake with the tmp.pro program to get the desired - # information. Use the same variable for both stdout and stderr - # to make sure we get the output on all platforms. - EXECUTE_PROCESS(COMMAND ${QT_QMAKE_EXECUTABLE} - WORKING_DIRECTORY - ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake - OUTPUT_VARIABLE _qmake_query_output - RESULT_VARIABLE _qmake_result - ERROR_VARIABLE _qmake_query_output ) - - FILE(REMOVE_RECURSE - "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake") - - IF(_qmake_result) - MESSAGE(WARNING " querying qmake for ${invar}. qmake reported:\n${_qmake_query_output}") - ELSE(_qmake_result) - STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}") - ENDIF(_qmake_result) - - ENDIF(QT_QMAKE_EXECUTABLE) -ENDMACRO(QT_QUERY_QMAKE) + +SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) # check for qmake @@ -397,6 +457,7 @@ FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin" $ENV{QTDIR}/bin + DOC "The qmake executable for the Qt installation to use" ) IF (QT_QMAKE_EXECUTABLE) @@ -418,6 +479,7 @@ IF (QT_QMAKE_EXECUTABLE) "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin" $ENV{QTDIR}/bin + DOC "The qmake executable for the Qt installation to use" ) IF(QT_QMAKE_EXECUTABLE) EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} @@ -494,53 +556,147 @@ ENDIF (QT_QMAKE_EXECUTABLE) IF (QT4_QMAKE_FOUND) - # ask qmake for the library dir - # Set QT_LIBRARY_DIR - IF (NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) + # ask qmake for the mkspecs directory + # we do this first because QT_LIBINFIX might be set + IF (NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) + EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} + ARGS "-query QMAKE_MKSPECS" + OUTPUT_VARIABLE qt_mkspecs_dirs ) + # do not replace : on windows as it might be a drive letter + # and windows should already use ; as a separator + IF(NOT WIN32) + STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") + ENDIF(NOT WIN32) + set(qt_cross_paths) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs") + endforeach(qt_cross_path) + SET(QT_MKSPECS_DIR NOTFOUND) + FIND_PATH(QT_MKSPECS_DIR NAMES qconfig.pri + HINTS ${qt_cross_paths} ${qt_mkspecs_dirs} + DOC "The location of the Qt mkspecs containing qconfig.pri") + ENDIF() + + IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) + STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") + STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") + ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + IF("${QT_EDITION}" MATCHES "DesktopLight") + SET(QT_EDITION_DESKTOPLIGHT 1) + ENDIF("${QT_EDITION}" MATCHES "DesktopLight") + + # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the + # others and for setting QT_LIBRARY_DIR + IF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_LIBS" OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP) - IF(EXISTS "${QT_LIBRARY_DIR_TMP}") - SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir" FORCE) - ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.") - ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}") - ENDIF(NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) - + SET(QT_QTCORE_LIBRARY_RELEASE NOTFOUND) + SET(QT_QTCORE_LIBRARY_DEBUG NOTFOUND) + FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE + NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG + NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + + # try dropping a hint if trying to use Visual Studio with Qt built by mingw + IF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) + IF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw. Those compilers do not produce code compatible with each other.") + ENDIF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) + + ENDIF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + + _QT4_ADJUST_LIB_VARS(QtCore) + + # set QT_LIBRARY_DIR based on location of QtCore found. + IF(QT_QTCORE_LIBRARY_RELEASE) + GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSEIF(QT_QTCORE_LIBRARY_DEBUG) + GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSE() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") + IF(Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") + ENDIF(Qt4_FIND_REQUIRED) + ENDIF() + IF (APPLE) IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) ENDIF (APPLE) # ask qmake for the binary dir - IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + IF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_BINS" OUTPUT_VARIABLE qt_bins ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins) SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + ENDIF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) # ask qmake for the include dir - IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) + IF (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED)) EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_HEADERS" OUTPUT_VARIABLE qt_headers ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers) - SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) + SET(QT_QTCORE_INCLUDE_DIR NOTFOUND) + FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore + HINTS ${qt_headers} + ${QT_LIBRARY_DIR}/QtCore.framework/Headers + PATH_SUFFIXES QtCore + ) + + # Set QT_HEADERS_DIR based on finding QtCore header + IF(QT_QTCORE_INCLUDE_DIR) + IF(QT_USE_FRAMEWORKS) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ELSE(QT_USE_FRAMEWORKS) + GET_FILENAME_COMPONENT(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ENDIF(QT_USE_FRAMEWORKS) + ELSEIF() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") + ENDIF() + ENDIF() + + # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR + IF(QT_HEADERS_DIR) + IF(QT_USE_FRAMEWORKS) + # Qt/Mac frameworks has two include dirs. + # One is the framework include for which CMake will add a -F flag + # and the other is an include dir for non-framework Qt modules + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY} ) + ELSE(QT_USE_FRAMEWORKS) + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) + ENDIF(QT_USE_FRAMEWORKS) + ENDIF(QT_HEADERS_DIR) + + # Set QT_INCLUDES + SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}) # ask qmake for the documentation directory @@ -553,21 +709,6 @@ IF (QT4_QMAKE_FOUND) SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE) ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR OR QT_QMAKE_CHANGED) - # ask qmake for the mkspecs directory - IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QMAKE_MKSPECS" - OUTPUT_VARIABLE qt_mkspecs_dirs ) - # do not replace : on windows as it might be a drive letter - # and windows should already use ; as a separator - IF(UNIX) - STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") - ENDIF(UNIX) - SET(QT_MKSPECS_DIR NOTFOUND) - FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs} - DOC "The location of the Qt mkspecs containing qconfig.pri" - NO_DEFAULT_PATH ) - ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the plugins directory IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) @@ -576,7 +717,13 @@ IF (QT4_QMAKE_FOUND) OUTPUT_VARIABLE qt_plugins_dir ) # make sure we have / and not \ as qmake gives on windows FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir) - SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins" FORCE) + SET(QT_PLUGINS_DIR NOTFOUND) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins") + endforeach(qt_cross_path) + FIND_PATH(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer + HINTS ${qt_cross_paths} ${qt_plugins_dir} + DOC "The location of the Qt plugins") ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the translations directory @@ -594,6 +741,8 @@ IF (QT4_QMAKE_FOUND) QT_PLUGINS_DIR QT_TRANSLATIONS_DIR) + + ############################################# # # Find out what window system we're using @@ -603,11 +752,7 @@ IF (QT4_QMAKE_FOUND) SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES - SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_HEADERS_DIR}") - # On Mac OS X when Qt has framework support, also add the framework path - IF( QT_USE_FRAMEWORKS ) - SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ") - ENDIF( QT_USE_FRAMEWORKS ) + SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") # Check for Window system symbols (note: only one should end up being set) CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) @@ -641,7 +786,7 @@ IF (QT4_QMAKE_FOUND) # ######################################## - SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools + SET(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools QtDeclarative) @@ -674,10 +819,10 @@ IF (QT4_QMAKE_FOUND) SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND) SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND) SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND) SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) ENDIF(QT_QMAKE_CHANGED) FOREACH(QT_MODULE ${QT_MODULES}) @@ -700,20 +845,18 @@ IF (QT4_QMAKE_FOUND) ENDIF(${QT_MODULE} STREQUAL "phonon") ENDFOREACH(QT_MODULE) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer) # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents @@ -739,49 +882,6 @@ IF (QT4_QMAKE_FOUND) NO_DEFAULT_PATH ) - # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR} - IF( QT_QTCORE_INCLUDE_DIR ) - IF (QT_USE_FRAMEWORKS) - SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) - ELSE (QT_USE_FRAMEWORKS) - STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR}) - SET( QT_INCLUDE_DIR ${qt4_include_dir}) - ENDIF (QT_USE_FRAMEWORKS) - ENDIF( QT_QTCORE_INCLUDE_DIR ) - - IF( NOT QT_INCLUDE_DIR) - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore header") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( QT_INCLUDE_DIR ) - - # Set QT_INCLUDES - SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ) - - - - - - ####################################### - # - # Qt configuration - # - ####################################### - IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) - STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") - STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") - ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - IF("${QT_EDITION}" MATCHES "DesktopLight") - SET(QT_EDITION_DESKTOPLIGHT 1) - ENDIF("${QT_EDITION}" MATCHES "DesktopLight") - ######################################## # # Setting the LIBRARY-Variables @@ -806,48 +906,32 @@ IF (QT4_QMAKE_FOUND) FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) - IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - - # try dropping a hint if trying to use Visual Studio with Qt built by mingw - IF(QT_LIBRARY_DIR AND MSVC) - IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw") - ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - ENDIF(QT_LIBRARY_DIR AND MSVC) - - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - # Set QT_QTDESIGNERCOMPONENTS_LIBRARY - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTMAIN_LIBRARY - IF(WIN32) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - ENDIF(WIN32) + IF(Q_WS_WIN) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + ENDIF(Q_WS_WIN) # Set QT_QTASSISTANTCLIENT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTHELP_LIBRARY - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # QtCLucene not with other frameworks with binary installation (in /usr/lib) IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) + ############################################ # # Check the existence of the libraries. @@ -861,137 +945,23 @@ IF (QT4_QMAKE_FOUND) ENDIF(QT_USE_FRAMEWORKS) - MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) - - STRING(TOUPPER "${_camelCaseBasename}" basename) - - # The name of the imported targets, i.e. the prefix "Qt4::" must not change, - # since it is stored in EXPORT-files as name of a required library. If the name would change - # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. - IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF(NOT TARGET Qt4::${_camelCaseBasename}) - ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) - - IF (QT_${basename}_LIBRARY_RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) - ENDIF (QT_${basename}_LIBRARY_RELEASE) - - IF (QT_${basename}_LIBRARY_DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) - ENDIF (QT_${basename}_LIBRARY_DEBUG) - ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) - - # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these - # imported targets. This works better in general, and is also in almost all cases fully - # backward compatible. The only issue is when a project A which had this enabled then exports its - # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project - # A will depend on the imported Qt targets, and the names of these imported targets will be stored - # in the dependency files on disk. This means when a project B then uses project A, these imported - # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a - # library file on disk, and not as a target, and linking will fail: - IF(QT_USE_IMPORTED_TARGETS) - SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) - SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) - ELSE(QT_USE_IMPORTED_TARGETS) - - # if the release- as well as the debug-version of the library have been found: - IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) - ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - - # if only the release version was found, set the debug variable also to the release version - IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) - ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - - # if only the debug version was found, set the release variable also to the debug version - IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - - # put the value in the cache: - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) - - ENDIF(QT_USE_IMPORTED_TARGETS) - -# message(STATUS "QT_${basename}_LIBRARY: ${QT_${basename}_LIBRARY}") - - SET(QT_${basename}_FOUND 1) - - ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF (QT_${basename}_INCLUDE_DIR) - #add the include directory to QT_INCLUDES - SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) - ENDIF (QT_${basename}_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) - ENDMACRO (_QT4_ADJUST_LIB_VARS) - - # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES - _QT4_ADJUST_LIB_VARS(QtCore) - _QT4_ADJUST_LIB_VARS(QtGui) - _QT4_ADJUST_LIB_VARS(Qt3Support) + FOREACH(QT_MODULE ${QT_MODULES}) + _QT4_ADJUST_LIB_VARS(${QT_MODULE}) + ENDFOREACH(QT_MODULE) + _QT4_ADJUST_LIB_VARS(QtAssistant) _QT4_ADJUST_LIB_VARS(QtAssistantClient) _QT4_ADJUST_LIB_VARS(QtCLucene) - _QT4_ADJUST_LIB_VARS(QtDBus) - _QT4_ADJUST_LIB_VARS(QtDeclarative) - _QT4_ADJUST_LIB_VARS(QtDesigner) _QT4_ADJUST_LIB_VARS(QtDesignerComponents) - _QT4_ADJUST_LIB_VARS(QtHelp) - _QT4_ADJUST_LIB_VARS(QtMultimedia) - _QT4_ADJUST_LIB_VARS(QtNetwork) - _QT4_ADJUST_LIB_VARS(QtNsPlugin) - _QT4_ADJUST_LIB_VARS(QtOpenGL) - _QT4_ADJUST_LIB_VARS(QtScript) - _QT4_ADJUST_LIB_VARS(QtScriptTools) - _QT4_ADJUST_LIB_VARS(QtSql) - _QT4_ADJUST_LIB_VARS(QtSvg) - _QT4_ADJUST_LIB_VARS(QtTest) - _QT4_ADJUST_LIB_VARS(QtUiTools) - _QT4_ADJUST_LIB_VARS(QtWebKit) - _QT4_ADJUST_LIB_VARS(QtXml) - _QT4_ADJUST_LIB_VARS(QtXmlPatterns) - _QT4_ADJUST_LIB_VARS(phonon) # platform dependent libraries - IF(Q_WS_X11) - _QT4_ADJUST_LIB_VARS(QtMotif) - ENDIF(Q_WS_X11) - IF(WIN32) + IF(Q_WS_WIN) _QT4_ADJUST_LIB_VARS(qtmain) _QT4_ADJUST_LIB_VARS(QAxServer) _QT4_ADJUST_LIB_VARS(QAxContainer) - ENDIF(WIN32) - - # If Qt is installed as a framework, we need to add QT_QTCORE_LIBRARY here (which - # is the framework directory in that case), since this will make the cmake include_directories() - # command recognize that we need the framework flag with the respective directory (-F) - IF(QT_USE_FRAMEWORKS) - SET(QT_INCLUDES ${QT_INCLUDES} ${QT_QTCORE_LIBRARY} ) - SET(QT_INCLUDE_DIR ${QT_INCLUDE_DIR} ${QT_QTCORE_LIBRARY} ) - ENDIF(QT_USE_FRAMEWORKS) - + ENDIF(Q_WS_WIN) ####################################### diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake index aa13ae9..f693543 100644 --- a/Modules/FindQuickTime.cmake +++ b/Modules/FindQuickTime.cmake @@ -41,9 +41,7 @@ ELSE(APPLE) ) ENDIF(APPLE) -SET(QUICKTIME_FOUND "NO") -IF(QUICKTIME_LIBRARY AND QUICKTIME_INCLUDE_DIR) - SET(QUICKTIME_FOUND "YES") -ENDIF(QUICKTIME_LIBRARY AND QUICKTIME_INCLUDE_DIR) - - +# handle the QUIETLY and REQUIRED arguments and set QUICKTIME_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(QuickTime DEFAULT_MSG QUICKTIME_LIBRARY QUICKTIME_INCLUDE_DIR) diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 05c09b4..6edcb72 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -5,7 +5,7 @@ # SWIG_EXECUTABLE - the path to the swig executable # SWIG_VERSION - the version number of the swig executable # -# All informations are collected from the SWIG_EXECUTABLE so the +# All information is collected from the SWIG_EXECUTABLE so the # version to be found can be changed from the command line by # means of setting SWIG_EXECUTABLE # diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index c33df1d..687aa19 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -38,16 +38,11 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -SET(Subversion_FOUND FALSE) -SET(Subversion_SVN_FOUND FALSE) - FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn DOC "subversion command line client") MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) IF(Subversion_SVN_EXECUTABLE) - SET(Subversion_SVN_FOUND TRUE) - SET(Subversion_FOUND TRUE) MACRO(Subversion_WC_INFO dir prefix) # the subversion commands should be executed with the C locale, otherwise @@ -109,14 +104,9 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(Subversion_SVN_EXECUTABLE) -IF(NOT Subversion_FOUND) - IF(NOT Subversion_FIND_QUIETLY) - MESSAGE(STATUS "Subversion was not found.") - ELSE(NOT Subversion_FIND_QUIETLY) - IF(Subversion_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Subversion was not found.") - ENDIF(Subversion_FIND_REQUIRED) - ENDIF(NOT Subversion_FIND_QUIETLY) -ENDIF(NOT Subversion_FOUND) - -# FindSubversion.cmake ends here. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion DEFAULT_MSG Subversion_SVN_EXECUTABLE) + +# for compatibility +SET(Subversion_FOUND ${SUBVERSION_FOUND}) +SET(Subversion_SVN_FOUND ${SUBVERSION_FOUND}) 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/FindThreads.cmake b/Modules/FindThreads.cmake index 459129b..2a74304 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -5,6 +5,8 @@ # CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? # CMAKE_USE_PTHREADS_INIT - are we using pthreads # CMAKE_HP_PTHREADS_INIT - are we using hp pthreads +# For systems with multiple thread libraries, caller can set +# CMAKE_THREAD_PREFER_PTHREADS #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -24,11 +26,11 @@ INCLUDE (CheckLibraryExists) SET(Threads_FOUND FALSE) # Do we have sproc? -IF(CMAKE_SYSTEM MATCHES IRIX) +IF(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD) CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H) ENDIF() -IF(CMAKE_HAVE_SPROC_H) +IF(CMAKE_HAVE_SPROC_H AND NOT CMAKE_THREAD_PREFER_PTHREAD) # We have sproc SET(CMAKE_USE_SPROC_INIT 1) ELSE() diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index c084df0..f056413 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -22,6 +22,7 @@ # X11_xf86vmode_INCLUDE_PATH, X11_xf86vmode_FOUND # X11_Xfixes_INCLUDE_PATH, X11_Xfixes_LIB, X11_Xfixes_FOUND # X11_Xft_INCLUDE_PATH, X11_Xft_LIB, X11_Xft_FOUND +# X11_Xi_INCLUDE_PATH, X11_Xi_LIB, X11_Xi_FOUND # X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND # X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND # X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND @@ -91,6 +92,7 @@ IF (UNIX) FIND_PATH(X11_xf86vmode_INCLUDE_PATH X11/extensions/xf86vmode.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xfixes_INCLUDE_PATH X11/extensions/Xfixes.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xft_INCLUDE_PATH X11/Xft/Xft.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_Xi_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xinerama_INCLUDE_PATH X11/extensions/Xinerama.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xinput_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH}) @@ -120,6 +122,7 @@ IF (UNIX) FIND_LIBRARY(X11_Xext_LIB Xext ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xfixes_LIB Xfixes ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH}) + FIND_LIBRARY(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinput_LIB Xi ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) @@ -219,6 +222,11 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XTest_INCLUDE_PATH}) ENDIF (X11_XTest_INCLUDE_PATH AND X11_XTest_LIB) + IF (X11_Xi_INCLUDE_PATH AND X11_Xi_LIB) + SET(X11_Xi_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xi_INCLUDE_PATH}) + ENDIF (X11_Xi_INCLUDE_PATH AND X11_Xi_LIB) + IF (X11_Xinerama_INCLUDE_PATH AND X11_Xinerama_LIB) SET(X11_Xinerama_FOUND TRUE) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinerama_INCLUDE_PATH}) @@ -396,6 +404,8 @@ IF (UNIX) X11_Xxf86misc_LIB X11_xf86misc_INCLUDE_PATH X11_xf86vmode_INCLUDE_PATH + X11_Xi_LIB + X11_Xi_INCLUDE_PATH X11_Xinerama_LIB X11_Xinerama_INCLUDE_PATH X11_XTest_LIB diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 8066343..3891be4 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -1,9 +1,22 @@ # - Find zlib -# Find the native ZLIB includes and library +# Find the native ZLIB includes and library. +# Once done this will define # -# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. -# ZLIB_LIBRARIES - List of libraries when using zlib. -# ZLIB_FOUND - True if zlib found. +# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. +# ZLIB_LIBRARIES - List of libraries when using zlib. +# ZLIB_FOUND - True if zlib found. +# +# ZLIB_VERSION_STRING - The version of zlib found (x.y.z) +# ZLIB_VERSION_MAJOR - The major version of zlib +# ZLIB_VERSION_MINOR - The minor version of zlib +# ZLIB_VERSION_PATCH - The patch version of zlib +# ZLIB_VERSION_TWEAK - The tweak version of zlib +# +# The following variable are provided for backward compatibility +# +# ZLIB_MAJOR_VERSION - The major version of zlib +# ZLIB_MINOR_VERSION - The minor version of zlib +# ZLIB_PATCH_VERSION - The patch version of zlib #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -18,23 +31,42 @@ # (To distributed this file outside of CMake, substitute the full # License text for the above reference.) -IF (ZLIB_INCLUDE_DIR) - # Already in cache, be silent - SET(ZLIB_FIND_QUIETLY TRUE) -ENDIF (ZLIB_INCLUDE_DIR) - -FIND_PATH(ZLIB_INCLUDE_DIR zlib.h) +FIND_PATH(ZLIB_INCLUDE_DIR zlib.h + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include" +) SET(ZLIB_NAMES z zlib zdll) -FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ) -MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR ) +FIND_LIBRARY(ZLIB_LIBRARY + NAMES + ${ZLIB_NAMES} + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib" +) +MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -# Per-recommendation -SET(ZLIB_INCLUDE_DIRS "${ZLIB_INCLUDE_DIR}") -SET(ZLIB_LIBRARIES "${ZLIB_LIBRARY}") +IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") + FILE(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$") + + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}") + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}") + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}") + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_TWEAK "${ZLIB_H}") + + SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}.${ZLIB_VERSION_TWEAK}") + + SET(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") + SET(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") + SET(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") +ENDIF() # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY + VERSION_VAR ZLIB_VERSION_STRING) + +IF(ZLIB_FOUND) + SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) + SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) +ENDIF() diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 05c6625..4533c01 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -57,14 +57,14 @@ # FIND_PACKAGE(wxWidgets COMPONENTS base core gl net) # IF(wxWidgets_FOUND) # INCLUDE(${wxWidgets_USE_FILE}) -# # and for each of your dependant executable/library targets: +# # and for each of your dependent executable/library targets: # TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES}) # ENDIF(wxWidgets_FOUND) # # If wxWidgets is required (i.e., not an optional part): # FIND_PACKAGE(wxWidgets REQUIRED base core gl net) # INCLUDE(${wxWidgets_USE_FILE}) -# # and for each of your dependant executable/library targets: +# # and for each of your dependent executable/library targets: # TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES}) #============================================================================= @@ -723,10 +723,13 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32") DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") - # parse definitions from cxxflags; drop -D* from CXXFLAGS and the -D prefix + # parse definitions from cxxflags; + # drop -D* from CXXFLAGS and the -D prefix STRING(REGEX MATCHALL "-D[^;]+" wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}") - STRING(REGEX REPLACE "-D[^;]+;" "" + STRING(REGEX REPLACE "-D[^;]+(;|$)" "" + wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") + STRING(REGEX REPLACE ";$" "" wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") STRING(REPLACE "-D" "" wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}") diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 123b433..f984c58 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -16,6 +16,7 @@ # gp_resolve_item # (projects can override with gp_resolve_item_override) # gp_resolved_file_type +# (projects can override with gp_resolved_file_type_override) # gp_file_type # get_prerequisites # list_prerequisites @@ -345,6 +346,9 @@ endfunction(gp_resolve_item) # embedded # other # +# Override on a per-project basis by providing a project-specific +# gp_resolved_file_type_override function. +# function(gp_resolved_file_type original_file file exepath dirs type_var) #message(STATUS "**") @@ -428,6 +432,13 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) endif() endif() + # Provide a hook so that projects can override the decision on whether a + # library belongs to the system or not by whatever logic they choose: + # + if(COMMAND gp_resolved_file_type_override) + gp_resolved_file_type_override("${resolved_file}" type) + endif() + set(${type_var} "${type}" PARENT_SCOPE) #message(STATUS "**") @@ -515,6 +526,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "ldd") set(gp_cmd_args "") set(gp_regex "^[\t ]*[^\t ]+ => ([^\t ]+).*${eol_char}$") + set(gp_regex_error "not found${eol_char}$") + set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$") set(gp_regex_cmp_count 1) set(gp_tool_known 1) endif("${gp_tool}" STREQUAL "ldd") @@ -522,6 +535,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "otool") set(gp_cmd_args "-L") set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$") + set(gp_regex_error "") + set(gp_regex_fallback "") set(gp_regex_cmp_count 3) set(gp_tool_known 1) endif("${gp_tool}" STREQUAL "otool") @@ -529,6 +544,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "dumpbin") set(gp_cmd_args "/dependents") set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$") + set(gp_regex_error "") + set(gp_regex_fallback "") set(gp_regex_cmp_count 1) set(gp_tool_known 1) set(ENV{VS_UNICODE_OUTPUT} "") # Block extra output from inside VS IDE. @@ -618,8 +635,13 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # foreach(candidate ${candidates}) if("${candidate}" MATCHES "${gp_regex}") + # Extract information from each candidate: - string(REGEX REPLACE "${gp_regex}" "\\1" raw_item "${candidate}") + if(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") + string(REGEX REPLACE "${gp_regex_fallback}" "\\1" raw_item "${candidate}") + else(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") + string(REGEX REPLACE "${gp_regex}" "\\1" raw_item "${candidate}") + endif(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") if(gp_regex_cmp_count GREATER 1) string(REGEX REPLACE "${gp_regex}" "\\2" raw_compat_version "${candidate}") 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/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 6a80f62..24bb92a 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -45,6 +45,7 @@ macro(__cygwin_compiler_gnu lang) SET(CMAKE_${type}_LINK_DYNAMIC_${lang}_FLAGS "-Wl,-Bdynamic") ENDFOREACH(type) + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-all-symbols") # TODO: Is -Wl,--enable-auto-import now always default? set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,--enable-auto-import") set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS}") 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) diff --git a/Modules/Platform/Generic.cmake b/Modules/Platform/Generic.cmake index 00508b2..a4e2ec6 100644 --- a/Modules/Platform/Generic.cmake +++ b/Modules/Platform/Generic.cmake @@ -9,3 +9,9 @@ # (embedded) targets without operating system usually don't support shared libraries SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) + +# To help the find_xxx() commands, set at least the following so CMAKE_FIND_ROOT_PATH +# works at least for some simple cases: +SET(CMAKE_SYSTEM_INCLUDE_PATH /include ) +SET(CMAKE_SYSTEM_LIBRARY_PATH /lib ) +SET(CMAKE_SYSTEM_PROGRAM_PATH /bin ) diff --git a/Modules/Platform/Linux-Clang-C.cmake b/Modules/Platform/Linux-Clang-C.cmake new file mode 100644 index 0000000..dbf8956 --- /dev/null +++ b/Modules/Platform/Linux-Clang-C.cmake @@ -0,0 +1 @@ +INCLUDE(Platform/Linux-GNU-C) diff --git a/Modules/Platform/Linux-Clang-CXX.cmake b/Modules/Platform/Linux-Clang-CXX.cmake new file mode 100644 index 0000000..8fe251c --- /dev/null +++ b/Modules/Platform/Linux-Clang-CXX.cmake @@ -0,0 +1 @@ +INCLUDE(Platform/Linux-GNU-CXX) diff --git a/Modules/Platform/Linux-SunPro-CXX.cmake b/Modules/Platform/Linux-SunPro-CXX.cmake index 5490473..8ee9658 100644 --- a/Modules/Platform/Linux-SunPro-CXX.cmake +++ b/Modules/Platform/Linux-SunPro-CXX.cmake @@ -1,2 +1,9 @@ -SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG "-rpath-link ") +# Sun C++ 5.9 does not support -Wl, but Sun C++ 5.11 does not work without it. +# Query the compiler flags to detect whether to use -Wl. +execute_process(COMMAND ${CMAKE_CXX_COMPILER} -flags OUTPUT_VARIABLE _cxx_flags ERROR_VARIABLE _cxx_error) +if("${_cxx_flags}" MATCHES "\n-W[^\n]*component") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG "-Wl,-rpath-link,") +else() + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_CXX_FLAG "-rpath-link ") +endif() SET(CMAKE_EXE_EXPORTS_CXX_FLAG "--export-dynamic") diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 652bed4..076410a 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -25,6 +25,7 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-V.*") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*") +SET(CMAKE_MAKE_INCLUDE_FROM_ROOT 1) # include $(CMAKE_BINARY_DIR)/... IF(CMAKE_COMPILER_IS_GNUCXX) # include the gcc flags diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake index e7df46d..b4ed66f 100644 --- a/Modules/Platform/OpenBSD.cmake +++ b/Modules/Platform/OpenBSD.cmake @@ -1,2 +1,18 @@ INCLUDE(Platform/NetBSD) + +# On OpenBSD, the compile time linker does not share it's configuration with +# the runtime linker. This will extract the library search paths from the +# system's ld.so.hints file which will allow CMake to set the appropriate +# -rpath-link flags +IF(NOT CMAKE_PLATFORM_RUNTIME_PATH) + EXECUTE_PROCESS(COMMAND /sbin/ldconfig -r + OUTPUT_VARIABLE LDCONFIG_HINTS + ERROR_QUIET) + STRING(REGEX REPLACE ".*search\\ directories:\\ ([^\n]*).*" "\\1" + LDCONFIG_HINTS "${LDCONFIG_HINTS}") + STRING(REGEX REPLACE ":" ";" + CMAKE_PLATFORM_RUNTIME_PATH + "${LDCONFIG_HINTS}") +ENDIF() + SET_PROPERTY(GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1) diff --git a/Modules/Platform/Windows-G95-Fortran.cmake b/Modules/Platform/Windows-G95-Fortran.cmake new file mode 100644 index 0000000..af08008 --- /dev/null +++ b/Modules/Platform/Windows-G95-Fortran.cmake @@ -0,0 +1 @@ +include(Platform/Windows-GNU-Fortran) diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index e369ac1..7463c62 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -23,19 +23,15 @@ ENDIF(NOT CMAKE_NO_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Visual Studio") IF(CMAKE_GENERATOR MATCHES "Visual Studio 8") SET(CMAKE_COMPILER_2005 1) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8") -IF(CMAKE_GENERATOR MATCHES "Visual Studio 9") - SET(CMAKE_COMPILER_2005 1) -ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 9") - # make sure to enable languages after setting configuration types ENABLE_LANGUAGE(RC) SET(CMAKE_COMPILE_RESOURCE "rc <FLAGS> /fo<OBJECT> <SOURCE>") -# for nmake we need to compute some information about the compiler +# for nmake we need to compute some information about the compiler # that is being used. # the compiler may be free command line, 6, 7, or 71, and -# each have properties that must be determined. +# each have properties that must be determined. # to avoid running these tests with each cmake run, the # test results are saved in CMakeCPlatform.cmake, a file # that is automatically copied into try_compile directories @@ -87,25 +83,12 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") SET(MSVC80 1) SET(CMAKE_COMPILER_2005 1) ENDIF("${compilerVersion}" EQUAL 1400) - IF("${compilerVersion}" GREATER 1400) - SET(MSVC80 1) - SET(CMAKE_COMPILER_2005 1) - ENDIF("${compilerVersion}" GREATER 1400) - IF("${compilerVersion}" GREATER 1400) - SET(MSVC80 1) - SET(CMAKE_COMPILER_2005 1) - ENDIF("${compilerVersion}" GREATER 1400) IF("${compilerVersion}" EQUAL 1500) SET(MSVC90 1) - SET(MSVC80 0) ENDIF("${compilerVersion}" EQUAL 1500) - IF("${compilerVersion}" GREATER 1500) - SET(MSVC90 1) - SET(MSVC80 0) - ENDIF("${compilerVersion}" GREATER 1500) IF("${compilerVersion}" EQUAL 1600) SET(MSVC10 1) - ENDIF() + ENDIF("${compilerVersion}" EQUAL 1600) SET(MSVC_VERSION "${compilerVersion}") ELSE(NOT CMAKE_COMPILER_RETURN) MESSAGE(STATUS "Check for CL compiler version - failed") @@ -224,7 +207,7 @@ ENDIF(NOT _MACHINE_ARCH_FLAG) SET (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:${_MACHINE_ARCH_FLAG}") -# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtyp +# add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtype # on versions that support it SET( MSVC_INCREMENTAL_YES_FLAG "") IF(NOT MSVC_INCREMENTAL_DEFAULT) @@ -256,7 +239,6 @@ SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELW SET (CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT}) SET (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT}) - # save computed information for this platform IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCPlatform.cmake") CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in @@ -267,4 +249,3 @@ IF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") CONFIGURE_FILE(${CMAKE_ROOT}/Modules/Platform/Windows-cl.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXPlatform.cmake IMMEDIATE) ENDIF(NOT EXISTS "${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake") - diff --git a/Modules/Platform/Windows-cl.cmake.in b/Modules/Platform/Windows-cl.cmake.in index 1a889f2..82a0e59 100644 --- a/Modules/Platform/Windows-cl.cmake.in +++ b/Modules/Platform/Windows-cl.cmake.in @@ -8,6 +8,7 @@ SET(MSVC70 @MSVC70@) SET(MSVC71 @MSVC71@) SET(MSVC80 @MSVC80@) SET(MSVC90 @MSVC90@) +SET(MSVC10 @MSVC10@) SET(MSVC_IDE @MSVC_IDE@) SET(MSVC_VERSION @MSVC_VERSION@) SET(WIN32 1) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index b260489..7fc345f 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -31,7 +31,7 @@ SET(CMAKE_C_CREATE_IMPORT_LIBRARY SET(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) SET(CMAKE_C_LINK_EXECUTABLE - "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) @@ -52,7 +52,7 @@ SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_MODULE - "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") + "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_MODULE} ${CMAKE_CXX_CREATE_IMPORT_LIBRARY}) @@ -64,7 +64,7 @@ SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) # create a C++ static library -SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '<TARGET_UNQUOTED>' <OBJECTS> ") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ") # create a C static library SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake index 1c5293d..2e03716 100644 --- a/Modules/Qt4ConfigDependentSettings.cmake +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -34,12 +34,12 @@ SET(QT_QTDBUS_LIB_DEPENDENCIES "") SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY}) -IF(WIN32) +IF(Q_WS_WIN) # On Windows, qconfig.pri has "static" for static library builds IF(QT_CONFIG MATCHES "static") SET(QT_IS_STATIC 1) ENDIF(QT_CONFIG MATCHES "static") -ELSE(WIN32) +ELSE(Q_WS_WIN) # On other platforms, check file extension to know if its static IF(QT_QTCORE_LIBRARY_RELEASE) GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT) @@ -53,133 +53,91 @@ ELSE(WIN32) SET(QT_IS_STATIC 1) ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) ENDIF(QT_QTCORE_LIBRARY_DEBUG) -ENDIF(WIN32) +ENDIF(Q_WS_WIN) # build using shared Qt needs -DQT_DLL on Windows -IF(WIN32 AND NOT QT_IS_STATIC) +IF(Q_WS_WIN AND NOT QT_IS_STATIC) SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL) -ENDIF(WIN32 AND NOT QT_IS_STATIC) +ENDIF(Q_WS_WIN AND NOT QT_IS_STATIC) +IF(NOT QT_IS_STATIC) + RETURN() +ENDIF(NOT QT_IS_STATIC) # QtOpenGL dependencies -QT_QUERY_QMAKE(QMAKE_LIBS_OPENGL "QMAKE_LIBS_OPENGL") -IF(Q_WS_MAC) -# On the Mac OpenGL is probably frameworks and QMAKE_LIBS_OPENGL can be -# e.g. "-framework OpenGL -framework AGL". The separate_arguments() call in -# the other branch makes "-framework;-OpenGL;-framework;-lAGL" appear in the -# linker command. So we need to protect the "-framework foo" as -# non-separatable strings. We do this by replacing the space after -# "-framework" with an underscore, then calling separate_arguments(), and -# then we replace the underscores again with spaces. So we get proper linker -# commands. Alex - STRING(REGEX REPLACE "-framework +" "-framework_" QMAKE_LIBS_OPENGL "${QMAKE_LIBS_OPENGL}") - SEPARATE_ARGUMENTS(QMAKE_LIBS_OPENGL) - STRING(REGEX REPLACE "-framework_" "-framework " QMAKE_LIBS_OPENGL "${QMAKE_LIBS_OPENGL}") -ELSE(Q_WS_MAC) - SEPARATE_ARGUMENTS(QMAKE_LIBS_OPENGL) -ENDIF(Q_WS_MAC) -SET (QT_QTOPENGL_LIB_DEPENDENCIES ${QT_QTOPENGL_LIB_DEPENDENCIES} ${QMAKE_LIBS_OPENGL}) +find_package(OpenGL) +SET (QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY}) ## system png IF(QT_QCONFIG MATCHES "system-png") - FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) - MARK_AS_ADVANCED(QT_PNG_LIBRARY) - IF(QT_PNG_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) - ENDIF(QT_PNG_LIBRARY) + find_package(PNG) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${PNG_LIBRARY}) ENDIF(QT_QCONFIG MATCHES "system-png") # for X11, get X11 library directory IF(Q_WS_X11) - QT_QUERY_QMAKE(QMAKE_LIBDIR_X11 "QMAKE_LIBDIR_X11") + FIND_PACKAGE(X11) ENDIF(Q_WS_X11) ## X11 SM IF(QT_QCONFIG MATCHES "x11sm") - # ask qmake where the x11 libs are - FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) - FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) - MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) - IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) - ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) + IF(X11_SM_LIB AND X11_ICE_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_SM_LIB} ${X11_ICE_LIB}) + ENDIF(X11_SM_LIB AND X11_ICE_LIB) ENDIF(QT_QCONFIG MATCHES "x11sm") ## Xi IF(QT_QCONFIG MATCHES "tablet") - FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XI_LIBRARY) - IF(QT_XI_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) - ENDIF(QT_XI_LIBRARY) + IF(X11_Xi_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xi_LIB}) + ENDIF(X11_Xi_LIB) ENDIF(QT_QCONFIG MATCHES "tablet") ## Xrender IF(QT_QCONFIG MATCHES "xrender") - FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) - IF(QT_XRENDER_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) - ENDIF(QT_XRENDER_LIBRARY) + IF(X11_Xrender_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrender_LIB}) + ENDIF(X11_Xrender_LIB) ENDIF(QT_QCONFIG MATCHES "xrender") ## Xrandr IF(QT_QCONFIG MATCHES "xrandr") - FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) - IF(QT_XRANDR_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) - ENDIF(QT_XRANDR_LIBRARY) + IF(X11_Xrandr_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xrandr_LIB}) + ENDIF(X11_Xrandr_LIB) ENDIF(QT_QCONFIG MATCHES "xrandr") ## Xcursor IF(QT_QCONFIG MATCHES "xcursor") - FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) - IF(QT_XCURSOR_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) - ENDIF(QT_XCURSOR_LIBRARY) + IF(X11_Xcursor_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xcursor_LIB}) + ENDIF(X11_Xcursor_LIB) ENDIF(QT_QCONFIG MATCHES "xcursor") ## Xinerama IF(QT_QCONFIG MATCHES "xinerama") - FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) - IF(QT_XINERAMA_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) - ENDIF(QT_XINERAMA_LIBRARY) + IF(X11_Xinerama_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xinerama_LIB}) + ENDIF(X11_Xinerama_LIB) ENDIF(QT_QCONFIG MATCHES "xinerama") ## Xfixes IF(QT_QCONFIG MATCHES "xfixes") - FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(QT_XFIXES_LIBRARY) - IF(QT_XFIXES_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY}) - ENDIF(QT_XFIXES_LIBRARY) + IF(X11_Xfixes_LIB) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xfixes_LIB}) + ENDIF(X11_Xfixes_LIB) ENDIF(QT_QCONFIG MATCHES "xfixes") -## system-freetype -IF(QT_QCONFIG MATCHES "system-freetype") - FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) - MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) - IF(QT_FREETYPE_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) - ENDIF(QT_FREETYPE_LIBRARY) -ENDIF(QT_QCONFIG MATCHES "system-freetype") - - ## fontconfig IF(QT_QCONFIG MATCHES "fontconfig") FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) @@ -190,13 +148,19 @@ IF(QT_QCONFIG MATCHES "fontconfig") ENDIF(QT_QCONFIG MATCHES "fontconfig") +## system-freetype +IF(QT_QCONFIG MATCHES "system-freetype") + find_package(Freetype) + if(FREETYPE_LIBRARIES) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${FREETYPE_LIBRARIES}) + endif(FREETYPE_LIBRARIES) +ENDIF(QT_QCONFIG MATCHES "system-freetype") + + ## system-zlib IF(QT_QCONFIG MATCHES "system-zlib") - FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) - MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) - IF(QT_ZLIB_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) - ENDIF(QT_ZLIB_LIBRARY) + find_package(ZLIB) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${ZLIB_LIBRARIES}) ENDIF(QT_QCONFIG MATCHES "system-zlib") @@ -221,29 +185,11 @@ ENDIF(NOT Q_WS_WIN) ## dbus IF(QT_QCONFIG MATCHES "dbus") - # if the dbus library isn't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - IF(NOT QT_DBUS_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1 - OUTPUT_VARIABLE _dbus_query_output - RESULT_VARIABLE _dbus_result - ERROR_VARIABLE _dbus_query_output ) - - IF(_dbus_result MATCHES 0) - STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}") - SEPARATE_ARGUMENTS(_dbus_query_output) - ELSE(_dbus_result MATCHES 0) - SET(_dbus_query_output) - ENDIF(_dbus_result MATCHES 0) - - FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} ) - - IF(QT_DBUS_LIBRARY) - SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) - ENDIF(QT_DBUS_LIBRARY) - - MARK_AS_ADVANCED(QT_DBUS_LIBRARY) - ENDIF(NOT QT_DBUS_LIBRARY) + FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 ) + IF(QT_DBUS_LIBRARY) + SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) + ENDIF(QT_DBUS_LIBRARY) + MARK_AS_ADVANCED(QT_DBUS_LIBRARY) ENDIF(QT_QCONFIG MATCHES "dbus") @@ -251,29 +197,11 @@ ENDIF(QT_QCONFIG MATCHES "dbus") ## glib IF(QT_QCONFIG MATCHES "glib") - # if the glib libraries aren't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - # Qt 4.2.0+ uses glib-2.0 - IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} ) - FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GLIB_LIBRARY) - MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) - ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) + FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 ) + FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 ) + MARK_AS_ADVANCED(QT_GLIB_LIBRARY) + MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} @@ -283,23 +211,8 @@ IF(QT_QCONFIG MATCHES "glib") # Qt 4.5+ also links to gobject-2.0 IF(QT_VERSION_MINOR GREATER 4) - IF(NOT QT_GOBJECT_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) - ENDIF(NOT QT_GOBJECT_LIBRARY) + FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) + MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) IF(QT_GOBJECT_LIBRARY) SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} @@ -327,24 +240,16 @@ ENDIF(QT_QCONFIG MATCHES "clock-monotonic") IF(Q_WS_X11) - # X11 libraries Qt absolutely depends on - QT_QUERY_QMAKE(QT_LIBS_X11 "QMAKE_LIBS_X11") - SEPARATE_ARGUMENTS(QT_LIBS_X11) - FOREACH(QT_X11_LIB ${QT_LIBS_X11}) - STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") - SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") - FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) - MARK_AS_ADVANCED(${QT_TMP_STR}) - IF(${QT_TMP_STR}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) - ENDIF(${QT_TMP_STR}) - ENDFOREACH(QT_X11_LIB) - - QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_LIBS_THREAD}) - - QT_QUERY_QMAKE(QMAKE_LIBS_DYNLOAD "QMAKE_LIBS_DYNLOAD") - SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QMAKE_LIBS_DYNLOAD}) + # X11 libraries Qt always depends on + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${X11_Xext_LIB} ${X11_X11_LIB}) + + set(CMAKE_THREAD_PREFER_PTHREADS 1) + find_package(Threads) + if(CMAKE_USE_PTHREADS_INIT) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_THREAD_LIBS_INIT}) + endif(CMAKE_USE_PTHREADS_INIT) + + SET (QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${CMAKE_DL_LIBS}) ENDIF(Q_WS_X11) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index baa0571..ea0ab95 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -27,9 +27,9 @@ INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") IF (QT_USE_QTMAIN) - IF (WIN32) + IF (Q_WS_WIN) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) - ENDIF (WIN32) + ENDIF (Q_WS_WIN) ENDIF (QT_USE_QTMAIN) IF(QT_DONT_USE_QTGUI) @@ -65,11 +65,12 @@ SET(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE) SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE) +SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE) # Qt modules (in order of dependence) FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN - QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP - QTWEBKIT PHONON QTSCRIPTTOOLS QTGUI QTTEST QTDBUS QTXML QTSQL + QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP + QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL QTXMLPATTERNS QTNETWORK QTCORE) IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) diff --git a/Modules/readme.txt b/Modules/readme.txt index a292e20..dd52000 100644 --- a/Modules/readme.txt +++ b/Modules/readme.txt @@ -8,16 +8,16 @@ We would like all FindXXX.cmake files to produce consistent variable names. Please use the following consistent variable names for general use. XXX_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. This should not be a cache entry. -XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. -XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include <jpeg.h> -XXX_EXECUTABLE Where to find the XXX tool. -XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. +XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. +XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include <jpeg.h> +XXX_EXECUTABLE Where to find the XXX tool. +XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry. -XXX_ROOT_DIR Where to find the base directory of XXX. -XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true. -XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command. -XXX_YY_FOUND If False, optional YY part of XXX sytem is not available. -XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX. +XXX_ROOT_DIR Where to find the base directory of XXX. +XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true. +XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command. +XXX_YY_FOUND If False, optional YY part of XXX sytem is not available. +XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX. XXX_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to shared libraries. The list should be used by user code to create the PATH on windows or LD_LIBRARY_PATH on unix. This should not be a cache entry. @@ -30,9 +30,9 @@ You do not have to provide all of the above variables. You should provide XXX_FO The following names should not usually be used in CMakeLists.txt files, but they may be usefully modified in users' CMake Caches to control stuff. -XXX_LIBRARY Name of XXX Library. A User may set this and XXX_INCLUDE_DIR to ignore to force non-use of XXX. -XXX_YY_LIBRARY Name of YY library that is part of the XXX system. It may or may not be required to use XXX. -XXX_INCLUDE_DIR Where to find xxx.h, etc. (XXX_INCLUDE_PATH was considered bad because a path includes an actual filename.) +XXX_LIBRARY Name of XXX Library. A User may set this and XXX_INCLUDE_DIR to ignore to force non-use of XXX. +XXX_YY_LIBRARY Name of YY library that is part of the XXX system. It may or may not be required to use XXX. +XXX_INCLUDE_DIR Where to find xxx.h, etc. (XXX_INCLUDE_PATH was considered bad because a path includes an actual filename.) XXX_YY_INCLUDE_DIR Where to find xxx_yy.h, etc. For tidiness's sake, try to keep as many options as possible out of the cache, leaving at least one option which can be used to disable use of the module, or locate a not-found library (e.g. XXX_ROOT_DIR). For the same reason, mark most cache options as advanced. |