diff options
43 files changed, 1547 insertions, 135 deletions
diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index f646e78..3da04b4 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -34,6 +34,8 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) FAIL_REGEX "[Uu]nknown option" # HP FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro FAIL_REGEX "command option .* is not recognized" # XL + FAIL_REGEX "not supported in this configuration; ignored" # AIX + FAIL_REGEX "File with unknown suffix passed to linker" # PGI ) SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") ENDMACRO (CHECK_CXX_COMPILER_FLAG) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index d07890f..d2567d5 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -35,14 +35,19 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") - # The compiler front-end passes all object files, archive files, and shared - # library files named on the command line to CreateExportList to create a - # list of all symbols to be exported from the shared library. This causes - # all archive members to be copied into the shared library whether they are - # needed or not. Instead we run the tool ourselves to pass only the object - # files so that we export only the symbols actually provided by the sources. - set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>" - "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - ) + # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones. + # If we found the tool, we'll use it to create exports, otherwise stick with the regular + # create shared library compile line. + if (CMAKE_XL_CreateExportList) + # The compiler front-end passes all object files, archive files, and shared + # library files named on the command line to CreateExportList to create a + # list of all symbols to be exported from the shared library. This causes + # all archive members to be copied into the shared library whether they are + # needed or not. Instead we run the tool ourselves to pass only the object + # files so that we export only the symbols actually provided by the sources. + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>" + "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + ) + endif() endmacro() diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index 570fb7b..885762a 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -302,7 +302,7 @@ FUNCTION(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) IF(includeThisOne) - SET(_currentFeatureText "${_currentFeatureText}\n${_currentFeature}") + SET(_currentFeatureText "${_currentFeatureText}\n * ${_currentFeature}") GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION) IF(_info) SET(_currentFeatureText "${_currentFeatureText} (required version ${_info})") diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index dc9ab37..9b76d90 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -42,6 +42,8 @@ include(CheckFunctionExists) include(CheckFortranFunctionExists) +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # Check the language being used get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) if( _LANGUAGES_ MATCHES Fortran ) @@ -89,13 +91,18 @@ foreach(_library ${_list}) if(_libraries_work) if (BLA_STATIC) if (WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif ( WIN32 ) if (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) else (APPLE) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} @@ -349,7 +356,7 @@ if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} ) if( BLAS_LIBRARIES ) break() @@ -361,7 +368,7 @@ if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") BLAS_LIBRARIES BLAS sgemm - "" "acml_mp;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} ) if( BLAS_LIBRARIES ) break() @@ -408,7 +415,7 @@ if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "Accelerate" "" @@ -421,7 +428,7 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "vecLib" "" @@ -613,3 +620,5 @@ else(BLA_F95) endif(BLAS_FOUND) endif(NOT BLAS_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index c3ac424..5ccbd6b 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -34,7 +34,7 @@ # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # -# You should provide a minimum version number that should be used. If you provide this +# You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need @@ -92,6 +92,12 @@ # BOOST_ROOT. Defaults to OFF. # [Since CMake 2.8.3] # +# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode +# before searching for a regular boost install. +# This will avoid finding boost-cmake installs. +# Defaults to OFF. +# [Since CMake 2.8.6] +# # Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries # linked against a static C++ standard library # ('s' ABI tag). This option should be set to @@ -134,7 +140,7 @@ # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] -# +# # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation @@ -164,13 +170,27 @@ # # These last three variables are available also as environment variables: -# Also, note they are completely UPPERCASE. +# Also, note they are completely UPPERCASE, except Boost_DIR. +# +# Boost_DIR or The preferred installation prefix for searching for +# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding +# the proper Boost installation. +# +# Note that Boost_DIR behaves exactly as <package>_DIR +# variables are documented to behave in find_package's +# Config mode. That is, if it is set as a -D argument +# to CMake, it must point to the location of the +# BoostConfig.cmake or Boost-config.cmake file. If it +# is set as an environment variable, it must point to +# the root of the boost installation. BOOST_ROOT and +# BOOSTROOT, on the other hand, will point to the root +# in either case. +# +# To prevent falling back on the system paths, set +# Boost_NO_SYSTEM_PATHS to true. # -# BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for -# Boost. Set this if the module has problems finding -# the proper Boost installation. To prevent falling -# back on the system paths, set Boost_NO_SYSTEM_PATHS -# to true. +# To avoid finding boost-cmake installations, set +# Boost_NO_BOOST_CMAKE to true. # # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation @@ -237,6 +257,43 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +#------------------------------------------------------------------------------- +# Before we go searching, check whether boost-cmake is avaialble, unless the +# user specifically asked NOT to search for boost-cmake. +# +# If Boost_DIR is set, this behaves as any find_package call would. If not, +# it looks at BOOST_ROOT and BOOSTROOT to find Boost. +# +if (NOT Boost_NO_BOOST_CMAKE) + # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, + # since these are more conventional for Boost. + if ("$ENV{Boost_DIR}" STREQUAL "") + if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) + elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOSTROOT}) + endif() + endif() + + # Do the same find_package call but look specifically for the CMake version. + # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no + # need to delegate them to this find_package call. + find_package(Boost QUIET NO_MODULE) + + # If we found boost-cmake, then we're done. Print out what we found. + # Otherwise let the rest of the module try to find it. + if (Boost_FOUND) + message("Boost ${Boost_FIND_VERSION} found.") + if (Boost_FIND_COMPONENTS) + message("Found Boost components:") + message(" ${Boost_FIND_COMPONENTS}") + endif() + return() + endif() +endif() + + #------------------------------------------------------------------------------- # FindBoost functions & macros # @@ -287,7 +344,7 @@ macro(_Boost_ADJUST_LIB_VARS basename) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) endif() - + if(Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") @@ -372,7 +429,7 @@ endfunction() # # End functions/macros -# +# #------------------------------------------------------------------------------- @@ -517,6 +574,11 @@ else(_boost_IN_CACHE) _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") + set(BOOST_ROOT $ENV{Boost_DIR}) + endif() + + # If BOOST_ROOT was defined in the environment, use it. if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") set(BOOST_ROOT $ENV{BOOST_ROOT}) endif() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 80fe867..bccf789 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -36,6 +36,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _LANGUAGES_ MATCHES Fortran) include(CheckFunctionExists) @@ -46,6 +48,8 @@ endif (NOT _LANGUAGES_ MATCHES Fortran) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) +# TODO: move this stuff to separate module + macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the @@ -61,38 +65,38 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) + else () + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) + endif () +endif () foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) - IF (WIN32) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS ENV LIB - ) - ENDIF (WIN32) - - if(APPLE) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib") - endif(BLA_STATIC) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRRAY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRRAY_SUFFIXES} .so.3gf) + endif () + endif (BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH - ) - else(APPLE) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") - endif(BLA_STATIC) - find_library(${_prefix}_${_library}_LIBRARY - NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH - ) - endif(APPLE) - + NAMES ${_library} + PATHS ${_libdir} + ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) @@ -165,7 +169,7 @@ endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") #acml lapack - if (BLA_VENDOR STREQUAL "ACML.*" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") if (BLAS_LIBRARIES MATCHES ".+acml.+") set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) endif () @@ -199,7 +203,9 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") endif ( NOT LAPACK_LIBRARIES ) endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") # Generic LAPACK library? -if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( LAPACK_LIBRARIES @@ -211,7 +217,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") "" ) endif ( NOT LAPACK_LIBRARIES ) -endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +endif () #intel lapack if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) @@ -297,3 +303,5 @@ else(BLA_F95) endif(LAPACK_FOUND) endif(NOT LAPACK_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index eb398b2..48d3472 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -34,6 +34,7 @@ FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. IF(NOT ${pkg}_FIND_QUIETLY) + STRING(REGEX REPLACE "[\n]" "" details "${details}") SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 46cde43..a10ec23 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -4,11 +4,17 @@ # # PYTHONINTERP_FOUND - Was the Python executable found # PYTHON_EXECUTABLE - path to the Python interpreter -# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for # +# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 +# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 +# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 +# +# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for #============================================================================= # Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks <bjoern.ricks@gmail.com> # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -20,32 +26,41 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Search for the current active python version first +find_program(PYTHON_EXECUTABLE NAMES python) + # 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) -# Run first with the Python version in the executable -foreach(_CURRENT_VERSION ${_Python_VERSIONS}) - set(_Python_NAMES python${_CURRENT_VERSION}) - if(WIN32) - list(APPEND _Python_NAMES python) - endif() - find_program(PYTHON_EXECUTABLE - NAMES ${_Python_NAMES} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] - ) -endforeach() -# Now without any version if we still haven't found it +# Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) - find_program(PYTHON_EXECUTABLE NAMES python) + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) + endforeach() 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() # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 1ebd69d..3b05c2b 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -862,10 +862,11 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) ) ENDFOREACH(QT_MODULE) - # QtUiTools not with other frameworks with binary installation (in /usr/lib) - IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + # QtUiTools is sometimes not in the same directory as the other found libraries + # e.g. on Mac, its never a framework like the others are + IF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) - ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + ENDIF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) # Set QT_QTDESIGNERCOMPONENTS_LIBRARY FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake new file mode 100644 index 0000000..4eb67b5 --- /dev/null +++ b/Modules/GenerateExportHeader.cmake @@ -0,0 +1,346 @@ +# - Function for generation of export macros for libraries +# This module provides the function GENERATE_EXPORT_HEADER() and the +# accompanying ADD_COMPILER_EXPORT_FLAGS() function. +# +# The GENERATE_EXPORT_HEADER function can be used to generate a file suitable +# for preprocessor inclusion which contains EXPORT macros to be used in +# library classes. +# +# GENERATE_EXPORT_HEADER( LIBRARY_TARGET +# [BASE_NAME <base_name>] +# [EXPORT_MACRO_NAME <export_macro_name>] +# [EXPORT_FILE_NAME <export_file_name>] +# [DEPRECATED_MACRO_NAME <deprecated_macro_name>] +# [NO_EXPORT_MACRO_NAME <no_export_macro_name>] +# [STATIC_DEFINE <static_define>] +# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>] +# [DEFINE_NO_DEPRECATED] +# [PREFIX_NAME <prefix_name>] +# ) +# +# ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) +# +# By default GENERATE_EXPORT_HEADER() generates macro names in a file name +# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS macro +# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on Windows +# which does not need extra compiler flags for exporting support. +# +# This means that in the simplest case, users of these functions will be equivalent to: +# +# add_compiler_export_flags() +# add_library(somelib someclass.cpp) +# generate_export_header(somelib) +# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) +# install(FILES +# someclass.h +# ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} +# ) +# +# And in the ABI header files: +# +# #include "somelib_export.h" +# class SOMELIB_EXPORT SomeClass { +# ... +# }; +# +# The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} called +# somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, +# SOMELIB_DEPRECATED, SOMELIB_DEPRECATED_EXPORT and SOMELIB_DEPRECATED_NO_EXPORT. +# The resulting file should be installed with other headers in the library. +# +# The BASE_NAME argument can be used to override the file name and the names +# used for the macros +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# BASE_NAME other_name +# ) +# +# Generates a file called other_name_export.h containing the macros +# OTHER_NAME_EXPORT, OTHER_NAME_NO_EXPORT and OTHER_NAME_DEPRECATED etc. +# +# The BASE_NAME may be overridden by specifiying other options in the function. +# For example: +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# EXPORT_MACRO_NAME OTHER_NAME_EXPORT +# ) +# +# creates the macro OTHER_NAME_EXPORT instead of SOMELIB_EXPORT, but other macros +# and the generated file name is as default. +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# DEPRECATED_MACRO_NAME KDE_DEPRECATED +# ) +# +# creates the macro KDE_DEPRECATED instead of SOMELIB_DEPRECATED. +# +# If LIBRARY_TARGET is a static library, macros are defined without values. +# +# If the same sources are used to create both a shared and a static library, the +# uppercased symbol ${BASE_NAME}_STATIC_DEFINE should be used when building the +# static library +# +# add_library(shared_variant SHARED ${lib_SRCS}) +# add_library(static_variant ${lib_SRCS}) +# generate_export_header(shared_variant BASE_NAME libshared_and_static) +# set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) +# +# This will cause the export macros to expand to nothing when building the static library. +# +# If DEFINE_NO_DEPRECATED is specified, then a macro ${BASE_NAME}_NO_DEPRECATED will be defined +# This macro can be used to remove deprecated code from preprocessor output. +# +# option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) +# if (EXCLUDE_DEPRECATED) +# set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) +# endif() +# generate_export_header(somelib ${NO_BUILD_DEPRECATED}) +# +# And then in somelib: +# +# class SOMELIB_EXPORT SomeClass +# { +# public: +# #ifndef SOMELIB_NO_DEPRECATED +# SOMELIB_DEPRECATED void oldMethod(); +# #endif +# }; +# +# #ifndef SOMELIB_NO_DEPRECATED +# void SomeClass::oldMethod() { } +# #endif +# +# If PREFIX_NAME is specified, the argument will be used as a prefix to all +# generated macros. +# +# For example: +# +# generate_export_header(somelib PREFIX_NAME VTK_) +# +# Generates the macros VTK_SOMELIB_EXPORT etc. + + +#============================================================================= +# Copyright 2011 Stephen Kelly <steveire@gmail.com> +# +# 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.) + +include(CMakeParseArguments) +include(CheckCXXCompilerFlag) + + +# TODO: Install this macro separately? +macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT) + check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } int main() { return somefunc();}" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "ignoring unknown option" # MSVC + FAIL_REGEX "warning D9002" # MSVC, any lang + FAIL_REGEX "[Uu]nknown option" # HP + FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro + FAIL_REGEX "command option .* is not recognized" # XL + ) +endmacro() + +macro(_test_compiler_hidden_visibility) + + if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() + + if(${_gcc_version} VERSION_LESS "4.2") + set(GCC_TOO_OLD TRUE) + message(WARNING "GCC version older than 4.2") + endif() + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") + + if(${_intel_version} VERSION_LESS "12.0") + set(_INTEL_TOO_OLD TRUE) + message(WARNING "Intel compiler older than 12.0") + endif() + endif() + + + # Exclude XL here because it misinterprets -fvisibility=hidden even though + # the check_cxx_compiler_flag passes + # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 + if (NOT GCC_TOO_OLD + AND NOT _INTEL_TOO_OLD + AND NOT WIN32 + AND NOT CYGWIN + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) + check_cxx_compiler_flag(-fvisibility-inlines-hidden COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + option(USE_COMPILER_HIDDEN_VISIBILITY "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) + endif() +endmacro() + +macro(_test_compiler_has_deprecated) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP + OR GCC_TOO_OLD + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL "Compiler support for a deprecated attribute") + else() + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED_ATTR) + if(COMPILER_HAS_DEPRECATED_ATTR) + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" CACHE INTERNAL "Compiler support for a deprecated attribute") + else() + _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED) + endif() + endif() +endmacro() + +get_filename_component(_GENERATE_EXPORT_HEADER_MODULE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + +macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) + set(DEFINE_DEPRECATED) + set(DEFINE_EXPORT) + set(DEFINE_IMPORT) + set(DEFINE_NO_EXPORT) + + if (COMPILER_HAS_DEPRECATED_ATTR) + set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + elseif(COMPILER_HAS_DEPRECATED) + set(DEFINE_DEPRECATED "__declspec(deprecated)") + endif() + + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + + if(NOT ${type} STREQUAL "STATIC_LIBRARY") + if(WIN32) + set(DEFINE_EXPORT "__declspec(dllexport)") + set(DEFINE_IMPORT "__declspec(dllimport)") + elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") + endif() + endif() +endmacro() + +macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) + # Option overrides + set(options DEFINE_NO_DEPRECATED) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE NO_DEPRECATED_MACRO_NAME) + set(multiValueArgs) + + cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(BASE_NAME "${TARGET_LIBRARY}") + + if(_GEH_BASE_NAME) + set(BASE_NAME ${_GEH_BASE_NAME}) + endif() + + string(TOUPPER ${BASE_NAME} BASE_NAME_UPPER) + string(TOLOWER ${BASE_NAME} BASE_NAME_LOWER) + + # Default options + set(EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_EXPORT") + set(NO_EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_EXPORT") + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") + set(DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_DEPRECATED") + set(STATIC_DEFINE "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_STATIC_DEFINE") + set(NO_DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_DEPRECATED") + + if(_GEH_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") + endif() + + if(_GEH_EXPORT_MACRO_NAME) + set(EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_EXPORT_MACRO_NAME}) + endif() + if(_GEH_EXPORT_FILE_NAME) + if(IS_ABSOLUTE _GEH_EXPORT_FILE_NAME) + set(EXPORT_FILE_NAME ${_GEH_EXPORT_FILE_NAME}) + else() + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_GEH_EXPORT_FILE_NAME}") + endif() + endif() + if(_GEH_DEPRECATED_MACRO_NAME) + set(DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_DEPRECATED_MACRO_NAME}) + endif() + if(_GEH_NO_EXPORT_MACRO_NAME) + set(NO_EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_EXPORT_MACRO_NAME}) + endif() + if(_GEH_STATIC_DEFINE) + set(STATIC_DEFINE ${_GEH_PREFIX_NAME}${_GEH_STATIC_DEFINE}) + endif() + + if (_GEH_DEFINE_NO_DEPRECATED) + set(DEFINE_NO_DEPRECATED TRUE) + endif() + + if (_GEH_NO_DEPRECATED_MACRO_NAME) + set(NO_DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_DEPRECATED_MACRO_NAME}) + endif() + + set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") + + get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) + + if (NOT EXPORT_IMPORT_CONDITION) + set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) + endif() + + configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" "${EXPORT_FILE_NAME}" @ONLY) +endmacro() + +function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + if(${type} STREQUAL "MODULE") + message(WARNING "This macro should not be used with libraries of type MODULE") + return() + endif() + if(NOT ${type} STREQUAL "STATIC_LIBRARY" AND NOT ${type} STREQUAL "SHARED_LIBRARY") + message(WARNING "This macro can only be used with libraries") + return() + endif() + _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() + _do_set_macro_values(${TARGET_LIBRARY}) + _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) +endfunction() + +function(add_compiler_export_flags) + + _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() + + if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) + message(WARNING "Compiler doesn't have hidden visibility") + return() + endif() + + set (EXTRA_FLAGS "-fvisibility=hidden") + + if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") + endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) +endfunction() diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index 2ca920f..926dbc0 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -85,20 +85,23 @@ set(CMAKE_DL_LIBS "dl") macro(__BlueGeneP_set_dynamic_flags compiler_id lang) if (${compiler_id} STREQUAL XL) # Flags for XL compilers if we explicitly detected XL - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") else() # Assume flags for GNU compilers (if the ID is GNU *or* anything else). - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") endif() - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty + # Both toolchains use the GNU linker on BG/P, so these options are shared. + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty set(BGP_${lang}_DEFAULT_EXE_FLAGS "<FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 869394d..b78278c 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -262,7 +262,10 @@ function(add_jar _TARGET_NAME) set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class") set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE}) - elseif (_JAVA_EXT MATCHES ".jar") + elseif (_JAVA_EXT MATCHES ".jar" + OR _JAVA_EXT MATCHES ".war" + OR _JAVA_EXT MATCHES ".ear" + OR _JAVA_EXT MATCHES ".sar") list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE}) elseif (_JAVA_EXT STREQUAL "") diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in new file mode 100644 index 0000000..131d3a7 --- /dev/null +++ b/Modules/exportheader.cmake.in @@ -0,0 +1,35 @@ + +#ifndef @INCLUDE_GUARD_NAME@ +#define @INCLUDE_GUARD_NAME@ + +#ifdef @STATIC_DEFINE@ +# define @EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ +#else +# ifndef @EXPORT_MACRO_NAME@ +# ifdef @EXPORT_IMPORT_CONDITION@ + /* We are building this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_EXPORT@ +# else + /* We are using this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_IMPORT@ +# endif +# endif + +# ifndef @NO_EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ @DEFINE_NO_EXPORT@ +# endif +#endif + +#ifndef @DEPRECATED_MACRO_NAME@ +# define @DEPRECATED_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_EXPORT @EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +#endif + +#cmakedefine01 DEFINE_NO_DEPRECATED +#if DEFINE_NO_DEPRECATED +# define @NO_DEPRECATED_MACRO_NAME@ +#endif + +#endif // @INCLUDE_GUARD_NAME@ diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f67b029..02a95fe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3467,7 +3467,14 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, { if(*c == '\'') { - flags += "\\\\'"; + if (this->XcodeVersion >= 40) + { + flags += "'\\\\''"; + } + else + { + flags += "\\\\'"; + } } else if(*c == '\\') { diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index ff96e5b..abda47e 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -207,7 +207,7 @@ bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, this->IncludeProjectDirsBefore = makefile->IsOn( "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); - this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); + this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); this->MocCompileDefinitionsStr = makefile->GetSafeDefinition( "AM_MOC_COMPILE_DEFINITIONS"); diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index c1f5100..513eb64 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -215,7 +215,7 @@ kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern, //---------------------------------------------------------------------------- void Glob::RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { kwsys::Directory d; if ( !d.Load(dir.c_str()) ) @@ -258,25 +258,24 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, fullname = dir + "/" + fname; } - if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str()); + bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); + + if ( isDir && (!isSymLink || this->RecurseThroughSymlinks) ) { - if ( (this->Internals->Expressions.size() > 0) && - this->Internals->Expressions[ - this->Internals->Expressions.size()-1].find(fname.c_str()) ) + if (isSymLink) { - this->AddFile(this->Internals->Files, realname.c_str()); + ++this->FollowedSymlinkCount; } + this->RecurseDirectory(start+1, realname); } - if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + else { - bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); - if (!isSymLink || this->RecurseThroughSymlinks) + if ( (this->Internals->Expressions.size() > 0) && + this->Internals->Expressions[ + this->Internals->Expressions.size()-1].find(fname.c_str()) ) { - if (isSymLink) - { - ++this->FollowedSymlinkCount; - } - this->RecurseDirectory(start+1, realname, dir_only); + this->AddFile(this->Internals->Files, realname.c_str()); } } } @@ -284,13 +283,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, //---------------------------------------------------------------------------- void Glob::ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { //kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl; bool last = ( start == this->Internals->Expressions.size()-1 ); if ( last && this->Recurse ) { - this->RecurseDirectory(start, dir, dir_only); + this->RecurseDirectory(start, dir); return; } @@ -345,7 +344,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, // << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl; //kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl; - if ( (!dir_only || !last) && + if ( !last && !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { continue; @@ -359,7 +358,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, } else { - this->ProcessDirectory(start+1, realname + "/", dir_only); + this->ProcessDirectory(start+1, realname + "/"); } } } @@ -462,12 +461,11 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr) // Handle network paths if ( skip > 0 ) { - this->ProcessDirectory(0, fexpr.substr(0, skip) + "/", - true); + this->ProcessDirectory(0, fexpr.substr(0, skip) + "/"); } else { - this->ProcessDirectory(0, "/", true); + this->ProcessDirectory(0, "/"); } return true; } diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index cb050ee..88c343c 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -83,12 +83,12 @@ public: protected: //! Process directory void ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Process last directory, but only when recurse flags is on. That is // effectively like saying: /path/to/file/**/file void RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Add regular expression void AddExpression(const char* expr); diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 4558e2a..d3033d9 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -18,4 +18,4 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) SET(KWSYS_DATE_STAMP_MONTH 09) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 01) +SET(KWSYS_DATE_STAMP_DAY 07) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 46b3c15..9f4e8a3 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -228,6 +228,10 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + 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/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 0000000..77f5006 --- /dev/null +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCXXCompilerFlag) + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +set(CMAKE_VERBOSE_MAKEFILE 1) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) + string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") +endif() + +message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" + " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" + " GCC: ${_gcc_version}\n" + " Clang: ${_clang_version}\n" + " Intel: ${_intel_version}\n" +) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) + +message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") + +if(CMAKE_COMPILER_IS_GNUCXX) + if(NOT WIN32) +# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + endif() +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/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt new file mode 100644 index 0000000..fee836e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -0,0 +1,168 @@ +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) + +project(GenerateExportHeader) + +# Prevent timeout on Watcom by not running the tests. +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } + " + ) + + add_executable( + GenerateExportHeader + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + ) + return() +endif() + +include(CheckCXXCompilerFlag) + +set( CMAKE_INCLUDE_CURRENT_DIR ON ) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG) + +if(HAS_WERROR_FLAG) + set(ERROR_FLAG "-Werror") +else() + # MSVC + # And intel on windows? + # http://software.intel.com/en-us/articles/how-to-handle-warnings-message-in-compiler/?wapkw=%28compiler+warning+message%29 + check_cxx_compiler_flag("/WX" HAS_WX_FLAG) + if(HAS_WX_FLAG) + set(ERROR_FLAG "/WX") + else() + # Sun CC + # http://www.acsu.buffalo.edu/~charngda/sunstudio.html + check_cxx_compiler_flag("-errwarn=%all" HAS_ERRWARN_ALL) + if (HAS_ERRWARN_ALL) + set(ERROR_FLAG "-errwarn=%all") + else() + endif() + endif() +endif() + + +# We seem to get race conditions is writing this stuff to the same file at least on MinGW +# So to write to separate source and build directories, we use a count to differentiate. +set (COUNT 0) +macro(_do_build Include Library LibrarySource Source) + + math(EXPR COUNT "${COUNT} + 1" ) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" + "int main() { ${Source}; }\n" + ) + + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/../${LibrarySource}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}") + + if ("${Library}" STREQUAL "static_variant") + set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.8)\n" + + "project(compiletest)\n" + + "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" + + "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" + + "include(GenerateExportHeader)\n" + + "add_compiler_export_flags()\n" + + "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" + " add_definitions(${ERROR_FLAG})\n" + "endif()\n" + + "if(MSVC)\n" + " add_definitions(-DCOMPILER_IS_MSVC)\n" + "endif()\n" + + "add_subdirectory(\"${LibrarySource}\")\n" + + "include_directories(\"${LibrarySource}\" \"\${CMAKE_CURRENT_BINARY_DIR}/${LibrarySource}\")\n" + + "${CONDITIONAL_STATIC_DEFINE}" + + "add_executable(compiletest src.cpp)\n" + "target_link_libraries(compiletest ${Library})\n" + ) + + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} + ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} + compiletest + OUTPUT_VARIABLE Out + ) +endmacro() + +macro(build_fail Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_fail(Result ${Message}) +endmacro() + +macro(build_pass Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_pass(Result ${Message}) +endmacro() + +include(GenerateExportHeader) + +add_compiler_export_flags() + +if (MSVC) + add_definitions(-DCOMPILER_IS_MSVC) +endif() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) +message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) +message("#### WIN32: " ${WIN32}) +message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG}) + +set(link_libraries) +macro(macro_add_test_library name) + add_subdirectory(${name}) + include_directories(${name} + ${${name}_BINARY_DIR} # For the export header. + ) + list(APPEND link_libraries ${name}) + add_subdirectory(${name}test) +endmacro() + +macro_add_test_library(libshared) +macro_add_test_library(libstatic) +add_subdirectory(lib_shared_and_static) +add_subdirectory(lib_shared_and_statictest) + +add_subdirectory(override_symbol) + +if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) + # We deliberately call deprecated methods, and test for that elsewhere. + # No need to clutter the test output with warnings. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +endif() + +if(MSVC AND COMPILER_HAS_DEPRECATED) + add_definitions(/wd4996) +endif() + +add_executable(GenerateExportHeader exportheader_test.cpp) + +target_link_libraries(GenerateExportHeader ${link_libraries}) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp new file mode 100644 index 0000000..55c3c1a --- /dev/null +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -0,0 +1,82 @@ + +#include "libshared.h" + +#include "libstatic.h" + +// #define BUILD_FAIL + +#ifndef BUILD_FAIL +#define DOES_NOT_BUILD(function) +#else +#define DOES_NOT_BUILD(function) function +#endif + +int main() +{ + { + Libshared l; + l.libshared(); + l.libshared_exported(); + l.libshared_deprecated(); + l.libshared_not_exported(); + + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedNotExported l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedExcluded l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + libshared_exported(); + libshared_deprecated(); + DOES_NOT_BUILD(libshared_not_exported();) + DOES_NOT_BUILD(libshared_excluded();) + + { + Libstatic l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticNotExported l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticExcluded l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + libstatic_exported(); + libstatic_deprecated(); + libstatic_not_exported(); + libstatic_excluded(); + + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt new file mode 100644 index 0000000..d19b6dc --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -0,0 +1,12 @@ +project(shared_and_static) + +set(lib_SRCS + libshared_and_static.cpp +) + +add_library(shared_variant SHARED ${lib_SRCS}) +add_library(static_variant ${lib_SRCS}) + +generate_export_header(shared_variant BASE_NAME libshared_and_static) + +set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp new file mode 100644 index 0000000..1e07273 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -0,0 +1,91 @@ + +#include "libshared_and_static.h" + +int LibsharedAndStatic::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStatic::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_excluded() const { + return 0; +} + +int libshared_and_static() { + return 0; +} + +int libshared_and_static_exported() { + return 0; +} + +int libshared_and_static_deprecated() { + return 0; +} + +int libshared_and_static_not_exported() { + return 0; +} + +int libshared_and_static_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h new file mode 100644 index 0000000..049bfe9 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -0,0 +1,54 @@ + +#ifndef SHARED_AND_STATIC_H +#define SHARED_AND_STATIC_H + +#include "libshared_and_static_export.h" + +class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +public: + int libshared_and_static() const; + + int libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LibsharedAndStaticNotExported { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); + +LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); + +int libshared_and_static_not_exported(); + +int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt new file mode 100644 index 0000000..207534d --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -0,0 +1,33 @@ + +macro(shared_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(shared_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") +shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") +# if (COMPILER_HAS_DEPRECATED) +# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +# else() +# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") +# endif() +static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") +else() + shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") +endif() diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt new file mode 100644 index 0000000..8e4ee2b --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -0,0 +1,6 @@ + +project(libshared) + +add_library(libshared SHARED libshared.cpp) + +generate_export_header(libshared) diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp new file mode 100644 index 0000000..d4041b3 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp @@ -0,0 +1,91 @@ + +#include "libshared.h" + +int Libshared::libshared() const +{ + return 0; +} + +int Libshared::libshared_exported() const +{ + return 0; +} + +int Libshared::libshared_deprecated() const +{ + return 0; +} + +int Libshared::libshared_not_exported() const { + return 0; +} + +int Libshared::libshared_excluded() const { + return 0; +} + +int LibsharedNotExported::libshared() const +{ + return 0; +} + +int LibsharedNotExported::libshared_exported() const +{ + return 0; +} + +int LibsharedNotExported::libshared_deprecated() const +{ + return 0; +} + +int LibsharedNotExported::libshared_not_exported() const { + return 0; +} + +int LibsharedNotExported::libshared_excluded() const { + return 0; +} + +int LibsharedExcluded::libshared() const +{ + return 0; +} + +int LibsharedExcluded::libshared_exported() const +{ + return 0; +} + +int LibsharedExcluded::libshared_deprecated() const +{ + return 0; +} + +int LibsharedExcluded::libshared_not_exported() const { + return 0; +} + +int LibsharedExcluded::libshared_excluded() const { + return 0; +} + +int libshared() { + return 0; +} + +int libshared_exported() { + return 0; +} + +int libshared_deprecated() { + return 0; +} + +int libshared_not_exported() { + return 0; +} + +int libshared_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h new file mode 100644 index 0000000..3d9bbff --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h @@ -0,0 +1,54 @@ + +#ifndef LIBSHARED_H +#define LIBSHARED_H + +#include "libshared_export.h" + +class LIBSHARED_EXPORT Libshared { +public: + int libshared() const; + + int libshared_exported() const; + + int LIBSHARED_DEPRECATED libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LibsharedNotExported { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LIBSHARED_NO_EXPORT LibsharedExcluded { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +LIBSHARED_EXPORT int libshared_exported(); + +LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); + +int libshared_not_exported(); + +int LIBSHARED_NO_EXPORT libshared_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt new file mode 100644 index 0000000..a5804fc --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -0,0 +1,44 @@ + +macro(shared_build_pass Source Message) + build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +macro(shared_build_fail Source Message) + build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") + +# if (COMPILER_HAS_DEPRECATED) +# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# else() +# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# endif() +if (COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") +else() + # There is no MSVC equivalent to hiding symbols. + shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") +endif() + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") + + shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") + shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") +else() + shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") + + shared_build_pass("return libshared_excluded();" "Built use of excluded function.") + shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") +endif() diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt new file mode 100644 index 0000000..8db1827 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -0,0 +1,8 @@ + +project(libstatic) + +# Show that the export header has no effect on a static library. + +add_library(libstatic STATIC libstatic.cpp) + +generate_export_header(libstatic) diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp new file mode 100644 index 0000000..0710c3e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp @@ -0,0 +1,87 @@ + +#include "libstatic.h" + +int Libstatic::libstatic() const +{ + return 0; +} + +int Libstatic::libstatic_exported() const +{ + return 0; +} + +int Libstatic::libstatic_deprecated() const +{ + return 0; +} + +int Libstatic::libstatic_not_exported() const { + return 0; +} + +int Libstatic::libstatic_excluded() const { + return 0; +} + +int LibstaticNotExported::libstatic() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_exported() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_not_exported() const { + return 0; +} + +int LibstaticNotExported::libstatic_excluded() const { + return 0; +} + +int LibstaticExcluded::libstatic() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_exported() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_not_exported() const { + return 0; +} + +int LibstaticExcluded::libstatic_excluded() const { + return 0; +} + +int libstatic_exported() { + return 0; +} + +int libstatic_deprecated() { + return 0; +} + +int libstatic_not_exported() { + return 0; +} + +int libstatic_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h new file mode 100644 index 0000000..cc7a35b --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -0,0 +1,54 @@ + +#ifndef LIBSTATIC_H +#define LIBSTATIC_H + +#include "libstatic_export.h" + +class LIBSTATIC_EXPORT Libstatic { +public: + int libstatic() const; + + int libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LibstaticNotExported { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LIBSTATIC_NO_EXPORT LibstaticExcluded { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +LIBSTATIC_EXPORT int libstatic_exported(); + +LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated(); + +int libstatic_not_exported(); + +int LIBSTATIC_NO_EXPORT libstatic_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt new file mode 100644 index 0000000..eb6bb87 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -0,0 +1,18 @@ + +macro(static_build_pass Source Message) + build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +macro(static_build_fail Source Message) + build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") + +# if (COMPILER_HAS_DEPRECATED) +# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# else() +# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# endif() diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt new file mode 100644 index 0000000..aeeef20 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt @@ -0,0 +1,11 @@ +project(override_symbol) + +add_library(somelib SHARED someclass.cpp) + +set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) + +generate_export_header(somelib) + +add_executable(consumer main.cpp) + +target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp new file mode 100644 index 0000000..445a652 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +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 new file mode 100644 index 0000000..7326b78 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -0,0 +1,7 @@ + +#include "someclass.h" + +void SomeClass::someMethod() const +{ + +}
\ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h new file mode 100644 index 0000000..ae5e844 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h @@ -0,0 +1,8 @@ + +#include "somelib_export.h" + +class SOMELIB_EXPORT SomeClass +{ +public: + void someMethod() const; +}; diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 85db367..798c163 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -126,7 +126,7 @@ ADD_CUSTOM_COMMAND( INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${HTML_FILES} ${TEXT_FILES}) -INSTALL_FILES(share/aclocal FILES cmake.m4) +INSTALL(FILES cmake.m4 DESTINATION share/aclocal) # Drive documentation generation. ADD_CUSTOM_TARGET(documentation ALL DEPENDS ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/cmake.txt ) diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 75b0061..c304e67 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -7,9 +7,9 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs) set(RELEASE_SCRIPTS_BATCH_1 dash2win64_release.cmake # Windows - dashmacmini2_release.cmake # Mac Darwin universal + dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 + dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux - dashsun1_release.cmake # SunOS v20n250_aix_release.cmake # AIX 5.3 ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index d117014..2668d38 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -12,7 +12,7 @@ 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 +BUILD_QtDialog:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Software/QtBinUniversal/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake new file mode 100644 index 0000000..92eebd7 --- /dev/null +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -0,0 +1,20 @@ +set(PROCESSORS 4) +set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory) +# set(USER_OVERRIDE "set(CMAKE_CXX_LINK_EXECUTABLE \\\"gcc <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared-libgcc -lstdc++-static\\\")") +set(INSTALL_PREFIX /) +set(HOST dashmacmini5) +set(MAKE_PROGRAM "make") +set(MAKE "${MAKE_PROGRAM} -j5") +set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") +set(CPACK_SOURCE_GENERATORS "TGZ TZ") +set(INITIAL_CACHE " +CMAKE_BUILD_TYPE:STRING=Release +CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386 +CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 +CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE +CPACK_SYSTEM_NAME:STRING=Darwin64-universal +BUILD_QtDialog:BOOL=TRUE +QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.6.4/install/bin/qmake +") +get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/dashsun1_release.cmake b/Utilities/Release/dashsun1_release.cmake deleted file mode 100644 index f98795d..0000000 --- a/Utilities/Release/dashsun1_release.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(PROCESSORS 1) -set(HOST dashsun1) -set(CMAKE_RELEASE_DIRECTORY "/home/kitware/CMakeReleaseDirectory" ) -set(MAKE_PROGRAM "make") -set(USER_MAKE_RULE_FILE - "/home/kitware/CMakeReleaseDirectory/UserMakeRules.cmake") -set(INITIAL_CACHE " -CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE -CMAKE_BUILD_TYPE:STRING=Release -HAVE_LIBDL:INTERNAL=FALSE -CMAKE_EXE_LINKER_FLAGS:STRING=-Bdynamic -ldl -Bstatic -CMAKE_USER_MAKE_RULES_OVERRIDE:STRING=${USER_MAKE_RULE_FILE} -CURSES_LIBRARY:FILEPATH=/usr/lib/libcurses.a -FORM_LIBRARY:FILEPATH=/usr/lib/libform.a") -set(USER_MAKE_RULE_FILE_CONTENTS - "SET(CMAKE_DL_LIBS \\\"-Bdynamic -ldl -Bstatic\\\")") -get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -include(${path}/release_cmake.cmake) |