diff options
107 files changed, 1641 insertions, 478 deletions
diff --git a/Docs/cmake-mode.el b/Docs/cmake-mode.el index 2f51f83..4418bfa 100644 --- a/Docs/cmake-mode.el +++ b/Docs/cmake-mode.el @@ -99,6 +99,7 @@ set the path with these commands: (setq region (buffer-substring-no-properties (point) point-start)) (while (and (not (bobp)) (or (looking-at cmake-regex-blank) + (cmake-line-starts-inside-string) (not (and (string-match cmake-regex-indented region) (= (length region) (match-end 0)))))) (forward-line -1) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 04a5cec..b14cf34 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -1,6 +1,7 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") SET(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@") SET(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@") +SET(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@") SET(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") @SET_MSVC_C_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 4cc690a..b0f5eb6 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -2,27 +2,62 @@ # error "A C++ compiler has been selected for C." #endif +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + #if defined(__18CXX) # define ID_VOID_MAIN #endif #if defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" + /* __INTEL_COMPILER = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif #elif defined(__clang__) # define COMPILER_ID "Clang" +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) # define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) #elif defined(__SUNPRO_C) # define COMPILER_ID "SunPro" +# if __SUNPRO_C >= 0x5100 + /* __SUNPRO_C = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# else + /* __SUNPRO_C = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) +# endif #elif defined(__HP_cc) # define COMPILER_ID "HP" + /* __HP_cc = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) #elif defined(__DECC) # define COMPILER_ID "Compaq" @@ -30,14 +65,25 @@ #elif defined(__IBMC__) # if defined(__COMPILER_VER__) # define COMPILER_ID "zOS" -# elif __IBMC__ >= 800 -# define COMPILER_ID "XL" # else -# define COMPILER_ID "VisualAge" +# if __IBMC__ >= 800 +# define COMPILER_ID "XL" +# else +# define COMPILER_ID "VisualAge" +# endif + /* __IBMC__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) # endif #elif defined(__PGI) # define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif #elif defined(__PATHSCALE__) # define COMPILER_ID "PathScale" @@ -56,9 +102,29 @@ #elif defined(__GNUC__) # define COMPILER_ID "GNU" +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif #elif defined(_MSC_VER) # define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) /* Analog Devices C++ compiler for Blackfin, TigerSHARC and @@ -78,6 +144,17 @@ #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) # define COMPILER_ID "MIPSpro" +# if defined(_SGI_COMPILER_VERSION) + /* _SGI_COMPILER_VERSION = VRP */ +# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) +# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) +# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) +# else + /* _COMPILER_VERSION = VRP */ +# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) +# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) +# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) +# endif /* This compiler is either not known or is too old to define an identification macro. Try to identify the platform and guess that @@ -112,6 +189,9 @@ int main(int argc, char* argv[]) require += info_compiler[argc]; require += info_platform[argc]; require += info_arch[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif (void)argv; return require; } diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index ea06526..bc3bc2e 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -1,6 +1,7 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") SET(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") SET(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") +SET(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") SET(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") @SET_MSVC_CXX_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 4c8f497..927f7f4 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -5,26 +5,61 @@ # error "A C compiler has been selected for C++." #endif +/* Version number components: V=Version, R=Revision, P=Patch + Version date components: YYYY=Year, MM=Month, DD=Day */ + #if defined(__COMO__) # define COMPILER_ID "Comeau" #elif defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" + /* __INTEL_COMPILER = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) +# define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# if defined(__INTEL_COMPILER_BUILD_DATE) + /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ +# define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) +# endif #elif defined(__clang__) # define COMPILER_ID "Clang" +# define COMPILER_VERSION_MAJOR DEC(__clang_major__) +# define COMPILER_VERSION_MINOR DEC(__clang_minor__) +# define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) #elif defined(__BORLANDC__) # define COMPILER_ID "Borland" + /* __BORLANDC__ = 0xVRR */ +# define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) +# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) #elif defined(__WATCOMC__) # define COMPILER_ID "Watcom" + /* __WATCOMC__ = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) +# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100) #elif defined(__SUNPRO_CC) # define COMPILER_ID "SunPro" +# if __SUNPRO_CC >= 0x5100 + /* __SUNPRO_CC = 0xVRRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# else + /* __SUNPRO_CC = 0xVRP */ +# define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) +# define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) +# define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) +# endif #elif defined(__HP_aCC) # define COMPILER_ID "HP" + /* __HP_aCC = VVRRPP */ +# define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) +# define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) +# define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) #elif defined(__DECCXX) # define COMPILER_ID "Compaq" @@ -32,14 +67,25 @@ #elif defined(__IBMCPP__) # if defined(__COMPILER_VER__) # define COMPILER_ID "zOS" -# elif __IBMCPP__ >= 800 -# define COMPILER_ID "XL" # else -# define COMPILER_ID "VisualAge" +# if __IBMCPP__ >= 800 +# define COMPILER_ID "XL" +# else +# define COMPILER_ID "VisualAge" +# endif + /* __IBMCPP__ = VRP */ +# define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) +# define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) +# define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) # endif #elif defined(__PGI) # define COMPILER_ID "PGI" +# define COMPILER_VERSION_MAJOR DEC(__PGIC__) +# define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) +# if defined(__PGIC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) +# endif #elif defined(__PATHSCALE__) # define COMPILER_ID "PathScale" @@ -55,9 +101,29 @@ #elif defined(__GNUC__) # define COMPILER_ID "GNU" +# define COMPILER_VERSION_MAJOR DEC(__GNUC__) +# define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) +# if defined(__GNUC_PATCHLEVEL__) +# define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) +# endif #elif defined(_MSC_VER) # define COMPILER_ID "MSVC" + /* _MSC_VER = VVRR */ +# define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) +# define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) +# if defined(_MSC_FULL_VER) +# if _MSC_VER >= 1400 + /* _MSC_FULL_VER = VVRRPPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) +# else + /* _MSC_FULL_VER = VVRRPPPP */ +# define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) +# endif +# endif +# if defined(_MSC_BUILD) +# define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) +# endif #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) /* Analog Devices C++ compiler for Blackfin, TigerSHARC and @@ -66,6 +132,17 @@ #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) # define COMPILER_ID "MIPSpro" +# if defined(_SGI_COMPILER_VERSION) + /* _SGI_COMPILER_VERSION = VRP */ +# define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) +# define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) +# define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) +# else + /* _COMPILER_VERSION = VRP */ +# define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) +# define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) +# define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) +# endif /* This compiler is either not known or is too old to define an identification macro. Try to identify the platform and guess that @@ -96,6 +173,9 @@ int main(int argc, char* argv[]) int require = 0; require += info_compiler[argc]; require += info_platform[argc]; +#ifdef COMPILER_VERSION_MAJOR + require += info_version[argc]; +#endif (void)argv; return require; } diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index b160dee..686cc9b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -55,8 +55,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # Display the final identification result. IF(CMAKE_${lang}_COMPILER_ID) + IF(CMAKE_${lang}_COMPILER_VERSION) + SET(_version " ${CMAKE_${lang}_COMPILER_VERSION}") + ELSE() + SET(_version "") + ENDIF() MESSAGE(STATUS "The ${lang} compiler identification is " - "${CMAKE_${lang}_COMPILER_ID}") + "${CMAKE_${lang}_COMPILER_ID}${_version}") ELSE(CMAKE_${lang}_COMPILER_ID) MESSAGE(STATUS "The ${lang} compiler identification is unknown") ENDIF(CMAKE_${lang}_COMPILER_ID) @@ -65,6 +70,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) #----------------------------------------------------------------------------- @@ -177,9 +183,10 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) IF(NOT CMAKE_${lang}_COMPILER_ID) # Read the compiler identification string from the executable file. SET(COMPILER_ID) + SET(COMPILER_VERSION) SET(PLATFORM_ID) FILE(STRINGS ${file} - CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 3 REGEX "INFO:") + CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 4 REGEX "INFO:") SET(HAVE_COMPILER_TWICE 0) FOREACH(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) IF("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*") @@ -197,6 +204,11 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) STRING(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1" ARCHITECTURE_ID "${info}") ENDIF("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*") + IF("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") + STRING(REGEX REPLACE ".*INFO:compiler_version\\[([^]]*)\\].*" "\\1" COMPILER_VERSION "${info}") + STRING(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}") + STRING(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") + ENDIF("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*") ENDFOREACH(info) # Check if a valid compiler and platform were found. @@ -204,6 +216,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) SET(CMAKE_${lang}_COMPILER_ID "${COMPILER_ID}") SET(CMAKE_${lang}_PLATFORM_ID "${PLATFORM_ID}") SET(MSVC_${lang}_ARCHITECTURE_ID "${ARCHITECTURE_ID}") + SET(CMAKE_${lang}_COMPILER_VERSION "${COMPILER_VERSION}") ENDIF(COMPILER_ID AND NOT COMPILER_ID_TWICE) # Check the compiler identification string. @@ -251,6 +264,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) + SET(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index cb3f40a..b69bf63 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -105,6 +105,46 @@ # define ARCHITECTURE_ID "" #endif +/* Convert integer to decimal digit literals. */ +#define DEC(n) \ + ('0' + (((n) / 10000000)%10)), \ + ('0' + (((n) / 1000000)%10)), \ + ('0' + (((n) / 100000)%10)), \ + ('0' + (((n) / 10000)%10)), \ + ('0' + (((n) / 1000)%10)), \ + ('0' + (((n) / 100)%10)), \ + ('0' + (((n) / 10)%10)), \ + ('0' + ((n) % 10)) + +/* Convert integer to hex digit literals. */ +#define HEX(n) \ + ('0' + ((n)>>28 & 0xF)), \ + ('0' + ((n)>>24 & 0xF)), \ + ('0' + ((n)>>20 & 0xF)), \ + ('0' + ((n)>>16 & 0xF)), \ + ('0' + ((n)>>12 & 0xF)), \ + ('0' + ((n)>>8 & 0xF)), \ + ('0' + ((n)>>4 & 0xF)), \ + ('0' + ((n) & 0xF)) + +/* Construct a string literal encoding the version number components. */ +#ifdef COMPILER_VERSION_MAJOR +char const info_version[] = { + 'I', 'N', 'F', 'O', ':', + 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', + COMPILER_VERSION_MAJOR, +# ifdef COMPILER_VERSION_MINOR + '.', COMPILER_VERSION_MINOR, +# ifdef COMPILER_VERSION_PATCH + '.', COMPILER_VERSION_PATCH, +# ifdef COMPILER_VERSION_TWEAK + '.', COMPILER_VERSION_TWEAK, +# endif +# endif +# endif + ']','\0'}; +#endif + /* Construct the string literal in pieces to prevent the source from getting matched. Store it in a pointer rather than an array because some compilers will just produce instructions to fill the diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index bf476ad..e1e76ed 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -714,6 +714,25 @@ else() set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") endif(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) +# Prepend directories in ${CPACK_RPM_INSTALL_FILES} with %dir +# This is necessary to avoid duplicate files since rpmbuild do +# recursion on its own when encountering a pathname which is a directory +# which is not flagged as %dir +string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) +string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") +string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") +set(CPACK_RPM_INSTALL_FILES "") +foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) + if(IS_DIRECTORY "${WDIR}/${F}") + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}%dir \"${F}\"\n") + else() + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + endif() +endforeach(F) +set(CPACK_RPM_INSTALL_FILES_LIST "") + # 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}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 75b5ca1..642d962 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -44,7 +44,7 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c" @ONLY IMMEDIATE) - MESSAGE(STATUS "Looking for include files ${VARIABLE}") + MESSAGE(STATUS "Looking for include files ${INCLUDE}") TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c @@ -54,15 +54,15 @@ MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) "${CHECK_INCLUDE_FILES_INCLUDE_DIRS}" OUTPUT_VARIABLE OUTPUT) IF(${VARIABLE}) - MESSAGE(STATUS "Looking for include files ${VARIABLE} - found") - SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${VARIABLE}") + MESSAGE(STATUS "Looking for include files ${INCLUDE} - found") + SET(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if files ${INCLUDE} " "exist passed with the following output:\n" "${OUTPUT}\n\n") ELSE(${VARIABLE}) - MESSAGE(STATUS "Looking for include files ${VARIABLE} - not found.") - SET(${VARIABLE} "" CACHE INTERNAL "Have includes ${VARIABLE}") + MESSAGE(STATUS "Looking for include files ${INCLUDE} - not found.") + SET(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " "exist failed with the following output:\n" diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index 183b2bb..515319d 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -60,7 +60,7 @@ MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") ENDFOREACH(FILE) SET(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n") + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nint main(int argc, char** argv)\n{\n (void)argv;\n#ifndef ${SYMBOL}\n return ((int*)(&${SYMBOL}))[argc];\n#else\n (void)argc;\n return 0;\n#endif\n}\n") CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" "${SOURCEFILE}" @ONLY IMMEDIATE) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index a37771b..fb55d3b 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -144,7 +144,7 @@ # set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) #============================================================================= -# Copyright 2008-2009 Kitware, Inc. +# Copyright 2008-2012 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -954,6 +954,7 @@ function(_ep_get_git_version git_EXECUTABLE git_version_var) execute_process( COMMAND "${git_EXECUTABLE}" --version OUTPUT_VARIABLE ov + ERROR_VARIABLE ev OUTPUT_STRIP_TRAILING_WHITESPACE ) string(REGEX REPLACE "^git version (.+)$" "\\1" version "${ov}") diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index af84f8c..ec6e3a8 100644 --- a/Modules/FindALSA.cmake +++ b/Modules/FindALSA.cmake @@ -8,6 +8,7 @@ # # ALSA_INCLUDE_DIR - where to find asoundlib.h, etc. # ALSA_LIBRARY - the asound library +# ALSA_VERSION_STRING - the version of alsa found (since CMake 2.8.8) # #============================================================================= @@ -33,10 +34,19 @@ find_library(ALSA_LIBRARY NAMES asound DOC "The ALSA (asound) library" ) +if(ALSA_INCLUDE_DIR AND EXISTS "${ALSA_INCLUDE_DIR}/version.h") + file(STRINGS "${ALSA_INCLUDE_DIR}/version.h" alsa_version_str REGEX "^#define[\t ]+SND_LIB_VERSION_STR[\t ]+\".*\"") + + string(REGEX REPLACE "^.*SND_LIB_VERSION_STR[\t ]+\"([^\"]*)\".*$" "\\1" ALSA_VERSION_STRING "${alsa_version_str}") + unset(alsa_version_str) +endif() + # handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA DEFAULT_MSG ALSA_LIBRARY ALSA_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA + REQUIRED_VARS ALSA_LIBRARY ALSA_INCLUDE_DIR + VERSION_VAR ALSA_VERSION_STRING) if(ALSA_FOUND) set( ALSA_LIBRARIES ${ALSA_LIBRARY} ) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index edde9eb..7af3367 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -75,8 +75,9 @@ IF(BISON_EXECUTABLE) ELSEIF("${BISON_version_output}" MATCHES "^bison[^+]") STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" BISON_VERSION "${BISON_version_output}") - ELSE() - SET(BISON_VERSION "unknown") + ELSEIF("${BISON_version_output}" MATCHES "^GNU Bison ") + STRING(REGEX REPLACE "^GNU Bison (version )?([^\n]+).*" "\\2" + BISON_VERSION "${BISON_version_output}") ENDIF() ENDIF() diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 679c129..7130192 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -5,10 +5,12 @@ # BZIP2_INCLUDE_DIR - the BZip2 include directory # BZIP2_LIBRARIES - Link these to use BZip2 # BZIP2_NEED_PREFIX - this is set if the functions are prefixed with BZ2_ +# BZIP2_VERSION_STRING - the version of BZip2 found (since CMake 2.8.8) #============================================================================= -# Copyright 2006-2009 Kitware, Inc. +# Copyright 2006-2012 Kitware, Inc. # Copyright 2006 Alexander Neundorf <neundorf@kde.org> +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -22,17 +24,29 @@ FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ) -FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2 ) +IF (NOT BZIP2_LIBRARIES) + FIND_LIBRARY(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ) + FIND_LIBRARY(BZIP2_LIBRARY_DEBUG NAMES bzip2d ) + + INCLUDE(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + SELECT_LIBRARY_CONFIGURATIONS(BZIP2) +ENDIF (NOT BZIP2_LIBRARIES) + +IF (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h") + FILE(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ") + STRING(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}") +ENDIF (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h") # handle the QUIETLY and REQUIRED arguments and set BZip2_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 DEFAULT_MSG BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 + REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR + VERSION_VAR BZIP2_VERSION_STRING) IF (BZIP2_FOUND) INCLUDE(CheckLibraryExists) - CHECK_LIBRARY_EXISTS(${BZIP2_LIBRARIES} BZ2_bzCompressInit "" BZIP2_NEED_PREFIX) + CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX) ENDIF (BZIP2_FOUND) -MARK_AS_ADVANCED(BZIP2_INCLUDE_DIR BZIP2_LIBRARIES) - +MARK_AS_ADVANCED(BZIP2_INCLUDE_DIR) diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index 36f3841..cc00d53 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -1,12 +1,14 @@ # - Find curl # Find the native CURL headers and libraries. # -# CURL_INCLUDE_DIRS - where to find curl/curl.h, etc. -# CURL_LIBRARIES - List of libraries when using curl. -# CURL_FOUND - True if curl found. +# CURL_INCLUDE_DIRS - where to find curl/curl.h, etc. +# CURL_LIBRARIES - List of libraries when using curl. +# CURL_FOUND - True if curl found. +# CURL_VERSION_STRING - the version of curl found (since CMake 2.8.8) #============================================================================= # Copyright 2006-2009 Kitware, Inc. +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -32,10 +34,24 @@ FIND_LIBRARY(CURL_LIBRARY NAMES ) MARK_AS_ADVANCED(CURL_LIBRARY) +IF(CURL_INCLUDE_DIR) + FOREACH(_curl_version_header curlver.h curl.h) + IF(EXISTS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}") + FILE(STRINGS "${CURL_INCLUDE_DIR}/curl/${_curl_version_header}" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") + + STRING(REGEX REPLACE "^#define[\t ]+LIBCURL_VERSION[\t ]+\"([^\"]*)\".*" "\\1" CURL_VERSION_STRING "${curl_version_str}") + UNSET(curl_version_str) + BREAK() + ENDIF() + ENDFOREACH(_curl_version_header) +ENDIF() + # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL + REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR + VERSION_VAR CURL_VERSION_STRING) IF(CURL_FOUND) SET(CURL_LIBRARIES ${CURL_LIBRARY}) diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 7e3e10a..3862f7d 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -4,12 +4,14 @@ # CUPS_FOUND - system has Cups # CUPS_INCLUDE_DIR - the Cups include directory # CUPS_LIBRARIES - Libraries needed to use Cups +# CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8) # Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which # features this function (i.e. at least 1.1.19) #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006 Alexander Neundorf <neundorf@kde.org> +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -21,36 +23,47 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -INCLUDE(CheckLibraryExists) +find_path(CUPS_INCLUDE_DIR cups/cups.h ) -FIND_PATH(CUPS_INCLUDE_DIR cups/cups.h ) +find_library(CUPS_LIBRARIES NAMES cups ) -FIND_LIBRARY(CUPS_LIBRARIES NAMES cups ) +if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) + include(CheckLibraryExists) -IF (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES) - SET(CUPS_FOUND TRUE) + # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint) + CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE) +endif (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) - # ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint) - CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE) - IF (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE AND NOT CUPS_HAS_IPP_DELETE_ATTRIBUTE) - SET(CUPS_FOUND FALSE) - ENDIF (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE AND NOT CUPS_HAS_IPP_DELETE_ATTRIBUTE) +if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") + file(STRINGS "${CUPS_INCLUDE_DIR}/cups/cups.h" cups_version_str + REGEX "^#[\t ]*define[\t ]+CUPS_VERSION_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$") -ELSE (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES) - SET(CUPS_FOUND FALSE) -ENDIF (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES) + unset(CUPS_VERSION_STRING) + foreach(VPART MAJOR MINOR PATCH) + foreach(VLINE ${cups_version_str}) + if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}") + string(REGEX REPLACE "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1" + CUPS_VERSION_PART "${VLINE}") + if(CUPS_VERSION_STRING) + set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}") + else(CUPS_VERSION_STRING) + set(CUPS_VERSION_STRING "${CUPS_VERSION_PART}") + endif(CUPS_VERSION_STRING) + endif() + endforeach(VLINE) + endforeach(VPART) +endif (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h") -IF (CUPS_FOUND) - IF (NOT Cups_FIND_QUIETLY) - MESSAGE(STATUS "Found Cups: ${CUPS_LIBRARIES}") - ENDIF (NOT Cups_FIND_QUIETLY) -ELSE (CUPS_FOUND) - SET(CUPS_LIBRARIES ) - IF (Cups_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find Cups") - ENDIF (Cups_FIND_REQUIRED) -ENDIF (CUPS_FOUND) - - -MARK_AS_ADVANCED(CUPS_INCLUDE_DIR CUPS_LIBRARIES) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +if (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups + REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR CUPS_HAS_IPP_DELETE_ATTRIBUTE + VERSION_VAR CUPS_VERSION_STRING) +else (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cups + REQUIRED_VARS CUPS_LIBRARIES CUPS_INCLUDE_DIR + VERSION_VAR CUPS_VERSION_STRING) +endif (CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) +mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES) diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 8551fd6..1bf0743 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -24,10 +24,32 @@ FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h) # Look for the library. FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat) +if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") + file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str + REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$") + + unset(EXPAT_VERSION_STRING) + foreach(VPART MAJOR MINOR MICRO) + foreach(VLINE ${expat_version_str}) + if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION") + string(REGEX REPLACE "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$" "\\1" + EXPAT_VERSION_PART "${VLINE}") + if(EXPAT_VERSION_STRING) + set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}") + else(EXPAT_VERSION_STRING) + set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}") + endif(EXPAT_VERSION_STRING) + endif() + endforeach(VLINE) + endforeach(VPART) +endif (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") + # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT + REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR + VERSION_VAR EXPAT_VERSION_STRING) # Copy the results to the output variables. IF(EXPAT_FOUND) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 6a70b40..586f77a 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -91,8 +91,12 @@ IF(FLEX_EXECUTABLE) MESSAGE("Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}\nFLEX_VERSION will not be available") ENDIF() ELSE() - STRING(REGEX REPLACE "^flex (.*)$" "\\1" + # older versions of flex printed "/full/path/to/executable version X.Y" + # newer versions use "basename(executable) X.Y" + GET_FILENAME_COMPONENT(FLEX_EXE_NAME "${FLEX_EXECUTABLE}" NAME) + STRING(REGEX REPLACE "^.*${FLEX_EXE_NAME}\"? (version )?([0-9]+[^ ]*)$" "\\2" FLEX_VERSION "${FLEX_version_output}") + UNSET(FLEX_EXE_NAME) ENDIF() #============================================================ diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index c44adb4..635090b 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -4,6 +4,7 @@ # GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. # GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. # GETTEXT_FOUND: True if gettext has been found. +# GETTEXT_VERSION_STRING: the version of gettext found (since CMake 2.8.8) # # Additionally it provides the following macros: # GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) @@ -42,8 +43,21 @@ FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) +IF(GETTEXT_MSGMERGE_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --version + OUTPUT_VARIABLE gettext_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]") + STRING(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}") + ENDIF() + UNSET(gettext_version) +ENDIF(GETTEXT_MSGMERGE_EXECUTABLE) + INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext + REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE + VERSION_VAR GETTEXT_VERSION_STRING) INCLUDE(CMakeParseArguments) diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index 503b640..f89d1af 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -1,6 +1,7 @@ # The module defines the following variables: # GIT_EXECUTABLE - path to git command line client # GIT_FOUND - true if the command line client was found +# GIT_VERSION_STRING - the version of git found (since CMake 2.8.8) # Example usage: # find_package(Git) # if(GIT_FOUND) @@ -9,6 +10,7 @@ #============================================================================= # Copyright 2010 Kitware, Inc. +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -40,8 +42,21 @@ find_program(GIT_EXECUTABLE ) mark_as_advanced(GIT_EXECUTABLE) +if(GIT_EXECUTABLE) + execute_process(COMMAND ${GIT_EXECUTABLE} --version + OUTPUT_VARIABLE git_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (git_version MATCHES "^git version [0-9]") + string(REPLACE "git version " "" GIT_VERSION_STRING "${git_version}") + endif() + unset(git_version) +endif(GIT_EXECUTABLE) + # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE) +find_package_handle_standard_args(Git + REQUIRED_VARS GIT_EXECUTABLE + VERSION_VAR GIT_VERSION_STRING) diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index a437a1f..02f2964 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -35,9 +35,10 @@ IF (NOT WIN32) # try using pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful - FIND_PACKAGE(PkgConfig) - PKG_CHECK_MODULES(PC_GNUTLS gnutls) + FIND_PACKAGE(PkgConfig QUIET) + PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls) SET(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER}) + SET(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION}) ENDIF (NOT WIN32) FIND_PATH(GNUTLS_INCLUDE_DIR gnutls/gnutls.h @@ -57,7 +58,9 @@ MARK_AS_ADVANCED(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS + REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR + VERSION_VAR GNUTLS_VERSION_STRING) IF(GNUTLS_FOUND) SET(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY}) diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index 7c59f03..3e36e4b 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake @@ -4,6 +4,7 @@ # # GNUPLOT_FOUND - system has Gnuplot # GNUPLOT_EXECUTABLE - the Gnuplot executable +# GNUPLOT_VERSION_STRING - the version of Gnuplot found (since CMake 2.8.8) #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -29,13 +30,26 @@ FIND_PROGRAM(GNUPLOT_EXECUTABLE ${CYGWIN_INSTALL_PATH}/bin ) +IF (GNUPLOT_EXECUTABLE) + EXECUTE_PROCESS(COMMAND "${GNUPLOT_EXECUTABLE}" --version + OUTPUT_VARIABLE GNUPLOT_OUTPUT_VARIABLE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + STRING(REGEX REPLACE "^gnuplot ([0-9\\.]+)( patchlevel )?" "\\1." GNUPLOT_VERSION_STRING "${GNUPLOT_OUTPUT_VARIABLE}") + STRING(REGEX REPLACE "\\.$" "" GNUPLOT_VERSION_STRING "${GNUPLOT_VERSION_STRING}") + UNSET(GNUPLOT_OUTPUT_VARIABLE) +ENDIF() + # for compatibility SET(GNUPLOT ${GNUPLOT_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set GNUPLOT_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gnuplot DEFAULT_MSG GNUPLOT_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gnuplot + REQUIRED_VARS GNUPLOT_EXECUTABLE + VERSION_VAR GNUPLOT_VERSION_STRING) MARK_AS_ADVANCED( GNUPLOT_EXECUTABLE ) diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 5e6fa20..75523f4 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -24,6 +24,8 @@ # ImageMagick_EXECUTABLE_DIR - Full path to executables directory. # ImageMagick_<component>_FOUND - TRUE if <component> is found. # ImageMagick_<component>_EXECUTABLE - Full path to <component> executable. +# ImageMagick_VERSION_STRING - the version of ImageMagick found +# (since CMake 2.8.8) # # There are also components for the following ImageMagick APIs: # @@ -53,6 +55,7 @@ #============================================================================= # Copyright 2007-2009 Kitware, Inc. # Copyright 2007-2008 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org> +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -134,7 +137,8 @@ FIND_PATH(ImageMagick_EXECUTABLE_DIR # Find each component. Search for all tools in same dir # <ImageMagick_EXECUTABLE_DIR>; otherwise they should be found # independently and not in a cohesive module such as this one. -SET(ImageMagick_FOUND TRUE) +UNSET(ImageMagick_REQUIRED_VARS) +UNSET(ImageMagick_DEFAULT_EXECUTABLES) FOREACH(component ${ImageMagick_FIND_COMPONENTS} # DEPRECATED: forced components for backward compatibility convert mogrify import montage composite @@ -143,37 +147,65 @@ FOREACH(component ${ImageMagick_FIND_COMPONENTS} FIND_IMAGEMAGICK_API(Magick++ Magick++.h Magick++ CORE_RL_Magick++_ ) + LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_Magick++_LIBRARY) ELSEIF(component STREQUAL "MagickWand") FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h Wand MagickWand CORE_RL_wand_ ) + LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickWand_LIBRARY) ELSEIF(component STREQUAL "MagickCore") FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h Magick MagickCore CORE_RL_magick_ ) + LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_MagickCore_LIBRARY) ELSE(component STREQUAL "Magick++") IF(ImageMagick_EXECUTABLE_DIR) FIND_IMAGEMAGICK_EXE(${component}) ENDIF(ImageMagick_EXECUTABLE_DIR) + + IF(ImageMagick_FIND_COMPONENTS) + LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested) + IF(is_requested GREATER -1) + LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_${component}_EXECUTABLE) + ENDIF(is_requested GREATER -1) + ELSEIF(ImageMagick_${component}_EXECUTABLE) + # if no components were requested explicitely put all (default) executables + # in the list + LIST(APPEND ImageMagick_DEFAULT_EXECUTABLES "${ImageMagick_${component}_EXECUTABLE}") + ENDIF(ImageMagick_FIND_COMPONENTS) ENDIF(component STREQUAL "Magick++") - - IF(NOT ImageMagick_${component}_FOUND) - LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested) - IF(is_requested GREATER -1) - SET(ImageMagick_FOUND FALSE) - ENDIF(is_requested GREATER -1) - ENDIF(NOT ImageMagick_${component}_FOUND) ENDFOREACH(component) +IF(NOT ImageMagick_FIND_COMPONENTS AND NOT ImageMagick_DEFAULT_EXECUTABLES) + # No components were requested, and none of the default components were + # found. Just insert mogrify into the list of the default components to + # find so FPHSA below has something to check + LIST(APPEND ImageMagick_REQUIRED_VARS ImageMagick_mogrify_EXECUTABLE) +ELSEIF(ImageMagick_DEFAULT_EXECUTABLES) + LIST(APPEND ImageMagick_REQUIRED_VARS ${ImageMagick_DEFAULT_EXECUTABLES}) +ENDIF() + SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS}) SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES}) +IF(ImageMagick_mogrify_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${ImageMagick_mogrify_EXECUTABLE} -version + OUTPUT_VARIABLE imagemagick_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(imagemagick_version MATCHES "^Version: ImageMagick [0-9]") + STRING(REGEX REPLACE "^Version: ImageMagick ([-0-9\\.]+).*" "\\1" ImageMagick_VERSION_STRING "${imagemagick_version}") + ENDIF() + UNSET(imagemagick_version) +ENDIF(ImageMagick_mogrify_EXECUTABLE) + #--------------------------------------------------------------------- # Standard Package Output #--------------------------------------------------------------------- INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( - ImageMagick DEFAULT_MSG ImageMagick_FOUND +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ImageMagick + REQUIRED_VARS ${ImageMagick_REQUIRED_VARS} + VERSION_VAR ImageMagick_VERSION_STRING ) # Maintain consistency with all other variables. SET(ImageMagick_FOUND ${IMAGEMAGICK_FOUND}) diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index bae4c05..6dc7e4d 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -3,11 +3,13 @@ # # JASPER_FOUND - system has Jasper # JASPER_INCLUDE_DIR - the Jasper include directory -# JASPER_LIBRARIES - The libraries needed to use Jasper +# JASPER_LIBRARIES - the libraries needed to use Jasper +# JASPER_VERSION_STRING - the version of Jasper found (since CMake 2.8.8) #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006 Alexander Neundorf <neundorf@kde.org> +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -19,19 +21,33 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PACKAGE(JPEG) - FIND_PATH(JASPER_INCLUDE_DIR jasper/jasper.h) -FIND_LIBRARY(JASPER_LIBRARY NAMES jasper libjasper) +IF (NOT JASPER_LIBRARIES) + FIND_PACKAGE(JPEG) + + FIND_LIBRARY(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) + FIND_LIBRARY(JASPER_LIBRARY_DEBUG NAMES jasperd) + + INCLUDE(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + SELECT_LIBRARY_CONFIGURATIONS(JASPER) +ENDIF (NOT JASPER_LIBRARIES) + +IF (JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") + FILE(STRINGS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h" jasper_version_str REGEX "^#define[\t ]+JAS_VERSION[\t ]+\".*\".*") + + STRING(REGEX REPLACE "^#define[\t ]+JAS_VERSION[\t ]+\"([^\"]+)\".*" "\\1" JASPER_VERSION_STRING "${jasper_version_str}") +ENDIF (JASPER_INCLUDE_DIR AND EXISTS "${JASPER_INCLUDE_DIR}/jasper/jas_config.h") # handle the QUIETLY and REQUIRED arguments and set JASPER_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper DEFAULT_MSG JASPER_LIBRARY JASPER_INCLUDE_DIR JPEG_LIBRARIES) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper + REQUIRED_VARS JASPER_LIBRARIES JASPER_INCLUDE_DIR JPEG_LIBRARIES + VERSION_VAR JASPER_VERSION_STRING) IF (JASPER_FOUND) - SET(JASPER_LIBRARIES ${JASPER_LIBRARY} ${JPEG_LIBRARIES} ) + SET(JASPER_LIBRARIES ${JASPER_LIBRARIES} ${JPEG_LIBRARIES} ) ENDIF (JASPER_FOUND) -MARK_AS_ADVANCED(JASPER_INCLUDE_DIR JASPER_LIBRARY) +MARK_AS_ADVANCED(JASPER_INCLUDE_DIR) diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index cedcd24..be931c5 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -54,8 +54,9 @@ endif() # itself includes this FindLibArchive when built with an older CMake that does # not provide it. The older CMake also does not have CMAKE_CURRENT_LIST_DIR.) include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(LibArchive DEFAULT_MSG - LibArchive_LIBRARY LibArchive_INCLUDE_DIR +find_package_handle_standard_args(LibArchive + REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR + VERSION_VAR LibArchive_VERSION ) set(LibArchive_FOUND ${LIBARCHIVE_FOUND}) unset(LIBARCHIVE_FOUND) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 95ae180..48a5498 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -6,6 +6,7 @@ # LIBXML2_LIBRARIES - The libraries needed to use LibXml2 # LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2 # LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2 +# LIBXML2_VERSION_STRING - the version of LibXml2 found (since CMake 2.8.8) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -23,8 +24,8 @@ # 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 QUIET) +FIND_PACKAGE(PkgConfig QUIET) +PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0) SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) FIND_PATH(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h @@ -44,10 +45,22 @@ FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint) # for backwards compat. with KDE 4.0.x: SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") +IF(PC_LIBXML_VERSION) + SET(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION}) +ELSEIF(LIBXML2_INCLUDE_DIR AND EXISTS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h") + FILE(STRINGS "${LIBXML2_INCLUDE_DIR}/libxml/xmlversion.h" libxml2_version_str + REGEX "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\".*\"") + + STRING(REGEX REPLACE "^#define[\t ]+LIBXML_DOTTED_VERSION[\t ]+\"([^\"]*)\".*" "\\1" + LIBXML2_VERSION_STRING "${libxml2_version_str}") + UNSET(libxml2_version_str) +ENDIF() + # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 + REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR + VERSION_VAR LIBXML2_VERSION_STRING) MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) - diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 1f49c3b..1e42f42 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -25,7 +25,7 @@ # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls -FIND_PACKAGE(PkgConfig) +FIND_PACKAGE(PkgConfig QUIET) PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt) SET(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER}) diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index 123fd5d..b67dd4c 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -2,7 +2,8 @@ # This module defines # LUA51_FOUND, if false, do not try to link to Lua # LUA_LIBRARIES -# LUA_INCLUDE_DIR, where to find lua.h +# LUA_INCLUDE_DIR, where to find lua.h +# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8) # # Note that the expected include convention is # #include "lua.h" @@ -66,10 +67,19 @@ IF(LUA_LIBRARY) ENDIF(UNIX AND NOT APPLE) ENDIF(LUA_LIBRARY) +IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h") + FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"") + + STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}") + UNSET(lua_version_str) +ENDIF() + INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 + REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR + VERSION_VAR LUA_VERSION_STRING) MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 250d8a6..1be4ccf 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -413,7 +413,7 @@ function (interrogate_mpi_compiler lang try_libs) HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} PATH_SUFFIXES lib) if (MPI_LIBRARIES_WORK AND MPI_LIB) - set(MPI_LIBRARIES_WORK "${MPI_LIBRARIES_WORK} ${MPI_LIB}") + list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) endif() endif() diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index af799d6..d1fc2d2 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -7,7 +7,7 @@ # OPENSSL_FOUND - system has the OpenSSL library # OPENSSL_INCLUDE_DIR - the OpenSSL include directory # OPENSSL_LIBRARIES - The libraries needed to use OpenSSL -# OPENSSL_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) +# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -25,10 +25,8 @@ # License text for the above reference.) if (UNIX) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(_OPENSSL openssl) - endif (PKG_CONFIG_FOUND) + find_package(PkgConfig QUIET) + pkg_check_modules(_OPENSSL QUIET openssl) endif (UNIX) # http://www.slproweb.com/products/Win32OpenSSL.html @@ -215,17 +213,73 @@ ELSE(WIN32 AND NOT CYGWIN) ENDIF(WIN32 AND NOT CYGWIN) +function(from_hex HEX DEC) + string(TOUPPER "${HEX}" HEX) + set(_res 0) + string(LENGTH "${HEX}" _strlen) + + while (_strlen GREATER 0) + math(EXPR _res "${_res} * 16") + string(SUBSTRING "${HEX}" 0 1 NIBBLE) + string(SUBSTRING "${HEX}" 1 -1 HEX) + if (NIBBLE STREQUAL "A") + math(EXPR _res "${_res} + 10") + elseif (NIBBLE STREQUAL "B") + math(EXPR _res "${_res} + 11") + elseif (NIBBLE STREQUAL "C") + math(EXPR _res "${_res} + 12") + elseif (NIBBLE STREQUAL "D") + math(EXPR _res "${_res} + 13") + elseif (NIBBLE STREQUAL "E") + math(EXPR _res "${_res} + 14") + elseif (NIBBLE STREQUAL "F") + math(EXPR _res "${_res} + 15") + else() + math(EXPR _res "${_res} + ${NIBBLE}") + endif() + + string(LENGTH "${HEX}" _strlen) + endwhile() + + set(${DEC} ${_res} PARENT_SCOPE) +endfunction(from_hex) + if (OPENSSL_INCLUDE_DIR) - file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9][0-9][0-9][0-9][0-9][0-9].*") + if (_OPENSSL_VERSION) + set(OPENSSL_VERSION "${_OPENSSL_VERSION}") + elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") + file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str + REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") + + # The version number is encoded as 0xMNNFFPPS: major minor fix patch status + # The status gives if this is a developer or prerelease and is ignored here. + # Major, minor, and fix directly translate into the version numbers shown in + # the string. The patch field translates to the single character suffix that + # indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so + # on. - string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1" OPENSSL_VERSION_MAJOR "${openssl_version_str}") - string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x[0-9]([0-9][0-9]).*$" "\\1" OPENSSL_VERSION_MINOR "${openssl_version_str}") - string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x[0-9][0-9][0-9]([0-9][0-9]).*$" "\\1" OPENSSL_VERSION_PATCH "${openssl_version_str}") + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$" + "\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}") + list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR) + list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR) + from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR) + list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX) + from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX) + list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH) - string(REGEX REPLACE "^0" "" OPENSSL_VERSION_MINOR "${OPENSSL_VERSION_MINOR}") - string(REGEX REPLACE "^0" "" OPENSSL_VERSION_PATCH "${OPENSSL_VERSION_PATCH}") + if (NOT OPENSSL_VERSION_PATCH STREQUAL "00") + from_hex("${OPENSSL_VERSION_PATCH}" _tmp) + # 96 is the ASCII code of 'a' minus 1 + math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96") + unset(_tmp) + # Once anyone knows how OpenSSL would call the patch versions beyond 'z' + # this should be updated to handle that, too. This has not happened yet + # so it is simply ignored here for now. + string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING) + endif (NOT OPENSSL_VERSION_PATCH STREQUAL "00") - set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_PATCH}") + set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}") + endif (_OPENSSL_VERSION) endif (OPENSSL_INCLUDE_DIR) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index f616973..a6c181c 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -7,6 +7,7 @@ # PNG_LIBRARIES, the libraries to link against to use PNG. # PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files. # PNG_FOUND, If false, do not try to use PNG. +# PNG_VERSION_STRING - the version of the PNG library found (since CMake 2.8.8) # Also defined, but not for general use are # PNG_LIBRARY, where to find the PNG library. # For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS. @@ -56,11 +57,19 @@ if(ZLIB_FOUND) endif (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) + if (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h") + file(STRINGS "${PNG_PNG_INCLUDE_DIR}/png.h" png_version_str REGEX "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\".+\"") + + string(REGEX REPLACE "^#define[ \t]+PNG_LIBPNG_VER_STRING[ \t]+\"([^\"]+)\".*" "\\1" PNG_VERSION_STRING "${png_version_str}") + unset(png_version_str) + endif (PNG_PNG_INCLUDE_DIR AND EXISTS "${PNG_PNG_INCLUDE_DIR}/png.h") endif(ZLIB_FOUND) # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR) +find_package_handle_standard_args(PNG + REQUIRED_VARS PNG_LIBRARY PNG_PNG_INCLUDE_DIR + VERSION_VAR PNG_VERSION_STRING) mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 1acb021..b503357 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -33,9 +33,9 @@ # messages include information about the required version and the version # which has been actually found, both if the version is ok or not. # Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for -# a find_package(... NO_MODULE) call, in this case all the information -# provided by the config-mode of find_package() will be evaluated -# automatically. +# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set +# to <NAME>_VERSION and the macro will automatically check whether the +# Config module was found. # Via FAIL_MESSAGE a custom failure message can be specified, if this is not # used, the default message will be displayed. # diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index db393e7..ae686df 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -1,8 +1,9 @@ # - Find perl # this module looks for Perl # -# PERL_EXECUTABLE - the full path to perl -# PERL_FOUND - If false, don't attempt to use perl. +# PERL_EXECUTABLE - the full path to perl +# PERL_FOUND - If false, don't attempt to use perl. +# PERL_VERSION_STRING - version of perl found (since CMake 2.8.8) #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -39,12 +40,44 @@ FIND_PROGRAM(PERL_EXECUTABLE PATHS ${PERL_POSSIBLE_BIN_PATHS} ) +IF(PERL_EXECUTABLE) + ### PERL_VERSION + EXECUTE_PROCESS( + COMMAND + ${PERL_EXECUTABLE} -V:version + OUTPUT_VARIABLE + PERL_VERSION_OUTPUT_VARIABLE + RESULT_VARIABLE + PERL_VERSION_RESULT_VARIABLE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + IF(NOT PERL_VERSION_RESULT_VARIABLE AND NOT PERL_VERSION_OUTPUT_VARIABLE MATCHES "^version='UNKNOWN'") + STRING(REGEX REPLACE "version='([^']+)'.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE}) + ELSE() + EXECUTE_PROCESS( + COMMAND ${PERL_EXECUTABLE} -v + OUTPUT_VARIABLE PERL_VERSION_OUTPUT_VARIABLE + RESULT_VARIABLE PERL_VERSION_RESULT_VARIABLE + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + IF(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]") + STRING(REGEX REPLACE ".*This is perl.*[ \\(]v([0-9\\._]+)[ \\)].*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE}) + ELSEIF(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +") + STRING(REGEX REPLACE ".*This is perl, version ([0-9\\._]+) +.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE}) + ENDIF() + ENDIF() +ENDIF(PERL_EXECUTABLE) + # Deprecated settings for compatibility with CMake1.4 SET(PERL ${PERL_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl DEFAULT_MSG PERL_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl + REQUIRED_VARS PERL_EXECUTABLE + VERSION_VAR PERL_VERSION_STRING) MARK_AS_ADVANCED(PERL_EXECUTABLE) diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index eea55f1..0ac8060 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -55,19 +55,6 @@ if (PERL_EXECUTABLE) string(REGEX REPLACE "prefix='([^']+)'.*" "\\1" PERL_PREFIX ${PERL_PREFIX_OUTPUT_VARIABLE}) endif (NOT PERL_PREFIX_RESULT_VARIABLE) - ### PERL_VERSION - execute_process( - COMMAND - ${PERL_EXECUTABLE} -V:version - OUTPUT_VARIABLE - PERL_VERSION_OUTPUT_VARIABLE - RESULT_VARIABLE - PERL_VERSION_RESULT_VARIABLE - ) - if (NOT PERL_VERSION_RESULT_VARIABLE) - string(REGEX REPLACE "version='([^']+)'.*" "\\1" PERL_VERSION ${PERL_VERSION_OUTPUT_VARIABLE}) - endif (NOT PERL_VERSION_RESULT_VARIABLE) - ### PERL_ARCHNAME execute_process( COMMAND @@ -206,19 +193,19 @@ if (PERL_EXECUTABLE) ### PERL_POSSIBLE_INCLUDE_PATHS set(PERL_POSSIBLE_INCLUDE_PATHS ${PERL_ARCHLIB}/CORE - /usr/lib/perl5/${PERL_VERSION}/${PERL_ARCHNAME}/CORE - /usr/lib/perl/${PERL_VERSION}/${PERL_ARCHNAME}/CORE - /usr/lib/perl5/${PERL_VERSION}/CORE - /usr/lib/perl/${PERL_VERSION}/CORE + /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE + /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE + /usr/lib/perl5/${PERL_VERSION_STRING}/CORE + /usr/lib/perl/${PERL_VERSION_STRING}/CORE ) ### PERL_POSSIBLE_LIB_PATHS set(PERL_POSSIBLE_LIB_PATHS ${PERL_ARCHLIB}/CORE - /usr/lib/perl5/${PERL_VERSION}/${PERL_ARCHNAME}/CORE - /usr/lib/perl/${PERL_VERSION}/${PERL_ARCHNAME}/CORE - /usr/lib/perl5/${PERL_VERSION}/CORE - /usr/lib/perl/${PERL_VERSION}/CORE + /usr/lib/perl5/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE + /usr/lib/perl/${PERL_VERSION_STRING}/${PERL_ARCHNAME}/CORE + /usr/lib/perl5/${PERL_VERSION_STRING}/CORE + /usr/lib/perl/${PERL_VERSION_STRING}/CORE ) ### PERL_POSSIBLE_LIBRARY_NAME @@ -249,7 +236,7 @@ if (PERL_EXECUTABLE) find_library(PERL_LIBRARY NAMES ${PERL_POSSIBLE_LIBRARY_NAME} - perl${PERL_VERSION} + perl${PERL_VERSION_STRING} perl PATHS ${PERL_POSSIBLE_LIB_PATHS} @@ -261,15 +248,16 @@ endif (PERL_EXECUTABLE) # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(PerlLibs REQUIRED_VARS PERL_LIBRARY PERL_INCLUDE_PATH - VERSION_VAR PERL_VERSION) + VERSION_VAR PERL_VERSION_STRING) # Introduced after CMake 2.6.4 to bring module into compliance set(PERL_INCLUDE_DIR ${PERL_INCLUDE_PATH}) set(PERL_INCLUDE_DIRS ${PERL_INCLUDE_PATH}) set(PERL_LIBRARIES ${PERL_LIBRARY}) +# For backward compatibility with CMake before 2.8.7 +set(PERL_VERSION ${PERL_VERSION_STRING}) mark_as_advanced( PERL_INCLUDE_PATH - PERL_EXECUTABLE PERL_LIBRARY ) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index c47f583..ce58899 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -85,14 +85,12 @@ ### Common stuff #### set(PKG_CONFIG_VERSION 1) -set(PKG_CONFIG_FOUND 0) find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable") mark_as_advanced(PKG_CONFIG_EXECUTABLE) -if(PKG_CONFIG_EXECUTABLE) - set(PKG_CONFIG_FOUND 1) -endif(PKG_CONFIG_EXECUTABLE) +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(PkgConfig DEFAULT_MSG PKG_CONFIG_EXECUTABLE) # Unsets the given variables diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 55f95c6..94e5676 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -1,20 +1,11 @@ # - 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}) -# 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. # +# This module defines +# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking +# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers +# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8) #============================================================================= # Copyright 2004-2009 Kitware, Inc. @@ -150,11 +141,20 @@ find_library( PostgreSQL_LIBRARY ) get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) +if (PostgreSQL_INCLUDE_DIR AND EXISTS "${PostgreSQL_INCLUDE_DIR}/pg_config.h") + file(STRINGS "${PostgreSQL_INCLUDE_DIR}/pg_config.h" pgsql_version_str + REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") + + string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" "\\1" + PostgreSQL_VERSION_STRING "${pgsql_version_str}") + unset(pgsql_version_str) +endif() + # Did we find anything? include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PostgreSQL DEFAULT_MSG - PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR) - +find_package_handle_standard_args(PostgreSQL + REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR + VERSION_VAR PostgreSQL_VERSION_STRING) set( PostgreSQL_FOUND ${POSTGRESQL_FOUND}) # Now try to get the include and library path. diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 5344304..1e1e493 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -7,6 +7,9 @@ # (vsprojects/Debug & vsprojects/Release) will be searched # for libraries and binaries. # +# PROTOBUF_IMPORT_DIRS - List of additional directories to be searched for +# imported .proto files. (New in CMake 2.8.8) +# # Defines the following variables: # # PROTOBUF_FOUND - Found the Google Protocol Buffers library (libprotobuf & header files) @@ -91,6 +94,16 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) endif() + if(DEFINED PROTOBUF_IMPORT_DIRS) + foreach(DIR ${PROTOBUF_IMPORT_DIRS}) + get_filename_component(ABS_PATH ${DIR} ABSOLUTE) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + endif() + set(${SRCS}) set(${HDRS}) foreach(FIL ${ARGN}) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index a10ec23..5c1d56b 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -26,14 +26,51 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +unset(_Python_NAMES) + +set(_PYTHON1_VERSIONS 1.6 1.5) +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +if(PythonInterp_FIND_VERSION) + if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ}) + unset(_PYTHON_FIND_OTHER_VERSIONS) + if(NOT PythonInterp_FIND_VERSION_EXACT) + foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + endif() + endforeach() + endif(NOT PythonInterp_FIND_VERSION_EXACT) + unset(_PYTHON_FIND_MAJ_MIN) + unset(_PYTHON_FIND_MAJ) + else(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION}) + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS}) + endif(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") +else(PythonInterp_FIND_VERSION) + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +endif(PythonInterp_FIND_VERSION) + +list(APPEND _Python_NAMES python) + # Search for the current active python version first -find_program(PYTHON_EXECUTABLE NAMES python) +find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS} - 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +unset(_PYTHON_FIND_OTHER_VERSIONS) +unset(_PYTHON1_VERSIONS) +unset(_PYTHON2_VERSIONS) +unset(_PYTHON3_VERSIONS) # Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) @@ -51,12 +88,29 @@ endif() # determine python version string if(PYTHON_EXECUTABLE) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) - string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}") - string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") -endif() + execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version + ERROR_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + OUTPUT_QUIET + ERROR_STRIP_TRAILING_WHITESPACE) + if(_PYTHON_VERSION_RESULT) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -V + ERROR_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + OUTPUT_QUIET + ERROR_STRIP_TRAILING_WHITESPACE) + endif(_PYTHON_VERSION_RESULT) + if(NOT _PYTHON_VERSION_RESULT AND _VERSION MATCHES "^Python [0-9]+\\.[0-9]+.*") + string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") + if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") + endif() + endif() + unset(_PYTHON_VERSION_RESULT) + unset(_VERSION) +endif(PYTHON_EXECUTABLE) # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index adcec46..da7a1ac 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -40,13 +40,17 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) NAMES python${_CURRENT_VERSION_NO_DOTS}_d python PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs ) + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + ) ENDIF(WIN32) FIND_LIBRARY(PYTHON_LIBRARY NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs # Avoid finding the .dll in the PATH. We want the .lib. NO_SYSTEM_ENVIRONMENT_PATH ) @@ -79,6 +83,7 @@ FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) PATHS ${PYTHON_FRAMEWORK_INCLUDES} [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include PATH_SUFFIXES python${_CURRENT_VERSION} ) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 5d6c98a..c4adfd1 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -139,7 +139,7 @@ ENDIF(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) # In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) # try to detect which version we found. This is not too good. -IF(NOT RUBY_VERSION_MAJOR) +IF(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) # by default assume 1.8.0 SET(RUBY_VERSION_MAJOR 1) SET(RUBY_VERSION_MINOR 8) @@ -149,13 +149,14 @@ IF(NOT RUBY_VERSION_MAJOR) SET(RUBY_VERSION_MAJOR 1) SET(RUBY_VERSION_MINOR 9) ENDIF(${RUBY_EXECUTABLE} MATCHES "ruby1.?9" OR RUBY_HDR_DIR) -ENDIF(NOT RUBY_VERSION_MAJOR) +ENDIF(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) - -SET(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}") -SET(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") -SET(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") -SET(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") +IF(RUBY_VERSION_MAJOR) + SET(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}") + SET(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") + SET(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") + SET(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") +ENDIF(RUBY_VERSION_MAJOR) FIND_PATH(RUBY_INCLUDE_DIR NAMES ruby.h @@ -167,7 +168,7 @@ FIND_PATH(RUBY_INCLUDE_DIR SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} ) # if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir -IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT} GREATER 18 OR RUBY_HDR_DIR) +IF( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NODOT}" GREATER 18 OR RUBY_HDR_DIR) FIND_PATH(RUBY_CONFIG_INCLUDE_DIR NAMES ruby/config.h config.h HINTS @@ -176,7 +177,7 @@ IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT ) SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} ) -ENDIF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT} GREATER 18 OR RUBY_HDR_DIR) +ENDIF( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NODOT}" GREATER 18 OR RUBY_HDR_DIR) # Determine the list of possible names for the ruby library diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 13f32f8..f2c776f 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -48,10 +48,14 @@ INCLUDE(CMakeFindFrameworks) INCLUDE(FindTclsh) INCLUDE(FindWish) -GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH) -GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH) -STRING(REGEX REPLACE - "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}") +IF(TCLSH_VERSION_STRING) + SET(TCL_TCLSH_VERSION "${TCLSH_VERSION_STRING}") +ELSE(TCLSH_VERSION_STRING) + GET_FILENAME_COMPONENT(TCL_TCLSH_PATH "${TCL_TCLSH}" PATH) + GET_FILENAME_COMPONENT(TCL_TCLSH_PATH_PARENT "${TCL_TCLSH_PATH}" PATH) + STRING(REGEX REPLACE + "^.*tclsh([0-9]\\.*[0-9]).*$" "\\1" TCL_TCLSH_VERSION "${TCL_TCLSH}") +ENDIF(TCLSH_VERSION_STRING) GET_FILENAME_COMPONENT(TK_WISH_PATH "${TK_WISH}" PATH) GET_FILENAME_COMPONENT(TK_WISH_PATH_PARENT "${TK_WISH_PATH}" PATH) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 714f65f..16f9e23 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -25,10 +25,21 @@ FIND_PATH(TIFF_INCLUDE_DIR tiff.h) SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) +IF(TIFF_INCLUDE_DIR AND EXISTS "${TIFF_INCLUDE_DIR}/tiffvers.h") + FILE(STRINGS "${TIFF_INCLUDE_DIR}/tiffvers.h" tiff_version_str + REGEX "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version .*") + + STRING(REGEX REPLACE "^#define[\t ]+TIFFLIB_VERSION_STR[\t ]+\"LIBTIFF, Version +([^ \\n]*).*" + "\\1" TIFF_VERSION_STRING "${tiff_version_str}") + UNSET(tiff_version_str) +ENDIF() + # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF DEFAULT_MSG TIFF_LIBRARY TIFF_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF + REQUIRED_VARS TIFF_LIBRARY TIFF_INCLUDE_DIR + VERSION_VAR TIFF_VERSION_STRING) IF(TIFF_FOUND) SET( TIFF_LIBRARIES ${TIFF_LIBRARY} ) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 8fde59e..a45f285 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -82,9 +82,19 @@ FIND_PROGRAM(TCL_TCLSH HINTS ${TCLTK_POSSIBLE_BIN_PATHS} ) +IF(TCL_TCLSH) + EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -E echo puts "\$tcl_version" + COMMAND "${TCL_TCLSH}" + OUTPUT_VARIABLE TCLSH_VERSION_STRING + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) +ENDIF(TCL_TCLSH) + # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh DEFAULT_MSG TCL_TCLSH) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh + REQUIRED_VARS TCL_TCLSH + VERSION_VAR TCLSH_VERSION_STRING) MARK_AS_ADVANCED(TCL_TCLSH) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index a6c2df8..21614fb 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -23,6 +23,7 @@ INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) +INCLUDE (CheckSymbolExists) SET(Threads_FOUND FALSE) # Do we have sproc? @@ -44,33 +45,41 @@ ELSE() # SET(CMAKE_HAVE_THREADS_LIBRARY) IF(NOT THREADS_HAVE_PTHREAD_ARG) - - # Do we have -lpthreads - CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) - IF(CMAKE_HAVE_PTHREADS_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + # Check if pthread functions are in normal C library + CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE) + IF(CMAKE_HAVE_LIBC_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() - # Ok, how about -lpthread - CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) - IF(CMAKE_HAVE_PTHREAD_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lpthread") - SET(Threads_FOUND TRUE) - SET(CMAKE_HAVE_THREADS_LIBRARY 1) - ENDIF() + IF(NOT CMAKE_HAVE_THREADS_LIBRARY) + # Do we have -lpthreads + CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE) + IF(CMAKE_HAVE_PTHREADS_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) + ENDIF() - IF(CMAKE_SYSTEM MATCHES "SunOS.*") - # On sun also check for -lthread - CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) - IF(CMAKE_HAVE_THR_CREATE) - SET(CMAKE_THREAD_LIBS_INIT "-lthread") + # Ok, how about -lpthread + CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) + IF(CMAKE_HAVE_PTHREAD_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lpthread") SET(CMAKE_HAVE_THREADS_LIBRARY 1) SET(Threads_FOUND TRUE) ENDIF() - ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + IF(CMAKE_SYSTEM MATCHES "SunOS.*") + # On sun also check for -lthread + CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE) + IF(CMAKE_HAVE_THR_CREATE) + SET(CMAKE_THREAD_LIBS_INIT "-lthread") + SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) + ENDIF() + ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") + ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY) ENDIF(NOT THREADS_HAVE_PTHREAD_ARG) IF(NOT CMAKE_HAVE_THREADS_LIBRARY) @@ -111,7 +120,7 @@ ELSE() ENDIF(CMAKE_HAVE_PTHREAD_H) ENDIF() -IF(CMAKE_THREAD_LIBS_INIT) +IF(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) SET(CMAKE_USE_PTHREADS_INIT 1) SET(Threads_FOUND TRUE) ENDIF() diff --git a/Modules/FindosgPresentation.cmake b/Modules/FindosgPresentation.cmake new file mode 100644 index 0000000..f89e25f --- /dev/null +++ b/Modules/FindosgPresentation.cmake @@ -0,0 +1,52 @@ +# This is part of the Findosg* suite used to find OpenSceneGraph components. +# Each component is separate and you must opt in to each module. You must +# also opt into OpenGL and OpenThreads (and Producer if needed) as these +# modules won't do it for you. This is to allow you control over your own +# system piece by piece in case you need to opt out of certain components +# or change the Find behavior for a particular module (perhaps because the +# default FindOpenGL.cmake module doesn't work with your system as an +# example). +# If you want to use a more convenient module that includes everything, +# use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. +# +# Locate osgPresentation +# This module defines +# +# OSGPRESENTATION_FOUND - Was osgPresentation found? +# OSGPRESENTATION_INCLUDE_DIR - Where to find the headers +# OSGPRESENTATION_LIBRARIES - The libraries to link for osgPresentation (use this) +# +# OSGPRESENTATION_LIBRARY - The osgPresentation library +# OSGPRESENTATION_LIBRARY_DEBUG - The osgPresentation debug library +# +# $OSGDIR is an environment variable that would +# correspond to the ./configure --prefix=$OSGDIR +# used in building osg. +# +# Created by Eric Wing. +# Modified to work with osgPresentation by Robert Osfield, January 2012. + +#============================================================================= +# Copyright 2007-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 distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Header files are presumed to be included like +# #include <osg/PositionAttitudeTransform> +# #include <osgPresentation/SlideEventHandler> + +include(Findosg_functions) +OSG_FIND_PATH (OSGPRESENTATION osgPresentation/SlideEventHandler) +OSG_FIND_LIBRARY(OSGPRESENTATION osgPresentation) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgPresentation DEFAULT_MSG + OSGPRESENTATION_LIBRARY OSGPRESENTATION_INCLUDE_DIR) diff --git a/Modules/FindosgQt.cmake b/Modules/FindosgQt.cmake new file mode 100644 index 0000000..ddc9128 --- /dev/null +++ b/Modules/FindosgQt.cmake @@ -0,0 +1,52 @@ +# This is part of the Findosg* suite used to find OpenSceneGraph components. +# Each component is separate and you must opt in to each module. You must +# also opt into OpenGL and OpenThreads (and Producer if needed) as these +# modules won't do it for you. This is to allow you control over your own +# system piece by piece in case you need to opt out of certain components +# or change the Find behavior for a particular module (perhaps because the +# default FindOpenGL.cmake module doesn't work with your system as an +# example). +# If you want to use a more convenient module that includes everything, +# use the FindOpenSceneGraph.cmake instead of the Findosg*.cmake modules. +# +# Locate osgQt +# This module defines +# +# OSGQT_FOUND - Was osgQt found? +# OSGQT_INCLUDE_DIR - Where to find the headers +# OSGQT_LIBRARIES - The libraries to link for osgQt (use this) +# +# OSGQT_LIBRARY - The osgQt library +# OSGQT_LIBRARY_DEBUG - The osgQt debug library +# +# $OSGDIR is an environment variable that would +# correspond to the ./configure --prefix=$OSGDIR +# used in building osg. +# +# Created by Eric Wing. +# Modified to work with osgQt by Robert Osfield, January 2012. + +#============================================================================= +# Copyright 2007-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 distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Header files are presumed to be included like +# #include <osg/PositionAttitudeTransform> +# #include <osgQt/GraphicsWindowQt> + +include(Findosg_functions) +OSG_FIND_PATH (OSGQT osgQt/GraphicsWindowQt) +OSG_FIND_LIBRARY(OSGQT osgQt) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgQt DEFAULT_MSG + OSGQT_LIBRARY OSGQT_INCLUDE_DIR) diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 2efa079..8761f40 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -304,6 +304,26 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) endif(NOT resolved) if(NOT resolved) + if(item MATCHES "@rpath") + # + # @rpath references are relative to the paths built into the binaries with -rpath + # We handle this case like we do for other Unixes + # + string(REPLACE "@rpath/" "" norpath_item "${item}") + + set(ri "ri-NOTFOUND") + find_file(ri "${norpath_item}" ${exepath} ${dirs} NO_DEFAULT_PATH) + if(ri) + #message(STATUS "info: 'find_file' in exepath/dirs (${ri})") + set(resolved 1) + set(resolved_item "${ri}") + set(ri "ri-NOTFOUND") + endif(ri) + + endif(item MATCHES "@rpath") + endif(NOT resolved) + + if(NOT resolved) set(ri "ri-NOTFOUND") find_file(ri "${item}" ${exepath} ${dirs} NO_DEFAULT_PATH) find_file(ri "${item}" ${exepath} ${dirs} /usr/lib) @@ -461,6 +481,15 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) get_filename_component(path "${lower}" PATH) if("${original_path}" STREQUAL "${path}") set(is_local 1) + else() + string(LENGTH "${original_path}/" original_length) + string(LENGTH "${lower}" path_length) + if(${path_length} GREATER ${original_length}) + string(SUBSTRING "${lower}" 0 ${original_length} path) + if("${original_path}/" STREQUAL "${path}") + set(is_embedded 1) + endif() + endif() endif() endif() endif() diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 6259a5b..819cc5c 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -922,12 +922,12 @@ Function .onInit Pop $0 UserInfo::GetAccountType Pop $1 - StrCmp $1 "Admin" 0 +3 + StrCmp $1 "Admin" 0 +4 SetShellVarContext all ;MessageBox MB_OK 'User "$0" is in the Admin group' StrCpy $SV_ALLUSERS "AllUsers" Goto done - StrCmp $1 "Power" 0 +3 + StrCmp $1 "Power" 0 +4 SetShellVarContext all ;MessageBox MB_OK 'User "$0" is in the Power Users group' StrCpy $SV_ALLUSERS "AllUsers" diff --git a/Modules/SelectLibraryConfigurations.cmake b/Modules/SelectLibraryConfigurations.cmake index 51b4dda..2e8ade0 100644 --- a/Modules/SelectLibraryConfigurations.cmake +++ b/Modules/SelectLibraryConfigurations.cmake @@ -15,7 +15,6 @@ # basename_LIBRARY and basename_LIBRARIES will take only the release values. #============================================================================= -# Copyright 2009 Kitware, Inc. # Copyright 2009 Will Dicharry <wdicharry@stellarscience.com> # Copyright 2005-2009 Kitware, Inc. # @@ -49,7 +48,8 @@ macro( select_library_configurations basename ) # if only the debug version was found, set the release value to be the # debug value. _set_library_name( ${basename} DEBUG RELEASE ) - if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE) # if the generator supports configuration types or CMAKE_BUILD_TYPE # is set, then set optimized and debug options. if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) @@ -65,7 +65,7 @@ macro( select_library_configurations basename ) set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + endif() set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The ${basename} library" ) @@ -79,4 +79,3 @@ macro( select_library_configurations basename ) ${basename}_LIBRARY_DEBUG ) endmacro( select_library_configurations ) - diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index bac2430..6dd8e5c 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -29,6 +29,7 @@ bool cmAddExecutableCommand bool use_macbundle = false; bool excludeFromAll = false; bool importTarget = false; + bool importGlobal = false; while ( s != args.end() ) { if (*s == "WIN32") @@ -51,6 +52,11 @@ bool cmAddExecutableCommand ++s; importTarget = true; } + else if(importTarget && *s == "GLOBAL") + { + ++s; + importGlobal = true; + } else { break; @@ -92,7 +98,8 @@ bool cmAddExecutableCommand } // Create the imported target. - this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE); + this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE, + importGlobal); return true; } diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index f90e826..6834f58 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -92,12 +92,12 @@ public: "\n" "The add_executable command can also create IMPORTED executable " "targets using this signature:\n" - " add_executable(<name> IMPORTED)\n" + " add_executable(<name> IMPORTED [GLOBAL])\n" "An IMPORTED executable target references an executable file located " "outside the project. " "No rules are generated to build it. " "The target name has scope in the directory in which it is created " - "and below. " + "and below, but the GLOBAL option extends visibility. " "It may be referenced like any target built within the project. " "IMPORTED executables are useful for convenient reference from " "commands like add_custom_command. " diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index efa29e6..9a776fb 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -31,6 +31,7 @@ bool cmAddLibraryCommand } bool excludeFromAll = false; bool importTarget = false; + bool importGlobal = false; std::vector<std::string>::const_iterator s = args.begin(); @@ -79,6 +80,11 @@ bool cmAddLibraryCommand ++s; importTarget = true; } + else if(importTarget && *s == "GLOBAL") + { + ++s; + importGlobal = true; + } else { break; @@ -124,7 +130,7 @@ bool cmAddLibraryCommand } // Create the imported target. - this->Makefile->AddImportedTarget(libName.c_str(), type); + this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal); return true; } diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index 07fbb06..edca1bb 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -96,12 +96,13 @@ public: "\n" "The add_library command can also create IMPORTED library " "targets using this signature:\n" - " add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED)\n" + " add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED\n" + " [GLOBAL])\n" "An IMPORTED library target references a library file located " "outside the project. " "No rules are generated to build it. " "The target name has scope in the directory in which it is created " - "and below. " + "and below, but the GLOBAL option extends visibility. " "It may be referenced like any target built within the project. " "IMPORTED libraries are useful for convenient reference from " "commands like target_link_libraries. " diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index eab8a59..dc6b749 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -247,10 +247,14 @@ bool cmArchiveWrite::AddFile(const char* file, return false; } - // Content. - if(size_t size = static_cast<size_t>(archive_entry_size(e))) + // do not copy content of symlink + if (!archive_entry_symlink(e)) { - return this->AddData(file, size); + // Content. + if(size_t size = static_cast<size_t>(archive_entry_size(e))) + { + return this->AddData(file, size); + } } return true; } diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 802cfcf..9a075bd 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -358,7 +358,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) this->AddLinkEntries(depender_index, iface->Libraries); // Handle dependent shared libraries. - this->QueueSharedDependencies(depender_index, iface->SharedDeps); + this->FollowSharedDeps(depender_index, iface); // Support for CMP0003. for(std::vector<std::string>::const_iterator @@ -379,6 +379,23 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) //---------------------------------------------------------------------------- void cmComputeLinkDepends +::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface, + bool follow_interface) +{ + // Follow dependencies if we have not followed them already. + if(this->SharedDepFollowed.insert(depender_index).second) + { + if(follow_interface) + { + this->QueueSharedDependencies(depender_index, iface->Libraries); + } + this->QueueSharedDependencies(depender_index, iface->SharedDeps); + } +} + +//---------------------------------------------------------------------------- +void +cmComputeLinkDepends ::QueueSharedDependencies(int depender_index, std::vector<std::string> const& deps) { @@ -430,8 +447,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) entry.Target->GetLinkInterface(this->Config)) { // Follow public and private dependencies transitively. - this->QueueSharedDependencies(index, iface->Libraries); - this->QueueSharedDependencies(index, iface->SharedDeps); + this->FollowSharedDeps(index, iface, true); } } } diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index e196e00..80a0454 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -105,6 +105,10 @@ private: int DependerIndex; }; std::queue<SharedDepEntry> SharedDepQueue; + std::set<int> SharedDepFollowed; + void FollowSharedDeps(int depender_index, + cmTarget::LinkInterface const* iface, + bool follow_interface = false); void QueueSharedDependencies(int depender_index, std::vector<std::string> const& deps); void HandleSharedDependency(SharedDepEntry const& dep); diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index fe29df9..1cab2b5 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -354,7 +354,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "If true, do not add run time path information.", "If this is set to TRUE, then the rpath information " "is not added to compiled executables. The default " - "is to add rpath information if the platform supports it." + "is to add rpath information if the platform supports it. " "This allows for easy running from the build tree.",false, "Variables that Provide Information"); cm->DefineProperty @@ -1301,6 +1301,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables for Languages"); cm->DefineProperty + ("CMAKE_<LANG>_COMPILER_VERSION", cmProperty::VARIABLE, + "An internal variable subject to change.", + "Compiler version in major[.minor[.patch[.tweak]]] format. " + "This variable is reserved for internal use by CMake and is not " + "guaranteed to be set.", + false, + "Variables for Languages"); + + cm->DefineProperty ("CMAKE_INTERNAL_PLATFORM_ABI", cmProperty::VARIABLE, "An internal variable subject to change.", "This is used in determining the compiler ABI and is subject to change.", diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 124519a..8dce053 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1666,6 +1666,11 @@ cmGlobalGenerator::FindTarget(const char* project, const char* name) { return i->second; } + i = this->ImportedTargets.find(name); + if ( i != this->ImportedTargets.end() ) + { + return i->second; + } } return 0; } @@ -2046,10 +2051,16 @@ cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) return this->TargetDependencies[&target]; } -void cmGlobalGenerator::AddTarget(cmTargets::value_type &v) +void cmGlobalGenerator::AddTarget(cmTarget* t) { - assert(!v.second.IsImported()); - this->TotalTargets[v.first] = &v.second; + if(t->IsImported()) + { + this->ImportedTargets[t->GetName()] = t; + } + else + { + this->TotalTargets[t->GetName()] = t; + } } void cmGlobalGenerator::SetExternalMakefileProjectGenerator( diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ded3345..1a0e41a 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -230,7 +230,7 @@ public: std::set<cmStdString> const& GetDirectoryContent(std::string const& dir, bool needDisk = true); - void AddTarget(cmTargets::value_type &v); + void AddTarget(cmTarget* t); virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } virtual const char* GetInstallTargetName() const { return "INSTALL"; } @@ -333,6 +333,7 @@ protected: // All targets in the entire project. std::map<cmStdString,cmTarget *> TotalTargets; + std::map<cmStdString,cmTarget *> ImportedTargets; virtual const char* GetPredefinedTargetsFolder(); virtual bool UseFolderProperty(); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 22ba28f..4eed477 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -910,6 +910,7 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args, if (newArgs.size() != 1) { errorString = "Unknown arguments specified"; + status = cmake::FATAL_ERROR; return false; } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 14deb24..dca528d 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -350,33 +350,33 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) targetIt!=targetList.GetVector().end(); ++targetIt) { - // Lookup this target in the current directory. - if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str())) - { - // Found the target. Check its type. - if(target->GetType() != cmTarget::EXECUTABLE && - target->GetType() != cmTarget::STATIC_LIBRARY && - target->GetType() != cmTarget::SHARED_LIBRARY && - target->GetType() != cmTarget::MODULE_LIBRARY) - { - cmOStringStream e; - e << "TARGETS given target \"" << (*targetIt) - << "\" which is not an executable, library, or module."; - this->SetError(e.str().c_str()); - return false; - } - // Store the target in the list to be installed. - targets.push_back(target); - } - else + // Lookup this target in the current directory. + if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str())) + { + // Found the target. Check its type. + if(target->GetType() != cmTarget::EXECUTABLE && + target->GetType() != cmTarget::STATIC_LIBRARY && + target->GetType() != cmTarget::SHARED_LIBRARY && + target->GetType() != cmTarget::MODULE_LIBRARY) { - // Did not find the target. cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) - << "\" which does not exist in this directory."; + << "\" which is not an executable, library, or module."; this->SetError(e.str().c_str()); return false; } + // Store the target in the list to be installed. + targets.push_back(target); + } + else + { + // Did not find the target. + cmOStringStream e; + e << "TARGETS given target \"" << (*targetIt) + << "\" which does not exist in this directory."; + this->SetError(e.str().c_str()); + return false; + } } // Keep track of whether we will be performing an installation of @@ -602,98 +602,98 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) break; } - // These well-known sets of files are installed *automatically* for FRAMEWORK - // SHARED library targets on the Mac as part of installing the FRAMEWORK. - // For other target types or on other platforms, they are not installed - // automatically and so we need to create install files generators for them. - // - bool createInstallGeneratorsForTargetFileSets = true; - - if(target.IsFrameworkOnApple()) - { - createInstallGeneratorsForTargetFileSets = false; - } + // These well-known sets of files are installed *automatically* for + // FRAMEWORK SHARED library targets on the Mac as part of installing the + // FRAMEWORK. For other target types or on other platforms, they are not + // installed automatically and so we need to create install files + // generators for them. + bool createInstallGeneratorsForTargetFileSets = true; - if(createInstallGeneratorsForTargetFileSets && !namelinkOnly) - { - const char* files = target.GetProperty("PRIVATE_HEADER"); - if ((files) && (*files)) + if(target.IsFrameworkOnApple()) { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - std::vector<std::string> absFiles; - if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) - { - return false; - } - - // Create the files install generator. - if (!privateHeaderArgs.GetDestination().empty()) - { - privateHeaderGenerator = CreateInstallFilesGenerator(absFiles, - privateHeaderArgs, false); - } - else - { - cmOStringStream e; - e << "INSTALL TARGETS - target " << target.GetName() << " has " - << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION."; - cmSystemTools::Message(e.str().c_str(), "Warning"); - } + createInstallGeneratorsForTargetFileSets = false; } - files = target.GetProperty("PUBLIC_HEADER"); - if ((files) && (*files)) + if(createInstallGeneratorsForTargetFileSets && !namelinkOnly) { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - std::vector<std::string> absFiles; - if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) + const char* files = target.GetProperty("PRIVATE_HEADER"); + if ((files) && (*files)) { - return false; - } + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) + { + return false; + } - // Create the files install generator. - if (!publicHeaderArgs.GetDestination().empty()) - { - publicHeaderGenerator = CreateInstallFilesGenerator(absFiles, - publicHeaderArgs, false); - } - else - { - cmOStringStream e; - e << "INSTALL TARGETS - target " << target.GetName() << " has " - << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION."; - cmSystemTools::Message(e.str().c_str(), "Warning"); + // Create the files install generator. + if (!privateHeaderArgs.GetDestination().empty()) + { + privateHeaderGenerator = + CreateInstallFilesGenerator(absFiles, privateHeaderArgs, false); + } + else + { + cmOStringStream e; + e << "INSTALL TARGETS - target " << target.GetName() << " has " + << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION."; + cmSystemTools::Message(e.str().c_str(), "Warning"); + } } - } - files = target.GetProperty("RESOURCE"); - if ((files) && (*files)) - { - std::vector<std::string> relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); - std::vector<std::string> absFiles; - if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) + files = target.GetProperty("PUBLIC_HEADER"); + if ((files) && (*files)) { - return false; - } + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) + { + return false; + } - // Create the files install generator. - if (!resourceArgs.GetDestination().empty()) - { - resourceGenerator = CreateInstallFilesGenerator(absFiles, - resourceArgs, false); + // Create the files install generator. + if (!publicHeaderArgs.GetDestination().empty()) + { + publicHeaderGenerator = + CreateInstallFilesGenerator(absFiles, publicHeaderArgs, false); + } + else + { + cmOStringStream e; + e << "INSTALL TARGETS - target " << target.GetName() << " has " + << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION."; + cmSystemTools::Message(e.str().c_str(), "Warning"); + } } - else + + files = target.GetProperty("RESOURCE"); + if ((files) && (*files)) { - cmOStringStream e; - e << "INSTALL TARGETS - target " << target.GetName() << " has " - << "RESOURCE files but no RESOURCE DESTINATION."; - cmSystemTools::Message(e.str().c_str(), "Warning"); + std::vector<std::string> relFiles; + cmSystemTools::ExpandListArgument(files, relFiles); + std::vector<std::string> absFiles; + if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) + { + return false; + } + + // Create the files install generator. + if (!resourceArgs.GetDestination().empty()) + { + resourceGenerator = CreateInstallFilesGenerator(absFiles, + resourceArgs, false); + } + else + { + cmOStringStream e; + e << "INSTALL TARGETS - target " << target.GetName() << " has " + << "RESOURCE files but no RESOURCE DESTINATION."; + cmSystemTools::Message(e.str().c_str(), "Warning"); + } } } - } // Keep track of whether we're installing anything in each category installsArchive = installsArchive || archiveGenerator != 0; diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index 8f62322..377b43a 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -168,9 +168,7 @@ public: "On non-DLL platforms mySharedLib will be installed to <prefix>/lib " "and /some/full/path. On DLL platforms the mySharedLib DLL will be " "installed to <prefix>/bin and /some/full/path and its import library " - "will be installed to <prefix>/lib/static and /some/full/path. " - "On non-DLL platforms mySharedLib will be installed to <prefix>/lib " - "and /some/full/path." + "will be installed to <prefix>/lib/static and /some/full/path." "\n" "The EXPORT option associates the installed target files with an " "export called <export-name>. " diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7939d73..fdf5b31 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1937,7 +1937,7 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) cmTarget& target = it->second; target.SetType(type, name); target.SetMakefile(this); - this->LocalGenerator->GetGlobalGenerator()->AddTarget(*it); + this->LocalGenerator->GetGlobalGenerator()->AddTarget(&it->second); return &it->second; } @@ -3894,7 +3894,8 @@ void cmMakefile::DefineProperties(cmake *cm) //---------------------------------------------------------------------------- cmTarget* -cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type) +cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, + bool global) { // Create the target. cmsys::auto_ptr<cmTarget> target(new cmTarget); @@ -3904,6 +3905,10 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type) // Add to the set of available imported targets. this->ImportedTargets[name] = target.get(); + if(global) + { + this->LocalGenerator->GetGlobalGenerator()->AddTarget(target.get()); + } // Transfer ownership to this cmMakefile object. this->ImportedTargetsOwned.push_back(target.get()); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1236787..1c46a73 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -203,7 +203,8 @@ public: void RemoveDefineFlag(const char* definition); /** Create a new imported target with the name and type given. */ - cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type); + cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type, + bool global); cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6a937b8..1a68cee 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -323,7 +323,8 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_CONFIGURATIONS", cmProperty::TARGET, "Configurations provided for an IMPORTED target.", - "Lists configuration names available for an IMPORTED target. " + "Set this to the list of configuration names available for an " + "IMPORTED target. " "The names correspond to configurations defined in the project from " "which the target is imported. " "If the importing project uses a different set of configurations " @@ -334,14 +335,12 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_IMPLIB", cmProperty::TARGET, "Full path to the import library for an IMPORTED target.", - "Specifies the location of the \".lib\" part of a windows DLL. " + "Set this to the location of the \".lib\" part of a windows DLL. " "Ignored for non-imported targets."); cm->DefineProperty ("IMPORTED_IMPLIB_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_IMPLIB property.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_IMPLIB property.", "Configuration names correspond to those provided by the project " "from which the target is imported."); @@ -351,8 +350,10 @@ void cmTarget::DefineProperties(cmake *cm) "Shared libraries may be linked to other shared libraries as part " "of their implementation. On some platforms the linker searches " "for the dependent libraries of shared libraries they are including " - "in the link. This property lists " - "the dependent shared libraries of an imported library. The list " + "in the link. " + "Set this property to the list of dependent shared libraries of an " + "imported library. " + "The list " "should be disjoint from the list of interface libraries in the " "IMPORTED_LINK_INTERFACE_LIBRARIES property. On platforms requiring " "dependent shared libraries to be found at link time CMake uses this " @@ -361,9 +362,7 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_LINK_DEPENDENT_LIBRARIES_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_LINK_DEPENDENT_LIBRARIES.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_LINK_DEPENDENT_LIBRARIES.", "Configuration names correspond to those provided by the project " "from which the target is imported. " "If set, this property completely overrides the generic property " @@ -372,8 +371,8 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, "Transitive link interface of an IMPORTED target.", - "Lists libraries whose interface is included when an IMPORTED library " - "target is linked to another target. " + "Set this to the list of libraries whose interface is included when " + "an IMPORTED library target is linked to another target. " "The libraries will be included on the link line for the target. " "Unlike the LINK_INTERFACE_LIBRARIES property, this property applies " "to all imported target types, including STATIC libraries. " @@ -381,9 +380,7 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LIBRARIES_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_LINK_INTERFACE_LIBRARIES.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LIBRARIES.", "Configuration names correspond to those provided by the project " "from which the target is imported. " "If set, this property completely overrides the generic property " @@ -392,8 +389,8 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LANGUAGES", cmProperty::TARGET, "Languages compiled into an IMPORTED static library.", - "Lists languages of soure files compiled to produce a STATIC IMPORTED " - "library (such as \"C\" or \"CXX\"). " + "Set this to the list of languages of source files compiled to " + "produce a STATIC IMPORTED library (such as \"C\" or \"CXX\"). " "CMake accounts for these languages when computing how to link a " "target to the imported library. " "For example, when a C executable links to an imported C++ static " @@ -405,9 +402,7 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LANGUAGES_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_LINK_INTERFACE_LANGUAGES.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_LANGUAGES.", "Configuration names correspond to those provided by the project " "from which the target is imported. " "If set, this property completely overrides the generic property " @@ -419,16 +414,14 @@ void cmTarget::DefineProperties(cmake *cm) "This is LINK_INTERFACE_MULTIPLICITY for IMPORTED targets."); cm->DefineProperty ("IMPORTED_LINK_INTERFACE_MULTIPLICITY_<CONFIG>", cmProperty::TARGET, - "Per-configuration repetition count for cycles of IMPORTED archives.", - "This is the configuration-specific version of " - "IMPORTED_LINK_INTERFACE_MULTIPLICITY. " + "<CONFIG>-specific version of IMPORTED_LINK_INTERFACE_MULTIPLICITY.", "If set, this property completely overrides the generic property " "for the named configuration."); cm->DefineProperty ("IMPORTED_LOCATION", cmProperty::TARGET, "Full path to the main file on disk for an IMPORTED target.", - "Specifies the location of an IMPORTED target file on disk. " + "Set this to the location of an IMPORTED target file on disk. " "For executables this is the location of the executable file. " "For bundles on OS X this is the location of the executable file " "inside Contents/MacOS under the application bundle folder. " @@ -440,28 +433,29 @@ void cmTarget::DefineProperties(cmake *cm) "symlink just inside the framework folder. " "For DLLs this is the location of the \".dll\" part of the library. " "For UNKNOWN libraries this is the location of the file to be linked. " - "Ignored for non-imported targets."); + "Ignored for non-imported targets." + "\n" + "Projects may skip IMPORTED_LOCATION if the configuration-specific " + "property IMPORTED_LOCATION_<CONFIG> is set. " + "To get the location of an imported target read one of the " + "LOCATION or LOCATION_<CONFIG> properties."); cm->DefineProperty ("IMPORTED_LOCATION_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_LOCATION property.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_LOCATION property.", "Configuration names correspond to those provided by the project " "from which the target is imported."); cm->DefineProperty ("IMPORTED_SONAME", cmProperty::TARGET, "The \"soname\" of an IMPORTED target of shared library type.", - "Specifies the \"soname\" embedded in an imported shared library. " + "Set this to the \"soname\" embedded in an imported shared library. " "This is meaningful only on platforms supporting the feature. " "Ignored for non-imported targets."); cm->DefineProperty ("IMPORTED_SONAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_SONAME property.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_SONAME property.", "Configuration names correspond to those provided by the project " "from which the target is imported."); @@ -477,9 +471,7 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("IMPORTED_NO_SONAME_<CONFIG>", cmProperty::TARGET, - "Per-configuration version of IMPORTED_NO_SONAME property.", - "This property is used when loading settings for the <CONFIG> " - "configuration of an imported target. " + "<CONFIG>-specific version of IMPORTED_NO_SONAME property.", "Configuration names correspond to those provided by the project " "from which the target is imported."); @@ -685,8 +677,8 @@ void cmTarget::DefineProperties(cmake *cm) cm->DefineProperty ("MAP_IMPORTED_CONFIG_<CONFIG>", cmProperty::TARGET, "Map from project configuration to IMPORTED target's configuration.", - "List configurations of an imported target that may be used for " - "the current project's <CONFIG> configuration. " + "Set this to the list of configurations of an imported target that " + "may be used for the current project's <CONFIG> configuration. " "Targets imported from another project may not provide the same set " "of configuration names available in the current project. " "Setting this property tells CMake what imported configurations are " diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a219ae9..449adc1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1490,7 +1490,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& imLib += targetNameImport; linkOptions.AddFlag("ImportLibrary", imLib.c_str()); - linkOptions.AddFlag("ProgramDataBaseFileName", pdb.c_str()); + linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str()); linkOptions.Parse(flags.c_str()); if(!this->ModuleDefinitionFile.empty()) { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d691f46..c0c73d6 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2204,8 +2204,11 @@ int cmake::ActualConfigure() std::string installedCompiler; // Try to find the newest VS installed on the computer and // use that as a default if -G is not specified - std::string vsregBase = - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\"; + const std::string vsregBase = + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"; + std::vector<std::string> vsVerions; + vsVerions.push_back("VisualStudio\\"); + vsVerions.push_back("VCExpress\\"); struct VSRegistryEntryName { const char* MSVersion; @@ -2219,14 +2222,18 @@ int cmake::ActualConfigure() {"9.0", "Visual Studio 9 2008"}, {"10.0", "Visual Studio 10"}, {0, 0}}; - for(int i =0; version[i].MSVersion != 0; i++) + for(size_t b=0; b < vsVerions.size() && installedCompiler.empty(); b++) { - std::string reg = vsregBase + version[i].MSVersion; - reg += ";InstallDir]"; - cmSystemTools::ExpandRegistryValues(reg); - if (!(reg == "/registry")) + for(int i =0; version[i].MSVersion != 0; i++) { - installedCompiler = version[i].GeneratorName; + std::string reg = vsregBase + vsVerions[b] + version[i].MSVersion; + reg += ";InstallDir]"; + cmSystemTools::ExpandRegistryValues(reg, + cmSystemTools::KeyWOW64_32); + if (!(reg == "/registry")) + { + installedCompiler = version[i].GeneratorName; + } } } cmGlobalGenerator* gen diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 39d8a79..2cbfe26 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2012) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 01) +SET(KWSYS_DATE_STAMP_MONTH 02) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 13) +SET(KWSYS_DATE_STAMP_DAY 07) diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt index 6209c8f..8f24afe 100644 --- a/Tests/BundleUtilities/CMakeLists.txt +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -82,3 +82,52 @@ add_custom_target(testbundleutils2_test ALL DEPENDS testbundleutils1 module2 ) add_dependencies(testbundleutils2_test testbundleutils2) + + +if(APPLE AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS 9.0) +###### Test a Bundle application using dependencies +###### and @rpaths on Mac OS X 10.5 or greater + + # a shared library + add_library(shared-3 SHARED shared.cpp shared.h) + + # another shared library + add_library(shared2-3 SHARED shared2.cpp shared2.h) + + # a framework library + add_library(framework-3 SHARED framework.cpp framework.h) + set_target_properties(framework-3 PROPERTIES FRAMEWORK 1) + + # build dependencies with @rpath install name + set_target_properties(shared-3 shared2-3 framework-3 PROPERTIES + INSTALL_NAME_DIR "@rpath" + BUILD_WITH_INSTALL_RPATH 1) + + # a loadable module (depends on shared2) + # testbundleutils1 will load this at runtime + add_library(module3 MODULE module.cpp module.h) + set_target_properties(module3 PROPERTIES PREFIX "" LINK_FLAGS "-Wl,-rpath,@loader_path/") + get_target_property(module_loc module3 LOCATION) + target_link_libraries(module3 shared2-3) + + # a non-bundle application + add_executable(testbundleutils3 testbundleutils3.cpp) + target_link_libraries(testbundleutils3 shared-3 framework-3 ${CMAKE_DL_LIBS}) + get_target_property(loc testbundleutils3 LOCATION) + + set_target_properties(testbundleutils3 module3 PROPERTIES + LINK_FLAGS "-Wl,-rpath,@loader_path/") + + # add custom target to install and test the app + add_custom_target(testbundleutils3_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir3" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils3 module3 + ) + + add_dependencies(testbundleutils3_test testbundleutils3) +endif() diff --git a/Tests/BundleUtilities/testbundleutils3.cpp b/Tests/BundleUtilities/testbundleutils3.cpp new file mode 100644 index 0000000..9df13e9 --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils3.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include <windows.h> +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module3.dll"); + if(!lib) + { + printf("Failed to open module3\n"); + } +#else + void* lib = dlopen("module3.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module3\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depC.cpp b/Tests/CMakeCommands/target_link_libraries/depC.cpp index 93410a8..60bed59 100644 --- a/Tests/CMakeCommands/target_link_libraries/depC.cpp +++ b/Tests/CMakeCommands/target_link_libraries/depC.cpp @@ -10,4 +10,4 @@ DepA DepC::getA() { DepA a; return a; -}
\ No newline at end of file +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 00c9ac7..2c5acd9 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -47,6 +47,7 @@ IF(BUILD_TESTING) ENDIF() ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(CMakeOnly) ADD_SUBDIRECTORY(FindPackageModeMakefileTest) @@ -240,8 +241,6 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) - ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag) - ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt new file mode 100644 index 0000000..127e9d7 --- /dev/null +++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required (VERSION 2.8) +project(AllFindModules) + +if (POLICY CMP0017) + cmake_policy(SET CMP0017 NEW) +endif () + +# Avoid ctest truncation of output +message(STATUS "CTEST_FULL_OUTPUT") + +file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" ) + +macro(do_find MODULE_NAME) + message(STATUS " Checking Find${MODULE_NAME}") + find_package(${MODULE_NAME}) +endmacro(do_find) + +# It is only possible to use either Qt3 or Qt4 in one project. +# Since FindQt will complain if both are found we explicitely +# filter out this and FindQt3. FindKDE3 also depends on Qt3 and +# is therefore also blocked +set(NO_QT4_MODULES "Qt3" "KDE3") + +# These modules are named Find*.cmake, but are nothing that works in +# find_package(). +set(NO_FIND_MODULES "PackageHandleStandardArgs" "PackageMessage") + +set(DESIRED_QT_VERSION 4) +foreach(FIND_MODULE ${FIND_MODULES}) + string(REGEX REPLACE ".*/Find(.*)\\.cmake$" "\\1" MODULE_NAME "${FIND_MODULE}") + + list(FIND NO_QT4_MODULES ${MODULE_NAME} NO_QT4_INDEX) + list(FIND NO_FIND_MODULES ${MODULE_NAME} NO_FIND_INDEX) + if (NO_QT4_INDEX EQUAL -1 AND NO_FIND_INDEX EQUAL -1) + do_find(${MODULE_NAME}) + endif () + +endforeach(FIND_MODULE) + +# Qt4 is not present, so we can check Qt3 +if (NOT QT4_FOUND) + set(DESIRED_QT_VERSION 3) + foreach(FIND_MODULE ${NO_QT4_MODULES} "Qt") + do_find(${FIND_MODULE}) + endforeach(FIND_MODULE) +endif (NOT QT4_FOUND) + +# If any of these modules reported that it was found a version number should have been +# reported. +set(VERSIONS_REQUIRED + ALSA BISON BZIP2 CUPS CURL DOXYGEN EXPAT FLEX GETTEXT GIF GIT GNUPLOT + ImageMagick JASPER LibArchive LIBXML2 PERL PostgreSQL SWIG TIFF ZLIB) + +foreach(VTEST ${VERSIONS_REQUIRED}) + if (${VTEST}_FOUND) + if (DEFINED ${VTEST}_VERSION_STRING) + if (NOT ${VTEST}_VERSION_STRING MATCHES "^[0-9][0-9\\.]*[A-Za-z_]*[0-9\\.]*$") + message(SEND_ERROR "${VTEST}_VERSION_STRING has unexpected content ${${VTEST}_VERSION_STRING}") + endif() + elseif (DEFINED ${VTEST}_VERSION) + if (NOT ${VTEST}_VERSION MATCHES "^[0-9][0-9\\.]*[A-Za-z_]*[0-9\\.]*$") + message(SEND_ERROR "${VTEST}_VERSION has unexpected content ${${VTEST}_VERSION}") + endif() + else() + message(SEND_ERROR "${VTEST}_FOUND is set but no version number is defined") + endif() + endif(${VTEST}_FOUND) +endforeach(VTEST) diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt new file mode 100644 index 0000000..33c426a --- /dev/null +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -0,0 +1,22 @@ +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Test.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake @ONLY) + +macro(add_CMakeOnly_test test) + add_test(CMakeOnly.${test} ${CMAKE_CMAKE_COMMAND} + -DTEST=${test} + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) +endmacro() + +add_CMakeOnly_test(LinkInterfaceLoop) +set_property(TEST CMakeOnly.LinkInterfaceLoop PROPERTY TIMEOUT 90) + +add_CMakeOnly_test(CheckSymbolExists) + +add_CMakeOnly_test(CheckCXXSymbolExists) + +add_CMakeOnly_test(CheckCXXCompilerFlag) + +add_CMakeOnly_test(AllFindModules) + +add_CMakeOnly_test(TargetScope) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt index 77f5006..e205330 100644 --- a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt @@ -56,19 +56,3 @@ if(CMAKE_COMPILER_IS_GNUCXX) else() message("Unhandled Platform") endif() - -# -# This is a no-op executable... If this test is going to fail, it fails during -# the configure step while cmake is configuring this CMakeLists.txt file... -# - -file(WRITE - "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" - "int main() { return 0; } -" -) - -add_executable( - CheckCXXCompilerFlag - "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" -) diff --git a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt new file mode 100644 index 0000000..1c978c1 --- /dev/null +++ b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt @@ -0,0 +1,62 @@ +# This test will verify if CheckCXXSymbolExists only report symbols available +# for linking that really are. You can find some documentation on this in +# bug 11333 where we found out that gcc would optimize out the actual +# reference to the symbol, so symbols that are in fact _not_ available in the +# given libraries (but seen in header) were reported as present. +# +# If you change this test do not forget to change the CheckSymbolExists +# test, too. + +PROJECT(CheckCXXSymbolExists CXX) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + +SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../CheckSymbolExists") + +INCLUDE(CheckCXXSymbolExists) + +foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) + unset(CSE_RESULT_${_config_type} CACHE) + MESSAGE(STATUS "Testing configuration ${_config_type}") + check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type}) + + IF (CSE_RESULT_${_config_type}) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}") + ENDIF (CSE_RESULT_${_config_type}) +endforeach() + +set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) +unset(CSE_RESULT_ERRNO_CERRNO CACHE) + +MESSAGE(STATUS "Checking <cerrno>") + +check_cxx_symbol_exists(errno "cerrno" CSE_RESULT_ERRNO_CERRNO) + +IF (NOT CSE_RESULT_ERRNO_CERRNO) + unset(CSE_RESULT_ERRNO_ERRNOH CACHE) + + MESSAGE(STATUS "Checking <errno.h>") + + check_cxx_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO_ERRNOH) + + IF (NOT CSE_RESULT_ERRNO_ERRNOH) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists did not find errno in <cerrno> and <errno.h>") + ELSE (NOT CSE_RESULT_ERRNO_ERRNOH) + MESSAGE(STATUS "errno found in <errno.h>") + ENDIF (NOT CSE_RESULT_ERRNO_ERRNOH) +ELSE (NOT CSE_RESULT_ERRNO_CERRNO) + MESSAGE(STATUS "errno found in <cerrno>") +ENDIF (NOT CSE_RESULT_ERRNO_CERRNO) + +IF (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") + unset(CSE_RESULT_O3 CACHE) + MESSAGE(STATUS "Testing with optimization -O3") + + check_cxx_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3) + + IF (CSE_RESULT_O3) + MESSAGE(SEND_ERROR "CheckCXXSymbolExists reported a nonexistent symbol as existing with optimization -O3") + ENDIF (CSE_RESULT_O3) +ENDIF (CMAKE_COMPILER_IS_GNUCXX) diff --git a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt new file mode 100644 index 0000000..7c969d3 --- /dev/null +++ b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt @@ -0,0 +1,51 @@ +# This test will verify if CheckSymbolExists only report symbols available +# for linking that really are. You can find some documentation on this in +# bug 11333 where we found out that gcc would optimize out the actual +# reference to the symbol, so symbols that are in fact _not_ available in the +# given libraries (but seen in header) were reported as present. +# +# If you change this test do not forget to change the CheckCXXSymbolExists +# test, too. + +PROJECT(CheckSymbolExists C) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) + +SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}") + +INCLUDE(CheckSymbolExists) + +foreach(_config_type Release RelWithDebInfo MinSizeRel Debug) + set(CMAKE_TRY_COMPILE_CONFIGURATION ${_config_type}) + unset(CSE_RESULT_${_config_type} CACHE) + MESSAGE(STATUS "Testing configuration ${_config_type}") + + check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_${_config_type}) + + IF (CSE_RESULT_${_config_type}) + MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing in configuration ${_config_type}") + ENDIF (CSE_RESULT_${_config_type}) +endforeach() + +set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE}) +unset(CSE_RESULT_ERRNO CACHE) + +check_symbol_exists(errno "errno.h" CSE_RESULT_ERRNO) + +IF (NOT CSE_RESULT_ERRNO) + MESSAGE(SEND_ERROR "CheckSymbolExists did not find errno in <errno.h>") +ELSE (NOT CSE_RESULT_ERRNO) + MESSAGE(STATUS "errno found as expected") +ENDIF (NOT CSE_RESULT_ERRNO) + +IF (CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") + unset(CSE_RESULT_O3 CACHE) + MESSAGE(STATUS "Testing with optimization -O3") + + check_symbol_exists(non_existent_function_for_symbol_test "cm_cse.h" CSE_RESULT_O3) + + IF (CSE_RESULT_O3) + MESSAGE(SEND_ERROR "CheckSymbolExists reported a nonexistent symbol as existing with optimization -O3") + ENDIF (CSE_RESULT_O3) +ENDIF (CMAKE_COMPILER_IS_GNUCC) diff --git a/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h b/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h new file mode 100644 index 0000000..4f41c76 --- /dev/null +++ b/Tests/CMakeOnly/CheckSymbolExists/cm_cse.h @@ -0,0 +1,6 @@ +#ifndef _CSE_DUMMY_H +#define _CSE_DUMMY_H + +int non_existent_function_for_symbol_test(); + +#endif diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt new file mode 100644 index 0000000..56e449a --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required (VERSION 2.8) +project(LinkInterfaceLoop C) + +# Add a shared library that incorrectly names itself as a +# dependency, thus forming a cycle. +add_library(A SHARED IMPORTED) +set_target_properties(A PROPERTIES + IMPORTED_LINK_DEPENDENT_LIBRARIES A + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dirA/A" + ) + +# Add a shared library that incorrectly names itself in +# its link interface, thus forming a cycle. +add_library(B SHARED IMPORTED) +set_target_properties(B PROPERTIES + IMPORTED_LINK_INTERFACE_LIBRARIES B + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/dirB/B" + ) + +# Add a shared library with an empty link interface +# that depends on two shared libraries. +add_library(C SHARED lib.c) +set_property(TARGET C PROPERTY LINK_INTERFACE_LIBRARIES "") +target_link_libraries(C B A) + +add_executable(main main.c) +target_link_libraries(main C) diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/lib.c b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c new file mode 100644 index 0000000..fede1d6 --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/lib.c @@ -0,0 +1 @@ +int lib(void) { return 0; } diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/main.c b/Tests/CMakeOnly/LinkInterfaceLoop/main.c new file mode 100644 index 0000000..78f2de1 --- /dev/null +++ b/Tests/CMakeOnly/LinkInterfaceLoop/main.c @@ -0,0 +1 @@ +int main(void) { return 0; } diff --git a/Tests/CMakeOnly/TargetScope/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/CMakeLists.txt new file mode 100644 index 0000000..fa5d8e2 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.8) +project(TargetScope NONE) + +add_subdirectory(Sub) + +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in top directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in top directory") +endif() + +add_subdirectory(Sib) diff --git a/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt new file mode 100644 index 0000000..7f6f4e8 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sib/CMakeLists.txt @@ -0,0 +1,6 @@ +if(TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal visible in sibling directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in sibling directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt new file mode 100644 index 0000000..27318f5 --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(SubLibLocal UNKNOWN IMPORTED) +add_library(SubLibGlobal UNKNOWN IMPORTED GLOBAL) +add_subdirectory(Sub) +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in own directory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in own directory") +endif() diff --git a/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt new file mode 100644 index 0000000..a351daa --- /dev/null +++ b/Tests/CMakeOnly/TargetScope/Sub/Sub/CMakeLists.txt @@ -0,0 +1,6 @@ +if(NOT TARGET SubLibLocal) + message(FATAL_ERROR "SubLibLocal not visible in subdirectory") +endif() +if(NOT TARGET SubLibGlobal) + message(FATAL_ERROR "SubLibGlobal not visible in subdirectory") +endif() diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in new file mode 100644 index 0000000..aa2d093 --- /dev/null +++ b/Tests/CMakeOnly/Test.cmake.in @@ -0,0 +1,12 @@ +set(source_dir "@CMAKE_CURRENT_SOURCE_DIR@/${TEST}") +set(binary_dir "@CMAKE_CURRENT_BINARY_DIR@/${TEST}-build") +file(REMOVE_RECURSE "${binary_dir}") +file(MAKE_DIRECTORY "${binary_dir}") +execute_process( + COMMAND ${CMAKE_COMMAND} "${source_dir}" -G "@CMAKE_TEST_GENERATOR@" + WORKING_DIRECTORY "${binary_dir}" + RESULT_VARIABLE result + ) +if(result) + message(FATAL_ERROR "CMake failed to configure ${TEST}") +endif() diff --git a/Tests/CMakeTests/If-Invalid-Argument.cmake b/Tests/CMakeTests/If-Invalid-Argument.cmake new file mode 100644 index 0000000..b4fb97f --- /dev/null +++ b/Tests/CMakeTests/If-Invalid-Argument.cmake @@ -0,0 +1,2 @@ +if (NOT foo bar STREQUAL "foo bar") +endif() diff --git a/Tests/CMakeTests/IfTest.cmake.in b/Tests/CMakeTests/IfTest.cmake.in index e5211b4..639e226 100644 --- a/Tests/CMakeTests/IfTest.cmake.in +++ b/Tests/CMakeTests/IfTest.cmake.in @@ -156,3 +156,11 @@ foreach(_bad 2x -2x) endforeach() test_vars("") + +set(Invalid-Argument-RESULT 1) +set(Invalid-Argument-STDERR ".*CMake Error at (@CMAKE_CURRENT_SOURCE_DIR@/)?If-Invalid-Argument.cmake:1 \\(if\\):.*Unknown arguments specified.*") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(If + Invalid-Argument +) diff --git a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt index 953d05c..5cdbc59b 100644 --- a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt @@ -5,9 +5,6 @@ IF (MUDSLIDE_TYPE MATCHES MUCHO) ADD_DEFINITIONS(-DMUCHO_MUDSLIDE) ENDIF (MUDSLIDE_TYPE MATCHES MUCHO) -IF(WATCOM) - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -ENDIF(WATCOM) INCLUDE_DIRECTORIES(${CMAKE_ROOT}/include ${CMAKE_ROOT}/Source) ADD_LIBRARY(cmCMAKE_TEST_COMMAND MODULE cmTestCommand.c) diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index e99105a..846cbb0 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -12,12 +12,6 @@ INCLUDE (CheckFunctionExists) CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF) CHECK_FUNCTION_EXISTS(vsblabla HAVE_VSBLABLA) -INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) -CHECK_INCLUDE_FILE("sys/prctl.h" HAVE_SYS_PRCTL_H) - -INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake) -CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM) - CONFIGURE_FILE(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in ${LoadCommand_BINARY_DIR}/LoadedCommand.h) diff --git a/Tests/LoadCommand/LoadedCommand.h.in b/Tests/LoadCommand/LoadedCommand.h.in index 7a0a15d..7516a66 100644 --- a/Tests/LoadCommand/LoadedCommand.h.in +++ b/Tests/LoadCommand/LoadedCommand.h.in @@ -5,9 +5,3 @@ /* Check for functions */ #cmakedefine HAVE_PRINTF #cmakedefine HAVE_VSBLABLA - -/* Check for headers */ -#cmakedefine HAVE_SYS_PRCTL_H - -/* Check for libraries */ -#cmakedefine HAVE_LIBM diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp index 445a652..eec46d3 100644 --- a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp @@ -6,4 +6,4 @@ int main(int, char**) SomeClass sc; sc.someMethod(); return 0; -}
\ No newline at end of file +} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp index 445a652..eec46d3 100644 --- a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -6,4 +6,4 @@ int main(int, char**) SomeClass sc; sc.someMethod(); return 0; -}
\ No newline at end of file +} diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp index 7326b78..427ec29 100644 --- a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -4,4 +4,4 @@ void SomeClass::someMethod() const { -}
\ No newline at end of file +} diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp index d04ae3c..507f6fd 100644 --- a/Tests/Module/GenerateExportHeader/prefix/main.cpp +++ b/Tests/Module/GenerateExportHeader/prefix/main.cpp @@ -5,4 +5,4 @@ int main(int argc, char **argv) { UsePrefixClass upc; return upc.someMethod(); -}
\ No newline at end of file +} diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp index 8337ab8..1fd2cb2 100644 --- a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp @@ -4,4 +4,4 @@ int UsePrefixClass::someMethod() const { return 0; -}
\ No newline at end of file +} diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index 1055d07..90ae20a 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -17,6 +17,10 @@ CMAKE_CXX_COMPILER == "${CMAKE_CXX_COMPILER}" CMAKE_C_COMPILER == "${CMAKE_C_COMPILER}" CMAKE_COMPILER_IS_GNUCC == "${CMAKE_COMPILER_IS_GNUCC}" CMAKE_COMPILER_IS_GNUCXX == "${CMAKE_COMPILER_IS_GNUCXX}" +CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}" +CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}" +CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}" +CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}" // C shared library flag CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}" diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 115181d..3e6b049 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -5,14 +5,14 @@ set(INSTALL_PREFIX /) set(HOST dashmacmini2) set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j2") -set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") +set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL=TRUE -QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Software/QtBinUniversal/bin/qmake +QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.8.0/install/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake) diff --git a/Utilities/cmThirdParty.h.in b/Utilities/cmThirdParty.h.in index daf8114..c824085 100644 --- a/Utilities/cmThirdParty.h.in +++ b/Utilities/cmThirdParty.h.in @@ -16,6 +16,7 @@ #cmakedefine CMAKE_USE_SYSTEM_CURL #cmakedefine CMAKE_USE_SYSTEM_EXPAT #cmakedefine CMAKE_USE_SYSTEM_ZLIB +#cmakedefine CMAKE_USE_SYSTEM_BZIP2 #cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE #cmakedefine CTEST_USE_XMLRPC diff --git a/Utilities/cm_bzlib.h b/Utilities/cm_bzlib.h new file mode 100644 index 0000000..d1fffa1 --- /dev/null +++ b/Utilities/cm_bzlib.h @@ -0,0 +1,23 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2012 Kitware, Inc., Insight Software Consortium + + 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. +============================================================================*/ +#ifndef __cm_bzlib_h +#define __cm_bzlib_h + +/* Use the bzip2 library configured for CMake. */ +#include "cmThirdParty.h" +#ifdef CMAKE_USE_SYSTEM_BZIP2 +# include <bzlib.h> +#else +# include <cmbzip2/bzlib.h> +#endif + +#endif diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c index 8d5bd1c..af618b0 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #include "archive.h" diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c index 1580c92..2be2267 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #ifdef HAVE_LZMA_H #include <lzma.h> diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c index 00f283d..0834e6f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c +++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include <expat.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #if HAVE_LZMA_H #include <lzma.h> diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c index e0d07a9..096a6a4 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_bzip2.c @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_bzip2.c 20 #include <string.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #include "archive.h" diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c index ce3298b..5bb248c 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c @@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$"); #endif #include <stdlib.h> #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #if HAVE_LZMA_H #include <lzma.h> diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c index 0f003a8..96b7b2f 100644 --- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c +++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_xar.c @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$"); #include <libxml/xmlwriter.h> #endif #ifdef HAVE_BZLIB_H -#include <bzlib.h> +#include <cm_bzlib.h> #endif #if HAVE_LZMA_H #include <lzma.h> @@ -1,7 +1,7 @@ #!/bin/sh #============================================================================= # CMake - Cross Platform Makefile Generator -# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -11,6 +11,10 @@ # See the License for more information. #============================================================================= +die() { + echo "$@" 1>&2 ; exit 1 +} + # Version number extraction function. cmake_version_component() { @@ -292,7 +296,7 @@ KWSYS_IOS_FILES=" cmake_usage() { echo ' -Usage: '"$0"' [options] +Usage: '"$0"' [<options>...] [-- <cmake-options>...] Options: [defaults in brackets after descriptions] Configuration: --help print this message @@ -337,7 +341,7 @@ Directory and file names: # Display CMake bootstrap usage cmake_version_display() { - echo "CMake ${cmake_version}, Copyright 2000-2009 Kitware, Inc." + echo "CMake ${cmake_version}, Copyright 2000-2011 Kitware, Inc." } # Display CMake bootstrap error, display the log file and exit @@ -527,63 +531,31 @@ cmake_verbose= cmake_parallel_make= cmake_ccache_enabled= cmake_prefix_dir="${cmake_default_prefix}" -for a in "$@"; do - if echo $a | grep "^--prefix=" > /dev/null 2> /dev/null; then - cmake_prefix_dir=`echo $a | sed "s/^--prefix=//"` - cmake_prefix_dir=`cmake_fix_slashes "${cmake_prefix_dir}"` - fi - if echo $a | grep "^--parallel=" > /dev/null 2> /dev/null; then - cmake_parallel_make=`echo $a | sed "s/^--parallel=//" | grep "[0-9][0-9]*"` - fi - if echo $a | grep "^--datadir=" > /dev/null 2> /dev/null; then - cmake_data_dir=`echo $a | sed "s/^--datadir=//"` - fi - if echo $a | grep "^--docdir=" > /dev/null 2> /dev/null; then - cmake_doc_dir=`echo $a | sed "s/^--docdir=//"` - fi - if echo $a | grep "^--mandir=" > /dev/null 2> /dev/null; then - cmake_man_dir=`echo $a | sed "s/^--mandir=//"` - fi - if echo $a | grep "^--init=" > /dev/null 2> /dev/null; then - cmake_init_file=`echo $a | sed "s/^--init=//"` - fi - for lib in bzip2 curl expat libarchive zlib; do - if echo $a | grep "^--system-${lib}" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${lib}`=1" - break - elif echo $a | grep "^--no-system-${lib}" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${lib}`=0" - break - fi - done - if echo $a | grep "^--system-libs" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" - fi - if echo $a | grep "^--no-system-libs" > /dev/null 2> /dev/null; then - cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" - fi - if echo $a | grep "^--qt-gui" > /dev/null 2> /dev/null; then - cmake_bootstrap_qt_gui="1" - fi - if echo $a | grep "^--no-qt-gui" > /dev/null 2> /dev/null; then - cmake_bootstrap_qt_gui="0" - fi - if echo $a | grep "^--qt-qmake=" > /dev/null 2> /dev/null; then - cmake_bootstrap_qt_qmake=`echo $a | sed "s/^--qt-qmake=//"` - fi - if echo $a | grep "^--help" > /dev/null 2> /dev/null; then - cmake_usage - fi - if echo $a | grep "^--version" > /dev/null 2> /dev/null; then - cmake_version_display - exit 2 - fi - if echo $a | grep "^--verbose" > /dev/null 2> /dev/null; then - cmake_verbose=TRUE - fi - if echo $a | grep "^--enable-ccache" > /dev/null 2> /dev/null; then - cmake_ccache_enabled=TRUE - fi +while test $# != 0; do + case "$1" in + --prefix=*) cmake_prefix_dir=`cmake_fix_slashes "${1#*=}"` ;; + --parallel=*) cmake_parallel_make="${1#*=}" ;; + --datadir=*) cmake_data_dir="${1#*=}" ;; + --docdir=*) cmake_doc_dir="${1#*=}" ;; + --mandir=*) cmake_man_dir="${1#*=}" ;; + --init=*) cmake_init_file="${1#*=}" ;; + --system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=1" ;; + --no-system-libs) cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARIES=0" ;; + --system-bzip2|--system-curl|--system-expat|--system-libarchive|--system-zlib) + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${1#--system-}`=1" ;; + --no-system-bzip2|--no-system-curl|--no-system-expat|--no-system-libarchive|--no-system-zlib) + cmake_bootstrap_system_libs="${cmake_bootstrap_system_libs} -DCMAKE_USE_SYSTEM_LIBRARY_`cmake_toupper ${1#--no-system-}`=0" ;; + --qt-gui) cmake_bootstrap_qt_gui="1" ;; + --no-qt-gui) cmake_bootstrap_qt_gui="0" ;; + --qt-qmake=*) cmake_bootstrap_qt_qmake="${1#*=}" ;; + --help) cmake_usage ;; + --version) cmake_version_display ; exit 2 ;; + --verbose) cmake_verbose=TRUE ;; + --enable-ccache) cmake_ccache_enabled=TRUE ;; + --) shift; break ;; + *) die "Unknown option: $1" ;; + esac + shift done # If verbose, display some information about bootstrap @@ -1533,7 +1505,7 @@ cmake_options="-DCMAKE_BOOTSTRAP=1" if [ -n "${cmake_verbose}" ]; then cmake_options="${cmake_options} -DCMAKE_VERBOSE_MAKEFILE=1" fi -"${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} +"${cmake_bootstrap_dir}/cmake" "${cmake_source_dir}" "-C${cmake_bootstrap_dir}/InitialCacheFlags.cmake" "-G${cmake_bootstrap_generator}" ${cmake_options} ${cmake_bootstrap_system_libs} "$@" RES=$? if [ "${RES}" -ne "0" ]; then cmake_error 11 "Problem while running initial CMake" |