diff options
35 files changed, 457 insertions, 121 deletions
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/FindCURL.cmake b/Modules/FindCURL.cmake index 517638a..cc00d53 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -34,11 +34,16 @@ FIND_LIBRARY(CURL_LIBRARY NAMES ) MARK_AS_ADVANCED(CURL_LIBRARY) -IF(CURL_INCLUDE_DIR AND EXISTS "${CURL_INCLUDE_DIR}/curl/curlver.h") - FILE(STRINGS "${CURL_INCLUDE_DIR}/curl/curlver.h" curl_version_str REGEX "^#define[\t ]+LIBCURL_VERSION[\t ]+\".*\"") +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) + 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 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/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 48e2736..6dc7e4d 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -27,7 +27,7 @@ IF (NOT JASPER_LIBRARIES) FIND_PACKAGE(JPEG) FIND_LIBRARY(JASPER_LIBRARY_RELEASE NAMES jasper libjasper) - FIND_LIBRARY(JASPER_LIBRARY_DEBUG NAMES japserd) + FIND_LIBRARY(JASPER_LIBRARY_DEBUG NAMES jasperd) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) SELECT_LIBRARY_CONFIGURATIONS(JASPER) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index a797b12..48a5498 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -45,15 +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 REQUIRED_VARS LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR - VERSION_VAR PC_LIBXML_VERSION) - -IF(LIBXML2_FOUND) - SET(LIBXML2_VERSION_STRING ${PC_LIBXML_VERSION}) -ENDIF() + VERSION_VAR LIBXML2_VERSION_STRING) MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) 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/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 59efe4b..d1fc2d2 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -213,6 +213,37 @@ 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) if (_OPENSSL_VERSION) set(OPENSSL_VERSION "${_OPENSSL_VERSION}") @@ -231,15 +262,16 @@ if (OPENSSL_INCLUDE_DIR) "\\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(.)" "\\1" OPENSSL_VERSION_MINOR "${OPENSSL_VERSION_MINOR}") - string(REGEX REPLACE "^0(.)" "\\1" OPENSSL_VERSION_FIX "${OPENSSL_VERSION_FIX}") - 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 "${OPENSSL_VERSION_PATCH} + 96") + 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. 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/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/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index d5a2a5e..5c1d56b 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -88,8 +88,19 @@ endif() # determine python version string if(PYTHON_EXECUTABLE) - execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) - if(_VERSION MATCHES "^Python [0-9]+\\.[0-9]+.*") + 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}") @@ -97,6 +108,8 @@ if(PYTHON_EXECUTABLE) 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 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/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/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/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/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/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index edce102..b64fb43 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 26) +SET(KWSYS_DATE_STAMP_DAY 01) diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index 2209b20..33c426a 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -18,3 +18,5 @@ add_CMakeOnly_test(CheckCXXSymbolExists) add_CMakeOnly_test(CheckCXXCompilerFlag) add_CMakeOnly_test(AllFindModules) + +add_CMakeOnly_test(TargetScope) 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() |