diff options
Diffstat (limited to 'Modules')
145 files changed, 2096 insertions, 1049 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 8c7646e..f94fc5c 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -7,7 +7,7 @@ BundleUtilities Functions to help assemble a standalone bundle application. -A collection of CMake utility functions useful for dealing with .app +A collection of CMake utility functions useful for dealing with ``.app`` bundles on the Mac and bundle-like directories on any OS. The following functions are provided by this module: @@ -33,7 +33,7 @@ The following functions are provided by this module: verify_bundle_symlinks Requires CMake 2.6 or greater because it uses function, break and -PARENT_SCOPE. Also depends on GetPrerequisites.cmake. +``PARENT_SCOPE``. Also depends on ``GetPrerequisites.cmake``. DO NOT USE THESE FUNCTIONS AT CONFIGURE TIME (from ``CMakeLists.txt``)! Instead, invoke them from an :command:`install(CODE)` or @@ -43,55 +43,57 @@ Instead, invoke them from an :command:`install(CODE)` or fixup_bundle(<app> <libs> <dirs>) -Fix up a bundle in-place and make it standalone, such that it can be +Fix up ``<app>`` bundle in-place and make it standalone, such that it can be drag-n-drop copied to another machine and run on that machine as long as all of the system libraries are compatible. -If you pass plugins to fixup_bundle as the libs parameter, you should -install them or copy them into the bundle before calling fixup_bundle. -The "libs" parameter is a list of libraries that must be fixed up, but -that cannot be determined by otool output analysis. (i.e., plugins) +If you pass plugins to ``fixup_bundle`` as the libs parameter, you should +install them or copy them into the bundle before calling ``fixup_bundle``. +The ``<libs>`` parameter is a list of libraries that must be fixed up, but +that cannot be determined by ``otool`` output analysis (i.e. ``plugins``). Gather all the keys for all the executables and libraries in a bundle, and then, for each key, copy each prerequisite into the bundle. Then fix each one up according to its own list of prerequisites. -Then clear all the keys and call verify_app on the final bundle to +Then clear all the keys and call ``verify_app`` on the final bundle to ensure that it is truly standalone. -As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed, +which are then ignored +(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``). .. code-block:: cmake copy_and_fixup_bundle(<src> <dst> <libs> <dirs>) -Makes a copy of the bundle <src> at location <dst> and then fixes up -the new copied bundle in-place at <dst>... +Makes a copy of the bundle ``<src>`` at location ``<dst>`` and then fixes up +the new copied bundle in-place at ``<dst>``. .. code-block:: cmake verify_app(<app>) -Verifies that an application <app> appears valid based on running -analysis tools on it. Calls "message(FATAL_ERROR" if the application +Verifies that an application ``<app>`` appears valid based on running +analysis tools on it. Calls :command:`message(FATAL_ERROR)` if the application is not verified. -As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed, +which are then ignored +(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``) .. code-block:: cmake get_bundle_main_executable(<bundle> <result_var>) The result will be the full path name of the bundle's main executable -file or an "error:" prefixed string if it could not be determined. +file or an ``error:`` prefixed string if it could not be determined. .. code-block:: cmake get_dotapp_dir(<exe> <dotapp_dir_var>) -Returns the nearest parent dir whose name ends with ".app" given the +Returns the nearest parent dir whose name ends with ``.app`` given the full path to an executable. If there is no such parent dir, then simply return the dir containing the executable. @@ -101,26 +103,26 @@ The returned directory may or may not exist. get_bundle_and_executable(<app> <bundle_var> <executable_var> <valid_var>) -Takes either a ".app" directory name or the name of an executable -nested inside a ".app" directory and returns the path to the ".app" -directory in <bundle_var> and the path to its main executable in -<executable_var> +Takes either a ``.app`` directory name or the name of an executable +nested inside a ``.app`` directory and returns the path to the ``.app`` +directory in ``<bundle_var>`` and the path to its main executable in +``<executable_var>``. .. code-block:: cmake get_bundle_all_executables(<bundle> <exes_var>) -Scans the given bundle recursively for all executable files and -accumulates them into a variable. +Scans ``<bundle>`` bundle recursively for all ``<exes_var>`` executable +files and accumulates them into a variable. .. code-block:: cmake get_item_key(<item> <key_var>) -Given a file (item) name, generate a key that should be unique +Given ``<item>`` file name, generate ``<key_var>`` key that should be unique considering the set of libraries that need copying or fixing up to make a bundle standalone. This is essentially the file name including -extension with "." replaced by "_" +extension with ``.`` replaced by ``_`` This key is used as a prefix for CMake variables so that we can associate a set of variables with a given item based on its key. @@ -129,10 +131,10 @@ associate a set of variables with a given item based on its key. clear_bundle_keys(<keys_var>) -Loop over the list of keys, clearing all the variables associated with -each key. After the loop, clear the list of keys itself. +Loop over the ``<keys_var>`` list of keys, clearing all the variables +associated with each key. After the loop, clear the list of keys itself. -Caller of get_bundle_keys should call clear_bundle_keys when done with +Caller of ``get_bundle_keys`` should call ``clear_bundle_keys`` when done with list of keys. .. code-block:: cmake @@ -140,86 +142,88 @@ list of keys. set_bundle_key_values(<keys_var> <context> <item> <exepath> <dirs> <copyflag> [<rpaths>]) -Add a key to the list (if necessary) for the given item. If added, -also set all the variables associated with that key. +Add ``<keys_var>`` key to the list (if necessary) for the given item. +If added, also set all the variables associated with that key. .. code-block:: cmake get_bundle_keys(<app> <libs> <dirs> <keys_var>) -Loop over all the executable and library files within the bundle (and -given as extra <libs>) and accumulate a list of keys representing +Loop over all the executable and library files within ``<app>`` bundle (and +given as extra ``<libs>``) and accumulate a list of keys representing them. Set values associated with each key such that we can loop over all of them and copy prerequisite libs into the bundle and then do -appropriate install_name_tool fixups. +appropriate ``install_name_tool`` fixups. -As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed, +which are then ignored +(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``) .. code-block:: cmake copy_resolved_item_into_bundle(<resolved_item> <resolved_embedded_item>) -Copy a resolved item into the bundle if necessary. Copy is not -necessary if the resolved_item is "the same as" the -resolved_embedded_item. +Copy a resolved item into the bundle if necessary. +Copy is not necessary, if the ``<resolved_item>`` is "the same as" the +``<resolved_embedded_item>``. .. code-block:: cmake copy_resolved_framework_into_bundle(<resolved_item> <resolved_embedded_item>) -Copy a resolved framework into the bundle if necessary. Copy is not -necessary if the resolved_item is "the same as" the -resolved_embedded_item. +Copy a resolved framework into the bundle if necessary. +Copy is not necessary, if the ``<resolved_item>`` is "the same as" the +``<resolved_embedded_item>``. -By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want +By default, ``BU_COPY_FULL_FRAMEWORK_CONTENTS`` is not set. If you want full frameworks embedded in your bundles, set -BU_COPY_FULL_FRAMEWORK_CONTENTS to ON before calling fixup_bundle. By -default, COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework -dylib itself plus the framework Resources directory. +``BU_COPY_FULL_FRAMEWORK_CONTENTS`` to ``ON`` before calling fixup_bundle. By +default, ``COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE`` copies the framework +dylib itself plus the framework ``Resources`` directory. .. code-block:: cmake fixup_bundle_item(<resolved_embedded_item> <exepath> <dirs>) -Get the direct/non-system prerequisites of the resolved embedded item. +Get the direct/non-system prerequisites of the ``<resolved_embedded_item>``. For each prerequisite, change the way it is referenced to the value of -the _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely -changing to an "@executable_path" style reference.) +the ``_EMBEDDED_ITEM`` keyed variable for that prerequisite. (Most likely +changing to an ``@executable_path`` style reference.) -This function requires that the resolved_embedded_item be "inside" the -bundle already. In other words, if you pass plugins to fixup_bundle +This function requires that the ``<resolved_embedded_item>`` be ``inside`` +the bundle already. In other words, if you pass plugins to ``fixup_bundle`` as the libs parameter, you should install them or copy them into the -bundle before calling fixup_bundle. The "libs" parameter is a list of +bundle before calling ``fixup_bundle``. The ``libs`` parameter is a list of libraries that must be fixed up, but that cannot be determined by -otool output analysis. (i.e., plugins) +otool output analysis. (i.e., ``plugins``) Also, change the id of the item being fixed up to its own -_EMBEDDED_ITEM value. +``_EMBEDDED_ITEM`` value. Accumulate changes in a local variable and make *one* call to -install_name_tool at the end of the function with all the changes at +``install_name_tool`` at the end of the function with all the changes at once. -If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be -marked writable before install_name_tool tries to change them. +If the ``BU_CHMOD_BUNDLE_ITEMS`` variable is set then bundle items will be +marked writable before ``install_name_tool`` tries to change them. .. code-block:: cmake verify_bundle_prerequisites(<bundle> <result_var> <info_var>) Verifies that the sum of all prerequisites of all files inside the -bundle are contained within the bundle or are "system" libraries, +bundle are contained within the bundle or are ``system`` libraries, presumed to exist everywhere. -As an optional parameter (IGNORE_ITEM) a list of file names can be passed, -which are then ignored (e.g. IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe") +As an optional parameter (``IGNORE_ITEM``) a list of file names can be passed, +which are then ignored +(e.g. ``IGNORE_ITEM "vcredist_x86.exe;vcredist_x64.exe"``) .. code-block:: cmake verify_bundle_symlinks(<bundle> <result_var> <info_var>) -Verifies that any symlinks found in the bundle point to other files +Verifies that any symlinks found in the ``<bundle>`` bundle point to other files that are already also in the bundle... Anything that points to an external file causes this function to fail the verification. #]=======================================================================] diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake index 1e3c608..cb793e7 100644 --- a/Modules/CMakeASM_NASMInformation.cmake +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -28,7 +28,9 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) endif() endif() -set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") +if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) + set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") +endif() # Load the generic ASMInformation file: set(ASM_DIALECT "_NASM") diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index 50b2807..2613569 100644 --- a/Modules/CMakeAddFortranSubdirectory.cmake +++ b/Modules/CMakeAddFortranSubdirectory.cmake @@ -16,7 +16,7 @@ build with the MinGW tools. It will also create imported targets for the libraries created. This will only work if the fortran code is built into a dll, so :variable:`BUILD_SHARED_LIBS` is turned on in the project. In addition the :variable:`CMAKE_GNUtoMS` option is set -to on, so that Microsoft .lib files are created. Usage is as follows: +to on, so that Microsoft ``.lib`` files are created. Usage is as follows: :: @@ -32,15 +32,15 @@ to on, so that Microsoft .lib files are created. Usage is as follows: NO_EXTERNAL_INSTALL # skip installation of external project ) -Relative paths in ARCHIVE_DIR and RUNTIME_DIR are interpreted with +Relative paths in ``ARCHIVE_DIR`` and ``RUNTIME_DIR`` are interpreted with respect to the build directory corresponding to the source directory in which the function is invoked. Limitations: -NO_EXTERNAL_INSTALL is required for forward compatibility with a +``NO_EXTERNAL_INSTALL`` is required for forward compatibility with a future version that supports installation of the external project -binaries during "make install". +binaries during ``make install``. #]=======================================================================] set(_MS_MINGW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Modules/CMakeAddNewLanguage.txt b/Modules/CMakeAddNewLanguage.txt index 612e1a3..6baadc3 100644 --- a/Modules/CMakeAddNewLanguage.txt +++ b/Modules/CMakeAddNewLanguage.txt @@ -1,7 +1,7 @@ This file provides a few notes to CMake developers about how to add support for a new language to CMake. It is also possible to place -these files in CMAKE_MODULE_PATH within an outside project to add -languages not supported by upstream CMake. However, this is not +these files in :variable:`CMAKE_MODULE_PATH` within an outside project +to add languages not supported by upstream CMake. However, this is not a fully supported use case. The implementation behind the scenes of project/enable_language, @@ -29,5 +29,3 @@ CMake(LANG)Information.cmake -> set up rule variables for LANG : CMAKE_(LANG)_CREATE_STATIC_LIBRARY CMAKE_(LANG)_COMPILE_OBJECT CMAKE_(LANG)_LINK_EXECUTABLE - - diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index e60ffe0..5b9ed34 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -30,5 +30,6 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) FAIL_REGEX "Incorrect command line option:" # Borland FAIL_REGEX "Warning: illegal option" # SunStudio 12 FAIL_REGEX "[Ww]arning: Invalid suboption" # Fujitsu + FAIL_REGEX "An invalid option .* appears on the command line" # Cray ) endmacro () diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 6a22d27..ed288f5 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -57,6 +57,7 @@ function(compiler_id_detection outvar lang) HP Compaq zOS + XLClang XL VisualAge PGI @@ -86,8 +87,6 @@ function(compiler_id_detection outvar lang) SDCC ) endif() - list(APPEND ordered_compilers - MIPSpro) #Currently the only CUDA compilers are NVIDIA if(lang STREQUAL CUDA) @@ -98,6 +97,8 @@ function(compiler_id_detection outvar lang) foreach(Id ${ordered_compilers}) string(APPEND CMAKE_${lang}_COMPILER_ID_CONTENT "# define ${CID_PREFIX}COMPILER_IS_${Id} 0\n") endforeach() + # Hard-code definitions for compilers that are no longer supported. + string(APPEND CMAKE_${lang}_COMPILER_ID_CONTENT "# define ${CID_PREFIX}COMPILER_IS_MIPSpro 0\n") endif() set(pp_if "#if") diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index b8c8c5d..eabb8b5 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -119,35 +119,40 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT} "${userflags}") if("x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xIAR") # primary necessary to detect architecture, so the right archiver and linker can be picked - # eg. IAR Assembler V8.10.1.12857/W32 for ARM + # eg. "IAR Assembler V8.10.1.12857/W32 for ARM" or "IAR Assembler V4.11.1.4666 for Renesas RX" # Cut out identification first, newline handling is a pain string(REGEX MATCH "IAR Assembler[^\r\n]*" _compileid "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT}") if("${_compileid}" MATCHES "V([0-9]+\\.[0-9]+\\.[0-9]+)") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION ${CMAKE_MATCH_1}) endif() - if("${_compileid}" MATCHES "for[ ]+([A-Za-z0-9]+)") - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID ${CMAKE_MATCH_1}) + string(REGEX MATCHALL "([A-Za-z0-9]+)" _all_compileid_matches "${_compileid}") + if(_all_compileid_matches) + list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID) endif() endif() unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT) + unset(_all_compileid_matches) unset(_compileid) endif() - if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) if(CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION) set(_version " ${CMAKE_ASM${ASM_DIALECT}_COMPILER_VERSION}") else() set(_version "") endif() - message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_version}") + if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID) + set(_archid " ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}") + else() + set(_archid "") + endif() + message(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}${_archid}${_version}") + unset(_archid) unset(_version) else() message(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") endif() - - # If we have a gas/as cross compiler, they have usually some prefix, like # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally # with a 3-component version number at the end diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index d7f6f97..3ec534f 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -139,8 +139,9 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|QCC") get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") if(CMAKE_C_COMPILER_TARGET) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index bd878b2..68cb9fe 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -136,8 +136,9 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|QCC") get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) - if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+(\\.[0-9]+)*)?(-[^.]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + set(_CMAKE_COMPILER_SUFFIX ${CMAKE_MATCH_5}) elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") if(CMAKE_CXX_COMPILER_TARGET) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 59dab6d..c1c9982 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -110,8 +110,15 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) else() set(_version "") endif() + if(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID) + set(_archid " ${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}") + else() + set(_archid "") + endif() message(STATUS "The ${lang} compiler identification is " - "${CMAKE_${lang}_COMPILER_ID}${_version}") + "${CMAKE_${lang}_COMPILER_ID}${_archid}${_version}") + unset(_archid) + unset(_version) else() message(STATUS "The ${lang} compiler identification is unknown") endif() @@ -431,10 +438,18 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} ) # Match the compiler location line printed out. set(ghs_toolpath "${CMAKE_MAKE_PROGRAM}") - string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath}) - string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath}) + if(CMAKE_HOST_UNIX) + string(REPLACE "/gbuild" "/" ghs_toolpath ${ghs_toolpath}) + else() + string(REPLACE "/gbuild.exe" "/" ghs_toolpath ${ghs_toolpath}) + string(REPLACE / "\\\\" ghs_toolpath ${ghs_toolpath}) + endif() if("${CMAKE_${lang}_COMPILER_ID_OUTPUT}" MATCHES "(${ghs_toolpath}[^ ]*)") - set(_comp "${CMAKE_MATCH_1}.exe") + if(CMAKE_HOST_UNIX) + set(_comp "${CMAKE_MATCH_1}") + else() + set(_comp "${CMAKE_MATCH_1}.exe") + endif() if(EXISTS "${_comp}") file(TO_CMAKE_PATH "${_comp}" _comp) set(CMAKE_${lang}_COMPILER_ID_TOOL "${_comp}" PARENT_SCOPE) diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index de1a332..bcdfbeb 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -31,36 +31,33 @@ CMakeFindDependencyMacro #]=======================================================================] macro(find_dependency dep) - if (NOT ${dep}_FOUND) - set(cmake_fd_quiet_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(cmake_fd_quiet_arg QUIET) - endif() - set(cmake_fd_required_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(cmake_fd_required_arg REQUIRED) - endif() + set(cmake_fd_quiet_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(cmake_fd_quiet_arg QUIET) + endif() + set(cmake_fd_required_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(cmake_fd_required_arg REQUIRED) + endif() - get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY - _CMAKE_${dep}_TRANSITIVE_DEPENDENCY - ) + get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY + _CMAKE_${dep}_TRANSITIVE_DEPENDENCY + ) - find_package(${dep} ${ARGN} - ${cmake_fd_quiet_arg} - ${cmake_fd_required_arg} - ) + find_package(${dep} ${ARGN} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} + ) - if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) - set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) - endif() + if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) + set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) + endif() - if (NOT ${dep}_FOUND) - set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") - set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) - return() - endif() - set(cmake_fd_required_arg) - set(cmake_fd_quiet_arg) - set(cmake_fd_exact_arg) + if (NOT ${dep}_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) + return() endif() + set(cmake_fd_required_arg) + set(cmake_fd_quiet_arg) endmacro() diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index 7ac09dc..7048806 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -25,38 +25,41 @@ toolchain file instead. ------------------------------------------------------------------------- -Macro CMAKE_FORCE_C_COMPILER has the following signature: +Macro ``CMAKE_FORCE_C_COMPILER`` has the following signature: :: CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>) -It sets CMAKE_C_COMPILER to the given compiler and the cmake internal -variable CMAKE_C_COMPILER_ID to the given compiler-id. It also -bypasses the check for working compiler and basic compiler information -tests. +It sets :variable:`CMAKE_C_COMPILER <CMAKE_<LANG>_COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_C_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given +compiler-id. It also bypasses the check for working compiler and basic +compiler information tests. -Macro CMAKE_FORCE_CXX_COMPILER has the following signature: +Macro ``CMAKE_FORCE_CXX_COMPILER`` has the following signature: :: CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>) -It sets CMAKE_CXX_COMPILER to the given compiler and the cmake -internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id. It -also bypasses the check for working compiler and basic compiler -information tests. +It sets :variable:`CMAKE_CXX_COMPILER <CMAKE_<LANG>_COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_CXX_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given +compiler-id. It also bypasses the check for working compiler and basic +compiler information tests. -Macro CMAKE_FORCE_Fortran_COMPILER has the following signature: +Macro ``CMAKE_FORCE_Fortran_COMPILER`` has the following signature: :: CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>) -It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake -internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id. -It also bypasses the check for working compiler and basic compiler -information tests. +It sets :variable:`CMAKE_Fortran_COMPILER <CMAKE_<LANG>_COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_Fortran_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` to the given +compiler-id. It also bypasses the check for working compiler and basic +compiler information tests. So a simple toolchain file could look like this: diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 5995694..30f8d4c 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -96,13 +96,6 @@ # if defined(__FLANG_PATCHLEVEL__) # define COMPILER_VERSION_PATCH DEC(__FLANG_PATCHLEVEL__) # endif -#elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) - PRINT *, 'INFO:compiler[MIPSpro]' -# if 0 -! This compiler is either not known or is too old to define an -! identification macro. Try to identify the platform and guess that -! it is the native compiler. -# endif #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) PRINT *, 'INFO:compiler[VisualAge]' #elif defined(__hpux) || defined(__hpux__) diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake index c42474b..176b3ff 100644 --- a/Modules/CMakeParseImplicitIncludeInfo.cmake +++ b/Modules/CMakeParseImplicitIncludeInfo.cmake @@ -92,13 +92,15 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var) endif() # XL compiler - if("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL" AND "${line}" MATCHES "^/" + if(("${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XL" + OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "XLClang") + AND "${line}" MATCHES "^/" AND ( ("${lang}" STREQUAL "Fortran" AND "${line}" MATCHES "/xl[fF]entry " AND "${line}" MATCHES "OSVAR\\([^ ]+\\)") OR ( ("${lang}" STREQUAL "C" OR "${lang}" STREQUAL "CXX") AND - "${line}" MATCHES "/xl[cC]entry " AND + "${line}" MATCHES "/xl[cC]2?entry " AND "${line}" MATCHES " -qosvar=") ) ) # -qnostdinc cancels other stdinc flags, even if present diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 3cb7f24..c88094a 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -156,6 +156,9 @@ # if defined(__ICCARM__) # define ARCHITECTURE_ID "ARM" +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + # elif defined(__ICCAVR__) # define ARCHITECTURE_ID "AVR" diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index 1227fdf..7bf6567 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -32,7 +32,7 @@ set(CMAKE_INCLUDE_FLAG_RC "-I") # compile a Resource file into an object file if(NOT CMAKE_RC_COMPILE_OBJECT) set(CMAKE_RC_COMPILE_OBJECT - "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo<OBJECT> <SOURCE>") + "<CMAKE_RC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /fo <OBJECT> <SOURCE>") endif() # set this variable so we can avoid loading this more than once. diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index efa88bd..d096849 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -13,11 +13,11 @@ Usage: check_language(<lang>) -where <lang> is a language that may be passed to enable_language() -such as "Fortran". If CMAKE_<lang>_COMPILER is already defined the -check does nothing. Otherwise it tries enabling the language in a -test project. The result is cached in CMAKE_<lang>_COMPILER as the -compiler that was found, or NOTFOUND if the language cannot be +where ``<lang>`` is a language that may be passed to :command:`enable_language` +such as ``Fortran``. If :variable:`CMAKE_<LANG>_COMPILER` is already defined +the check does nothing. Otherwise it tries enabling the language in a +test project. The result is cached in :variable:`CMAKE_<LANG>_COMPILER` +as the compiler that was found, or ``NOTFOUND`` if the language cannot be enabled. Example: diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index 720217d..6d63f0b 100644 --- a/Modules/CheckPIESupported.cmake +++ b/Modules/CheckPIESupported.cmake @@ -5,8 +5,8 @@ CheckPIESupported ----------------- -Check whether the linker supports position independent code (PIE) or no -position independent code (NO_PIE) for executables. +Check whether the linker supports Position Independent Code (PIE) or No +Position Independent Code (NO_PIE) for executables. Use this to ensure that the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property for executables will be honored at link time. diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in index 2303c4e..82035a3 100644 --- a/Modules/CheckTypeSize.c.in +++ b/Modules/CheckTypeSize.c.in @@ -18,7 +18,7 @@ #endif #define SIZE (sizeof(@type@)) -char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[', +static char info_size[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','[', ('0' + ((SIZE / 10000)%10)), ('0' + ((SIZE / 1000)%10)), ('0' + ((SIZE / 100)%10)), diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index a48adec..2794f52 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -4,12 +4,15 @@ __compiler_clang(C) if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() __compiler_check_default_language_standard(C 4.0 99) diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index e5fd647..d34d494 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -8,6 +8,7 @@ endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index ad464c7..96537f8 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -65,13 +65,28 @@ endmacro() macro(cmake_record_c_compile_features) set(_result 0) if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) + if(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(11) + else() + _record_compiler_features_c(11) + endif() + unset(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(99) + if(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(99) + else() + _record_compiler_features_c(99) + endif() + unset(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(90) + if(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(90) + else() + _record_compiler_features_c(90) + endif() + unset(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT) endif() endmacro() @@ -79,18 +94,43 @@ endmacro() macro(cmake_record_cxx_compile_features) set(_result 0) if(_result EQUAL 0 AND DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(20) + if(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cxx(20) + else() + _record_compiler_features_cxx(20) + endif() + unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_CXX17_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(17) + if(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cxx(17) + else() + _record_compiler_features_cxx(17) + endif() + unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_CXX14_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(14) + if(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cxx(14) + else() + _record_compiler_features_cxx(14) + endif() + unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(11) + if(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cxx(11) + else() + _record_compiler_features_cxx(11) + endif() + unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_CXX98_STANDARD_COMPILE_OPTION) - _record_compiler_features_cxx(98) + if(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_cxx(98) + else() + _record_compiler_features_cxx(98) + endif() + unset(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT) endif() endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index a07ae40..0448965 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -10,22 +10,28 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) else() # clang-cl doesn't have any of these set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() endif() diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake index e99011b..34ffd66 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -19,6 +19,7 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") @@ -59,6 +60,7 @@ elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9 # support for -std: flags. set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std:c++14") diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake index d34154c..9340948 100644 --- a/Modules/Compiler/Cray-C.cmake +++ b/Modules/Compiler/Cray-C.cmake @@ -10,11 +10,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform) set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5) set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif () diff --git a/Modules/Compiler/Cray-CXX.cmake b/Modules/Compiler/Cray-CXX.cmake index 85a3167..38c8b1e 100644 --- a/Modules/Compiler/Cray-CXX.cmake +++ b/Modules/Compiler/Cray-CXX.cmake @@ -10,13 +10,16 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -h conform) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -h gnu) + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.4) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -h std=c++11) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -h std=c++11,gnu) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.6) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -h std=c++14) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -h std=c++14,gnu) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) endif () endif () diff --git a/Modules/Compiler/CrayPrgEnv.cmake b/Modules/Compiler/CrayPrgEnv.cmake index 6c1c770..e55e587 100644 --- a/Modules/Compiler/CrayPrgEnv.cmake +++ b/Modules/Compiler/CrayPrgEnv.cmake @@ -1,8 +1,93 @@ # Guard against multiple inclusions -if(__craylinux_crayprgenv) +if(__cmake_craype_crayprgenv) return() endif() -set(__craylinux_crayprgenv 1) +set(__cmake_craype_crayprgenv 1) + +# CrayPrgEnv: loaded when compiling through the Cray compiler wrapper. +# The compiler wrapper can run on a front-end node or a compute node. + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +# One-time setup of the craype environment. First, check the wrapper config. +# The wrapper's selection of a compiler (gcc, clang, intel, etc.) and +# default include/library paths is selected using the "module" command. +# The CRAYPE_LINK_TYPE environment variable partly controls if static +# or dynamic binaries are generated (see __cmake_craype_linktype below). +# Running cmake and then changing module and/or linktype configuration +# may cause build problems (since the data in the cmake cache may no +# longer be correct after the change). We can look for this and warn +# the user about it. Second, use the "module" provided PKG_CONFIG_PATH-like +# environment variable to add additional prefixes to the system prefix +# path. +function(__cmake_craype_setupenv) + if(NOT DEFINED __cmake_craype_setupenv_done) # only done once per run + set(__cmake_craype_setupenv_done 1 PARENT_SCOPE) + unset(__cmake_check) + set(CMAKE_CRAYPE_LINKTYPE "$ENV{CRAYPE_LINK_TYPE}" CACHE STRING + "saved value of CRAYPE_LINK_TYPE environment variable") + set(CMAKE_CRAYPE_LOADEDMODULES "$ENV{LOADEDMODULES}" CACHE STRING + "saved value of LOADEDMODULES environment variable") + mark_as_advanced(CMAKE_CRAYPE_LINKTYPE CMAKE_CRAYPE_LOADEDMODULES) + if (NOT "${CMAKE_CRAYPE_LINKTYPE}" STREQUAL "$ENV{CRAYPE_LINK_TYPE}") + string(APPEND __cmake_check "CRAYPE_LINK_TYPE ") + endif() + if (NOT "${CMAKE_CRAYPE_LOADEDMODULES}" STREQUAL "$ENV{LOADEDMODULES}") + string(APPEND __cmake_check "LOADEDMODULES ") + endif() + if(DEFINED __cmake_check) + message(STATUS "NOTE: ${__cmake_check}changed since initial config!") + message(STATUS "NOTE: this may cause unexpected build errors.") + endif() + # loop over variables of interest + foreach(pkgcfgvar PKG_CONFIG_PATH PKG_CONFIG_PATH_DEFAULT + PE_PKG_CONFIG_PATH) + file(TO_CMAKE_PATH "$ENV{${pkgcfgvar}}" pkgcfg) + foreach(path ${pkgcfg}) + string(REGEX REPLACE "(.*)/lib[^/]*/pkgconfig$" "\\1" path "${path}") + if(NOT "${path}" STREQUAL "" AND + NOT "${path}" IN_LIST CMAKE_SYSTEM_PREFIX_PATH) + list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${path}") + endif() + endforeach() + endforeach() + # push it up out of this function into the parent scope + set(CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_SYSTEM_PREFIX_PATH}" PARENT_SCOPE) + endif() +endfunction() + +# The wrapper disables dynamic linking by default. Dynamic linking is +# enabled either by setting $ENV{CRAYPE_LINK_TYPE} to "dynamic" or by +# specifying "-dynamic" to the wrapper when linking. Specifying "-static" +# to the wrapper when linking takes priority over $ENV{CRAYPE_LINK_TYPE}. +# Furthermore, if you specify multiple "-dynamic" and "-static" flags to +# the wrapper when linking, the last one will win. In this case, the +# wrapper will also print a warning like: +# Warning: -dynamic was already seen on command line, overriding with -static. +# +# note that cmake applies both CMAKE_${lang}_FLAGS and CMAKE_EXE_LINKER_FLAGS +# (in that order) to the linking command, so -dynamic can appear in either +# variable. +function(__cmake_craype_linktype lang rv) + # start with ENV, but allow flags to override + if("$ENV{CRAYPE_LINK_TYPE}" STREQUAL "dynamic") + set(linktype dynamic) + else() + set(linktype static) + endif() + # combine flags and convert to a list so we can apply the flags in order + set(linkflags "${CMAKE_${lang}_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") + string(REPLACE " " ";" linkflags "${linkflags}") + foreach(flag IN LISTS linkflags) + if("${flag}" STREQUAL "-dynamic") + set(linktype dynamic) + elseif("${flag}" STREQUAL "-static") + set(linktype static) + endif() + endforeach() + set(${rv} ${linktype} PARENT_SCOPE) +endfunction() macro(__CrayPrgEnv_setup lang) if(DEFINED ENV{CRAYPE_VERSION}) @@ -13,25 +98,25 @@ macro(__CrayPrgEnv_setup lang) message(STATUS "Cray Programming Environment (unknown version) ${lang}") endif() + # setup the craype environment + __cmake_craype_setupenv() + # Flags for the Cray wrappers set(CMAKE_STATIC_LIBRARY_LINK_${lang}_FLAGS "-static") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-dynamic") - # If the link type is not explicitly specified in the environment then - # the Cray wrappers assume that the code will be built statically so - # we check the following condition(s) are NOT met - # Compiler flags are explicitly dynamic - # Env var is dynamic and compiler flags are not explicitly static - if(NOT (((CMAKE_${lang}_FLAGS MATCHES "(^| )-dynamic($| )") OR - (CMAKE_EXE_LINKER_FLAGS MATCHES "(^| )-dynamic($| )")) - OR - (("$ENV{CRAYPE_LINK_TYPE}" STREQUAL "dynamic") AND - NOT ((CMAKE_${lang}_FLAGS MATCHES "(^| )-static($| )") OR - (CMAKE_EXE_LINKER_FLAGS MATCHES "(^| )-static($| )"))))) + # determine linktype from environment and compiler flags + __cmake_craype_linktype(${lang} __cmake_craype_${lang}_linktype) + + # switch off shared libs if we get a static linktype + if("${__cmake_craype_${lang}_linktype}" STREQUAL "static") set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) set(BUILD_SHARED_LIBS FALSE CACHE BOOL "") set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(CMAKE_LINK_SEARCH_START_STATIC TRUE) endif() + endmacro() + +cmake_policy(POP) diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index f072c54..ca286b3 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -10,13 +10,16 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake index 0058223..7202607 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -19,6 +19,7 @@ endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) # 4.3 supports 0x variants set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x") diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake index 16b7bbd..097fbf3 100644 --- a/Modules/Compiler/GNU-FindBinUtils.cmake +++ b/Modules/Compiler/GNU-FindBinUtils.cmake @@ -18,7 +18,7 @@ get_filename_component(__gcc_hints "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPIL find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x_y}" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar-${__version_x}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ar${_CMAKE_COMPILER_SUFFIX}" HINTS ${__gcc_hints} DOC "A wrapper around 'ar' adding the appropriate '--plugin' option for the GCC compiler" ) @@ -28,7 +28,7 @@ mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_AR) find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x_y}" "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib-${__version_x}" - "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib" + "${_CMAKE_TOOLCHAIN_PREFIX}gcc-ranlib${_CMAKE_COMPILER_SUFFIX}" HINTS ${__gcc_hints} DOC "A wrapper around 'ranlib' adding the appropriate '--plugin' option for the GCC compiler" ) diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake index e12bfd1..f9c0ced 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -3,21 +3,20 @@ include(Compiler/IAR) if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") -set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_ARM(ASM) + set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") + __compiler_iar_ilink(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) - string(APPEND CMAKE_ASM_FLAGS_INIT " ") - string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") - string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") - string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") + set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") + __compiler_iar_ilink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -S <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") - __compiler_iar_AVR(ASM) + __compiler_iar_xlink(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa) else() - message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic.") + message(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.") endif() diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index b5e61f0..cb10020 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -3,44 +3,39 @@ include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -# The toolchains for ARM and AVR are quite different: -if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - if(NOT CMAKE_C_COMPILER_VERSION) - message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") - endif() +# Common +if(NOT CMAKE_C_COMPILER_VERSION) + message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") +endif() - set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) +set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) +if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) + set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89) + set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e) + set(CMAKE_C99_STANDARD_COMPILE_OPTION "") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e) +elseif() set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e) +endif() - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.10) - set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89) - set(CMAKE_C90_EXTENSION_COMPILE_OPTION --c89 -e) - set(CMAKE_C99_STANDARD_COMPILE_OPTION "") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e) - endif() - if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.10) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e) - endif() +if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION -e) +endif() - __compiler_iar_ARM(C) +# Architecture specific +if("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + __compiler_iar_ilink(C) __compiler_check_default_language_standard(C 1.10 90 6.10 99 8.10 11) -elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") - if(NOT CMAKE_C_COMPILER_VERSION) - message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") - endif() - - set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) - - set(CMAKE_C90_STANDARD_COMPILE_OPTION --c89) - set(CMAKE_C90_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_C99_STANDARD_COMPILE_OPTION "") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION -e) +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") + __compiler_iar_ilink(C) + __compiler_check_default_language_standard(C 1.10 90 2.10 99 4.10 11) - __compiler_iar_AVR(C) +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") + __compiler_iar_xlink(C) __compiler_check_default_language_standard(C 7.10 99) set(CMAKE_C_OUTPUT_EXTENSION ".r90") @@ -48,9 +43,6 @@ elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") set(CMAKE_C_LINK_FLAGS "-Fmotorola") endif() - set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") - set(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ") - # add the target specific include directory: get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) get_filename_component(_compilerDir "${_compilerDir}" PATH) @@ -58,5 +50,5 @@ elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") include_directories("${_compilerDir}/inc/Atmel" ) else() - message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic.") + message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.") endif() diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index b7076f5..eb27e3c 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -3,60 +3,45 @@ include(Compiler/IAR) include(Compiler/CMakeCommonCompilerMacros) -if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - # "(extended) embedded C++" Mode - # old version: --ec++ or --eec++ - # since 8.10: --c++ --no_exceptions --no_rtti - # - # --c++ is full C++ and supported since 6.10 - if(NOT CMAKE_IAR_CXX_FLAG) - if(NOT CMAKE_CXX_COMPILER_VERSION) - message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") - endif() - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.10) - set(CMAKE_IAR_CXX_FLAG --c++) - else() - set(CMAKE_IAR_CXX_FLAG --eec++) - endif() +# Common +if(NOT CMAKE_IAR_CXX_FLAG) + if(NOT CMAKE_CXX_COMPILER_VERSION) + message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") + endif() + if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) + set(CMAKE_IAR_CXX_FLAG --c++) + else() + set(CMAKE_IAR_CXX_FLAG --eec++) endif() +endif() - set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) +set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) +if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e) - - if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.10) set(CMAKE_CXX03_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX03_EXTENSION_COMPILE_OPTION -e) +endif() + +if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -e) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -e) - endif() +endif() - __compiler_iar_ARM(CXX) +# Architecture specific +if("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") + __compiler_iar_ilink(CXX) __compiler_check_default_language_standard(CXX 6.10 98 8.10 14) -elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") - # "embedded C++" --EC++ is probably closest to CXX98 but with no support for: - # Templates, multiple inheritance, virtual inheritance, exceptions, RTTI, C++ style casts, - # Namespaces, the mutable attribute, no STL, any library features related to the above features. - # - # "(extended) embedded C++" --EEC++ Mode but DOES NOT support any normal C++ standard - # probably closest to CXX98 but with no RTTI and no exceptions, and the library - # provided is not in the standard namespace - if(NOT CMAKE_IAR_CXX_FLAG) - if(NOT CMAKE_CXX_COMPILER_VERSION) - message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") - endif() - set(CMAKE_IAR_CXX_FLAG --eec++) - endif() +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") + __compiler_iar_ilink(CXX) + __compiler_check_default_language_standard(CXX 2.10 98 4.10 14) - set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -e) - - __compiler_iar_AVR(CXX) +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") + __compiler_iar_xlink(CXX) __compiler_check_default_language_standard(CXX 7.10 98) set(CMAKE_CXX_OUTPUT_EXTENSION ".r90") @@ -64,15 +49,12 @@ elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") set(CMAKE_CXX_LINK_FLAGS "-Fmotorola") endif() - set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <OBJECTS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") - set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -o <TARGET> <OBJECTS> ") - # add the target specific include directory: get_filename_component(_compilerDir "${CMAKE_C_COMPILER}" PATH) get_filename_component(_compilerDir "${_compilerDir}" PATH) - include_directories("${_compilerDir}/inc") - include_directories("${_compilerDir}/inc/Atmel") + include_directories("${_compilerDir}/inc" ) + include_directories("${_compilerDir}/inc/Atmel" ) else() - message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected as \"AVR\" or \"ARM\". This should be automatic." ) + message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected. This should be automatic." ) endif() diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake index 43477ac..cdfb095 100644 --- a/Modules/Compiler/IAR-DetermineCompiler.cmake +++ b/Modules/Compiler/IAR-DetermineCompiler.cmake @@ -31,7 +31,7 @@ set(_compiler_id_version_compute " # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000) # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000) # define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__) -# elif defined(__VER__) && defined(__ICCAVR__) +# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__)) # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100) # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100)) # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__) diff --git a/Modules/Compiler/IAR-FindBinUtils.cmake b/Modules/Compiler/IAR-FindBinUtils.cmake index 5fecb26..e8f5e6b 100644 --- a/Modules/Compiler/IAR-FindBinUtils.cmake +++ b/Modules/Compiler/IAR-FindBinUtils.cmake @@ -10,39 +10,39 @@ get_filename_component(__iar_hint_2 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPI set(__iar_hints "${__iar_hint_1}" "${__iar_hint_2}") -if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") - # could allow using normal binutils ar, since objects are normal ELF files? - find_program(CMAKE_IAR_LINKARM ilinkarm.exe HINTS ${__iar_hints} - DOC "The IAR ARM linker") +if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") + # could allow using normal binutils ar, since objects are normal ELF files? + find_program(CMAKE_IAR_LINKER ilink${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}.exe HINTS ${__iar_hints} + DOC "The IAR ILINK linker") find_program(CMAKE_IAR_ARCHIVE iarchive.exe HINTS ${__iar_hints} DOC "The IAR archiver") # find auxiliary tools find_program(CMAKE_IAR_ELFTOOL ielftool.exe HINTS ${__iar_hints} DOC "The IAR ELF Tool") - find_program(CMAKE_IAR_ELFDUMP ielfdumparm.exe HINTS ${__iar_hints} + find_program(CMAKE_IAR_ELFDUMP ielfdump${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}.exe HINTS ${__iar_hints} DOC "The IAR ELF Dumper") find_program(CMAKE_IAR_OBJMANIP iobjmanip.exe HINTS ${__iar_hints} DOC "The IAR ELF Object Tool") find_program(CMAKE_IAR_SYMEXPORT isymexport.exe HINTS ${__iar_hints} DOC "The IAR Absolute Symbol Exporter") - mark_as_advanced(CMAKE_IAR_LINKARM CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT) + mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_ARCHIVE CMAKE_IAR_ELFTOOL CMAKE_IAR_ELFDUMP CMAKE_IAR_OBJMANIP CMAKE_IAR_SYMEXPORT) set(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CUSTOM_CODE -"set(CMAKE_IAR_LINKARM \"${CMAKE_IAR_LINKARM}\") +"set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\") set(CMAKE_IAR_ARCHIVE \"${CMAKE_IAR_ARCHIVE}\") set(CMAKE_IAR_ELFTOOL \"${CMAKE_IAR_ELFTOOL}\") set(CMAKE_IAR_ELFDUMP \"${CMAKE_IAR_ELFDUMP}\") set(CMAKE_IAR_OBJMANIP \"${CMAKE_IAR_OBJMANIP}\") -set(CMAKE_IAR_LINKARM \"${CMAKE_IAR_LINKARM}\") +set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\") ") - elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") # For AVR and AVR32, IAR uses the "xlink" linker and the "xar" archiver: find_program(CMAKE_IAR_LINKER xlink.exe HINTS ${__iar_hints} - DOC "The IAR AVR linker") + DOC "The IAR XLINK linker") find_program(CMAKE_IAR_AR xar.exe HINTS ${__iar_hints} DOC "The IAR archiver") mark_as_advanced(CMAKE_IAR_LINKER CMAKE_IAR_AR) diff --git a/Modules/Compiler/IAR.cmake b/Modules/Compiler/IAR.cmake index bbcdea2..8e75caa 100644 --- a/Modules/Compiler/IAR.cmake +++ b/Modules/Compiler/IAR.cmake @@ -2,11 +2,16 @@ # Documentation can be downloaded here: http://www.iar.com/website1/1.0.1.0/675/1/ # The initial feature request is here: https://gitlab.kitware.com/cmake/cmake/issues/10176 # It also contains additional links and information. -# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for: +# See USER GUIDES -> C/C++ Development Guide and ReleaseNotes for EWARM: # version 6.30.8: http://supp.iar.com/FilesPublic/UPDINFO/006607/arm/doc/infocenter/index.ENU.html # version 7.60.1: http://supp.iar.com/FilesPublic/UPDINFO/011006/arm/doc/infocenter/index.ENU.html # version 8.10.1: http://netstorage.iar.com/SuppDB/Public/UPDINFO/011854/arm/doc/infocenter/index.ENU.html +# The IAR internal compiler platform generations (Predefined symbol __IAR_SYSTEMS_ICC__): +# 9 and higher means C11 and C++14 as language default (EWARM v8.x, EWRX v4.x and higher) +# 8 means C99 and C++03 as language default (EWARM v6.x, v7.x. EWRX v2.x, 3.x) +# 7 and lower means C89 and EC++ as language default. (EWARM v5.x and lower) + # C/C++ Standard versions # # IAR typically only supports one C and C++ Standard version, @@ -33,15 +38,11 @@ # code and data size printouts (that can be inspected with common tools). # This module is shared by multiple languages; use include blocker. -if(_IARARM_CMAKE_LOADED) - return() -endif() -set(_IARARM_CMAKE_LOADED 1) +include_guard() -macro(__compiler_iar_ARM lang) +macro(__compiler_iar_ilink lang) set(CMAKE_EXECUTABLE_SUFFIX ".elf") if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX") - set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT>") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> --preprocess=cnl <PREPROCESSED_SOURCE>") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> ${CMAKE_IAR_${lang}_FLAG} --silent <SOURCE> <DEFINES> <INCLUDES> <FLAGS> -lAH <ASSEMBLY_SOURCE> -o <OBJECT>.dummy") @@ -56,17 +57,25 @@ macro(__compiler_iar_ARM lang) string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG") endif() - set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKARM}\" --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") + if (${lang} STREQUAL "ASM") + string(APPEND CMAKE_ASM_FLAGS_INIT " ") + string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") + string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") + string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") + string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") + endif() + + set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKER}\" --silent <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --create <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_IAR_ARCHIVE}\" <TARGET> --replace <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_FINISH "") - set(CMAKE_LINKER "${CMAKE_IAR_LINKARM}" CACHE FILEPATH "The IAR linker" FORCE) + set(CMAKE_LINKER "${CMAKE_IAR_LINKER}" CACHE FILEPATH "The IAR linker" FORCE) set(CMAKE_AR "${CMAKE_IAR_ARCHIVE}" CACHE FILEPATH "The IAR archiver" FORCE) endmacro() -macro(__compiler_iar_AVR lang) +macro(__compiler_iar_xlink lang) set(CMAKE_EXECUTABLE_SUFFIX ".bin") if (${lang} STREQUAL "C" OR ${lang} STREQUAL "CXX") @@ -84,6 +93,14 @@ macro(__compiler_iar_AVR lang) string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Oh -r -DNDEBUG") endif() + if (${lang} STREQUAL "ASM") + string(APPEND CMAKE_ASM_FLAGS_INIT " ") + string(APPEND CMAKE_ASM_FLAGS_DEBUG_INIT " -r") + string(APPEND CMAKE_ASM_FLAGS_MINSIZEREL_INIT " -DNDEBUG") + string(APPEND CMAKE_ASM_FLAGS_RELEASE_INIT " -DNDEBUG") + string(APPEND CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT " -r -DNDEBUG") + endif() + set(CMAKE_${lang}_LINK_EXECUTABLE "\"${CMAKE_IAR_LINKER}\" -S <OBJECTS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> -o <TARGET>") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_AR}\" <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_AR}\" <TARGET> <LINK_FLAGS> <OBJECTS>") diff --git a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake index e5b9741..899e284 100644 --- a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake +++ b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake @@ -1,14 +1,6 @@ set(_compiler_id_version_compute " -# if defined(__ibmxl__) -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__) -# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__) -# else - /* __IBMC__ = VRP */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMC__/100) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMC__/10 % 10) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMC__ % 10) -# endif -") + /* __IBMC__ = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMC__/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMC__/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMC__ % 10)") diff --git a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake index 63c3e32..73aa2b4 100644 --- a/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake +++ b/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake @@ -1,14 +1,6 @@ set(_compiler_id_version_compute " -# if defined(__ibmxl__) -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__) -# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__) -# else - /* __IBMCPP__ = VRP */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMCPP__/100) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMCPP__/10 % 10) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMCPP__ % 10) -# endif -") + /* __IBMCPP__ = VRP */ +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__IBMCPP__/100) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__IBMCPP__/10 % 10) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__IBMCPP__ % 10)") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 4e4af29..e9e59a2 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -12,13 +12,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-Qstd=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-Qstd=c89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-Qstd=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-Qstd=c99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() else() @@ -26,13 +29,16 @@ else() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() endif() diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index c115b6a..471dd4a 100644 --- a/Modules/Compiler/Intel-CXX.cmake +++ b/Modules/Compiler/Intel-CXX.cmake @@ -30,6 +30,7 @@ if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) endif() else() @@ -64,6 +65,7 @@ else() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) endif() endif() diff --git a/Modules/Compiler/Intel-DetermineCompiler.cmake b/Modules/Compiler/Intel-DetermineCompiler.cmake index d7e4532..c31aa77 100644 --- a/Modules/Compiler/Intel-DetermineCompiler.cmake +++ b/Modules/Compiler/Intel-DetermineCompiler.cmake @@ -18,9 +18,23 @@ set(_compiler_id_version_compute " /* _MSC_VER = VVRR */ # define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(_MSC_VER / 100) # define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(_MSC_VER % 100) +# endif +# if defined(__GNUC__) +# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUC__) +# elif defined(__GNUG__) +# define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUG__) +# endif +# if defined(__GNUC_MINOR__) +# define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__) +# endif +# if defined(__GNUC_PATCHLEVEL__) +# define @PREFIX@SIMULATE_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__) # endif") set(_compiler_id_simulate " # if defined(_MSC_VER) # define @PREFIX@SIMULATE_ID \"MSVC\" +# endif +# if defined(__GNUC__) +# define @PREFIX@SIMULATE_ID \"GNU\" # endif") diff --git a/Modules/Compiler/MIPSpro-C.cmake b/Modules/Compiler/MIPSpro-C.cmake deleted file mode 100644 index 675560c..0000000 --- a/Modules/Compiler/MIPSpro-C.cmake +++ /dev/null @@ -1 +0,0 @@ -set(CMAKE_C_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/MIPSpro-CXX.cmake b/Modules/Compiler/MIPSpro-CXX.cmake deleted file mode 100644 index 9fb191c..0000000 --- a/Modules/Compiler/MIPSpro-CXX.cmake +++ /dev/null @@ -1 +0,0 @@ -set(CMAKE_CXX_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake b/Modules/Compiler/MIPSpro-DetermineCompiler.cmake deleted file mode 100644 index 9e48553..0000000 --- a/Modules/Compiler/MIPSpro-DetermineCompiler.cmake +++ /dev/null @@ -1,15 +0,0 @@ - -set(_compiler_id_pp_test "defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)") - -set(_compiler_id_version_compute " -# if defined(_SGI_COMPILER_VERSION) - /* _SGI_COMPILER_VERSION = VRP */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_SGI_COMPILER_VERSION/100) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_SGI_COMPILER_VERSION/10 % 10) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_SGI_COMPILER_VERSION % 10) -# else - /* _COMPILER_VERSION = VRP */ -# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(_COMPILER_VERSION/100) -# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(_COMPILER_VERSION/10 % 10) -# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(_COMPILER_VERSION % 10) -# endif") diff --git a/Modules/Compiler/MIPSpro-Fortran.cmake b/Modules/Compiler/MIPSpro-Fortran.cmake deleted file mode 100644 index ffceea8..0000000 --- a/Modules/Compiler/MIPSpro-Fortran.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CMAKE_Fortran_VERBOSE_FLAG "-v") -set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") -set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake index 22c34f8..f56227b 100644 --- a/Modules/Compiler/MSVC-C.cmake +++ b/Modules/Compiler/MSVC-C.cmake @@ -11,8 +11,8 @@ set(CMAKE_C11_EXTENSION_COMPILE_OPTION "") # There is no meaningful default for this set(CMAKE_C_STANDARD_DEFAULT "") -# There are no C compiler modes so we only need to test features once. -# Override the default macro for this special case. Pretend that +# There are no C compiler modes so we hard-code the known compiler supported +# features. Override the default macro for this special case. Pretend that # all language standards are available so that at least compilation # can be attempted. macro(cmake_record_c_compile_features) @@ -20,6 +20,14 @@ macro(cmake_record_c_compile_features) c_std_90 c_std_99 c_std_11 + c_function_prototypes ) - _record_compiler_features(C "" CMAKE_C_COMPILE_FEATURES) + list(APPEND CMAKE_C90_COMPILE_FEATURES c_std_90 c_function_prototypes) + list(APPEND CMAKE_C99_COMPILE_FEATURES c_std_99) + list(APPEND CMAKE_C11_COMPILE_FEATURES c_std_11) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + list(APPEND CMAKE_C_COMPILE_FEATURES c_variadic_macros) + list(APPEND CMAKE_C99_COMPILE_FEATURES c_variadic_macros) + endif() + set(_result 0) # expected by cmake_determine_compile_features endmacro() diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index be259ff..691926f 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -11,6 +11,7 @@ if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND # with the default and minimum level being C++14. set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "") set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std:c++14") diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index 3b3848a..c39dbe5 100644 --- a/Modules/Compiler/PGI-C.cmake +++ b/Modules/Compiler/PGI-C.cmake @@ -6,11 +6,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89) set(CMAKE_C90_EXTENSION_COMPILE_OPTION -c89) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15.3) set(CMAKE_C11_STANDARD_COMPILE_OPTION -c11) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -c11) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif () diff --git a/Modules/Compiler/PGI-CXX.cmake b/Modules/Compiler/PGI-CXX.cmake index 35076bb..c77de36 100644 --- a/Modules/Compiler/PGI-CXX.cmake +++ b/Modules/Compiler/PGI-CXX.cmake @@ -6,15 +6,19 @@ string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -DNDEBUG") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -A) set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION --gnu_extensions) + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.10) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION --c++11 -A) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION --c++11 --gnu_extensions) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15.7) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14 -A) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION --c++14 --gnu_extensions) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.1) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION --c++17 -A) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION --c++17 --gnu_extensions) + set(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT ON) endif() endif() endif() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index c4aba8e..7e962b8 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -39,10 +39,13 @@ set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.11) set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") diff --git a/Modules/Compiler/SunPro-CXX-FeatureTests.cmake b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake index 279d875..e7133c1 100644 --- a/Modules/Compiler/SunPro-CXX-FeatureTests.cmake +++ b/Modules/Compiler/SunPro-CXX-FeatureTests.cmake @@ -6,6 +6,14 @@ set(_cmake_oldestSupported "__SUNPRO_CC >= 0x5130") +set(SolarisStudio126_CXX14 "(__SUNPRO_CC >= 0x5150) && __cplusplus >= 201402L") +set(_cmake_feature_test_cxx_aggregate_default_initializers "${SolarisStudio126_CXX14}") +set(_cmake_feature_test_cxx_digit_separators "${SolarisStudio126_CXX14}") +set(_cmake_feature_test_cxx_generic_lambdas "${SolarisStudio126_CXX14}") +set(_cmake_feature_test_cxx_lambda_init_captures "${SolarisStudio126_CXX14}") +set(_cmake_feature_test_cxx_return_type_deduction "${SolarisStudio126_CXX14}") +set(_cmake_feature_test_cxx_variable_templates "${SolarisStudio126_CXX14}") + set(SolarisStudio126_CXX11 "(__SUNPRO_CC >= 0x5150) && __cplusplus >= 201103L") set(_cmake_feature_test_cxx_decltype_auto "${SolarisStudio126_CXX11}") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 5ce58b2..c946c64 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -48,9 +48,15 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++03") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=c++03") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION 1) + + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.14) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=c++14") + endif() else() set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-library=stlport4") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-library=stlport4") diff --git a/Modules/Compiler/XL-C-DetermineCompiler.cmake b/Modules/Compiler/XL-C-DetermineCompiler.cmake index 484811e..3f4e05c 100644 --- a/Modules/Compiler/XL-C-DetermineCompiler.cmake +++ b/Modules/Compiler/XL-C-DetermineCompiler.cmake @@ -1,4 +1,4 @@ -set(_compiler_id_pp_test "defined(__ibmxl__) || (defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800)") +set(_compiler_id_pp_test "defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800") include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-C-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 5dc8bc1..2077bda 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -6,36 +6,18 @@ string(APPEND CMAKE_C_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded") -# XL v13.1.1 for Linux ppc64 little-endian switched to using a clang based -# front end and accepts the -std= option while only reserving -qlanglevel= for -# compatibility. All other versions (previous versions on Linux ppc64 -# little-endian, all versions on Linux ppc64 big-endian, all versions on AIX -# and BGQ, etc) are derived from the UNIX compiler and only accept the -# -qlanglvl option. if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) - if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND - CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) - set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") - set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") - set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") - else () - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") - endif () - else () - set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") - set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") - set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99") - set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99") - if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1) - set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") - set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") - endif () + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif() -__compiler_check_default_language_standard(C 10.1 90) +__compiler_check_default_language_standard(C 10.1 90 11.1 99) diff --git a/Modules/Compiler/XL-CXX-DetermineCompiler.cmake b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake index 2bf1ec6..dffa4bc 100644 --- a/Modules/Compiler/XL-CXX-DetermineCompiler.cmake +++ b/Modules/Compiler/XL-CXX-DetermineCompiler.cmake @@ -1,4 +1,4 @@ -set(_compiler_id_pp_test "defined(__ibmxl__) || (defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800)") +set(_compiler_id_pp_test "defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800") include("${CMAKE_CURRENT_LIST_DIR}/IBMCPP-CXX-DetermineVersionInternal.cmake") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index b87e923..3037851 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -6,41 +6,23 @@ string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL_INIT " -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe string(APPEND CMAKE_CXX_FLAGS_INIT " -qthreaded") -# XL v13.1.1 for Linux ppc64 little-endian switched to using a clang based -# front end and accepts the -std= option while only reserving -qlanglevel= for -# compatibility. All other versions (previous versions on Linux ppc64 -# little-endian, all versions on Linux ppc64 big-endian, all versions on AIX -# and BGQ, etc) are derived from the UNIX compiler and only accept the -# -qlanglvl option. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) - if (CMAKE_SYSTEM MATCHES "Linux.*ppc64") - if (CMAKE_SYSTEM MATCHES "Linux.*ppc64le" AND - CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") - set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") - set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y") - else () - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") - endif () - else () - # The non-clang based Linux ppc64 compiler, both big-endian and - # little-endian lacks, the non-extension language level flags - set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=extended") - set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended") - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") - endif () - else () + if(CMAKE_SYSTEM MATCHES "Linux") + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + else() set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-qlanglvl=strict98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-qlanglvl=extended") - set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") - set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") - endif () + endif() + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-qlanglvl=extended1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-qlanglvl=extended1y") + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + endif() endif () __compiler_check_default_language_standard(CXX 10.1 98) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index 68dc28a..a9cec11 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -10,12 +10,6 @@ set(__COMPILER_XL 1) include(Compiler/CMakeCommonCompilerMacros) -# Find the CreateExportList program that comes with this toolchain. -find_program(CMAKE_XL_CreateExportList - NAMES CreateExportList - DOC "IBM XL CreateExportList tool" - ) - macro(__compiler_xl lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-V") @@ -35,20 +29,4 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE "<CMAKE_${lang}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") set(CMAKE_DEPFILE_FLAGS_${lang} "-MF <DEPFILE> -qmakedep=gcc") - - # 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> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" - ) - endif() endmacro() diff --git a/Modules/Compiler/XLClang-C-DetermineCompiler.cmake b/Modules/Compiler/XLClang-C-DetermineCompiler.cmake new file mode 100644 index 0000000..4d89921 --- /dev/null +++ b/Modules/Compiler/XLClang-C-DetermineCompiler.cmake @@ -0,0 +1,8 @@ +set(_compiler_id_pp_test "defined(__ibmxl__) && defined(__clang__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__) +") diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake new file mode 100644 index 0000000..54c18a6 --- /dev/null +++ b/Modules/Compiler/XLClang-C.cmake @@ -0,0 +1,20 @@ +include(Compiler/XLClang) +__compiler_xlclang(C) + +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) + set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") + set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") + if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) + set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) + endif () +endif() + +__compiler_check_default_language_standard(C 13.1.1 99) diff --git a/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake b/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake new file mode 100644 index 0000000..4d89921 --- /dev/null +++ b/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake @@ -0,0 +1,8 @@ +set(_compiler_id_pp_test "defined(__ibmxl__) && defined(__clang__)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ibmxl_version__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ibmxl_release__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ibmxl_modification__) +# define @PREFIX@COMPILER_VERSION_TWEAK @MACRO_DEC@(__ibmxl_ptf_fix_level__) +") diff --git a/Modules/Compiler/XLClang-CXX.cmake b/Modules/Compiler/XLClang-CXX.cmake new file mode 100644 index 0000000..9ea3d7c --- /dev/null +++ b/Modules/Compiler/XLClang-CXX.cmake @@ -0,0 +1,27 @@ +include(Compiler/XLClang) +__compiler_xlclang(CXX) + +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "") + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "") + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-qlanglvl=extended0x") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-qlanglvl=extended0x") + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + endif () + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.1.0) + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + endif() +endif() + +__compiler_check_default_language_standard(CXX 13.1.1 98) + +set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -x c++ <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>") diff --git a/Modules/Compiler/XLClang.cmake b/Modules/Compiler/XLClang.cmake new file mode 100644 index 0000000..cdf0fdc --- /dev/null +++ b/Modules/Compiler/XLClang.cmake @@ -0,0 +1,22 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_XLCLANG) + return() +endif() +set(__COMPILER_XLCLANG 1) + +include(Compiler/XL) + +macro(__compiler_xlclang lang) + __compiler_xl(${lang}) + + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-V") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIC") + set(CMAKE_${lang}_RESPONSE_FILE_FLAG "@") + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") +endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 22e0523..20b37d2 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -202,23 +202,24 @@ External Project Definition :command:`file(DOWNLOAD)`) ``NETRC <level>`` - Specify whether the .netrc file is to be used for operation. If this - option is not specified, the value of the ``CMAKE_NETRC`` variable - will be used instead (see :command:`file(DOWNLOAD)`) + Specify whether the ``.netrc`` file is to be used for operation. + If this option is not specified, the value of the ``CMAKE_NETRC`` + variable will be used instead (see :command:`file(DOWNLOAD)`) Valid levels are: ``IGNORED`` - The .netrc file is ignored. + The ``.netrc`` file is ignored. This is the default. ``OPTIONAL`` - The .netrc file is optional, and information in the URL is preferred. - The file will be scanned to find which ever information is not specified - in the URL. + The ``.netrc`` file is optional, and information in the URL + is preferred. The file will be scanned to find which ever + information is not specified in the URL. ``REQUIRED`` - The .netrc file is required, and information in the URL is ignored. + The ``.netrc`` file is required, and information in the URL + is ignored. ``NETRC_FILE <file>`` - Specify an alternative .netrc file to the one in your home directory + Specify an alternative ``.netrc`` file to the one in your home directory if the ``NETRC`` level is ``OPTIONAL`` or ``REQUIRED``. If this option is not specified, the value of the ``CMAKE_NETRC_FILE`` variable will be used instead (see :command:`file(DOWNLOAD)`) @@ -251,6 +252,9 @@ External Project Definition The lack of such deterministic behavior makes the main project lose traceability and repeatability. + If ``GIT_SHALLOW`` is enabled then ``GIT_TAG`` works only with + branch names and tags. A commit hash is not allowed. + ``GIT_REMOTE_NAME <name>`` The optional name of the remote. If this option is not specified, it defaults to ``origin``. @@ -418,6 +422,10 @@ External Project Definition different behavior depending on whether the build starts from a fresh build directory or re-uses previous build contents. + If the CMake generator is the ``Green Hills MULTI`` and not overridden then + the orginal projects settings for the GHS toolset and target system + customization cache variables are propagated into the external project. + ``SOURCE_SUBDIR <dir>`` When no ``CONFIGURE_COMMAND`` option is specified, the configure step assumes the external project has a ``CMakeLists.txt`` file at the top of @@ -1053,11 +1061,6 @@ define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED ) function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify) - if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10) - set(git_clone_shallow_options "--depth 1 --no-single-branch") - else() - set(git_clone_shallow_options "--depth 1") - endif() if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5) # Use `git checkout <tree-ish> --` to avoid ambiguity with a local path. set(git_checkout_explicit-- "--") @@ -1067,18 +1070,41 @@ function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git # because that will not search for remote branch names, a common use case. set(git_checkout_explicit-- "") endif() - file(WRITE ${script_filename} -"if(\"${git_tag}\" STREQUAL \"\") - message(FATAL_ERROR \"Tag for git checkout should not be empty.\") -endif() + if("${git_tag}" STREQUAL "") + message(FATAL_ERROR "Tag for git checkout should not be empty.") + endif() -set(run 0) + set(git_clone_options) + if(git_shallow) + if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.10) + list(APPEND git_clone_options "--depth 1 --no-single-branch") + else() + list(APPEND git_clone_options "--depth 1") + endif() + endif() + if(git_progress) + list(APPEND git_clone_options --progress) + endif() + foreach(config IN LISTS git_config) + list(APPEND git_clone_options --config ${config}) + endforeach() + if(NOT ${git_remote_name} STREQUAL "origin") + list(APPEND git_clone_options --origin \"${git_remote_name}\") + endif() -if(\"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\") - set(run 1) -endif() + string (REPLACE ";" " " git_clone_options "${git_clone_options}") -if(NOT run) + set(git_options) + # disable cert checking if explicitly told not to do it + if(NOT "x${tls_verify}" STREQUAL "x" AND NOT tls_verify) + set(git_options + -c http.sslVerify=false) + endif() + string (REPLACE ";" " " git_options "${git_options}") + + file(WRITE ${script_filename} +" +if(NOT \"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\") message(STATUS \"Avoiding repeated git clone, stamp file is up to date: '${gitclone_stampfile}'\") return() endif() @@ -1091,38 +1117,12 @@ if(error_code) message(FATAL_ERROR \"Failed to remove directory: '${source_dir}'\") endif() -set(git_options) - -# disable cert checking if explicitly told not to do it -set(tls_verify \"${tls_verify}\") -if(NOT \"x${tls_verify}\" STREQUAL \"x\" AND NOT tls_verify) - list(APPEND git_options - -c http.sslVerify=false) -endif() - -set(git_clone_options) - -set(git_shallow \"${git_shallow}\") -if(git_shallow) - list(APPEND git_clone_options ${git_clone_shallow_options}) -endif() - -set(git_progress \"${git_progress}\") -if(git_progress) - list(APPEND git_clone_options --progress) -endif() - -set(git_config \"${git_config}\") -foreach(config IN LISTS git_config) - list(APPEND git_clone_options --config \${config}) -endforeach() - # try the clone 3 times in case there is an odd git clone issue set(error_code 1) set(number_of_tries 0) while(error_code AND number_of_tries LESS 3) execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} clone \${git_clone_options} --origin \"${git_remote_name}\" \"${git_repository}\" \"${src_name}\" + COMMAND \"${git_EXECUTABLE}\" ${git_options} clone ${git_clone_options} \"${git_repository}\" \"${src_name}\" WORKING_DIRECTORY \"${work_dir}\" RESULT_VARIABLE error_code ) @@ -1137,7 +1137,7 @@ if(error_code) endif() execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} checkout ${git_tag} ${git_checkout_explicit--} + COMMAND \"${git_EXECUTABLE}\" ${git_options} checkout ${git_tag} ${git_checkout_explicit--} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -1146,16 +1146,7 @@ if(error_code) endif() execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule init ${git_submodules} - WORKING_DIRECTORY \"${work_dir}/${src_name}\" - RESULT_VARIABLE error_code - ) -if(error_code) - message(FATAL_ERROR \"Failed to init submodules in: '${work_dir}/${src_name}'\") -endif() - -execute_process( - COMMAND \"${git_EXECUTABLE}\" \${git_options} submodule update --recursive --init ${git_submodules} + COMMAND \"${git_EXECUTABLE}\" ${git_options} submodule update --recursive --init ${git_submodules} WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) @@ -1169,7 +1160,6 @@ execute_process( COMMAND \${CMAKE_COMMAND} -E copy \"${gitclone_infofile}\" \"${gitclone_stampfile}\" - WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) if(error_code) @@ -1182,18 +1172,12 @@ endif() endfunction() function(_ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile) + if("${hg_tag}" STREQUAL "") + message(FATAL_ERROR "Tag for hg checkout should not be empty.") + endif() file(WRITE ${script_filename} -"if(\"${hg_tag}\" STREQUAL \"\") - message(FATAL_ERROR \"Tag for hg checkout should not be empty.\") -endif() - -set(run 0) - -if(\"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\") - set(run 1) -endif() - -if(NOT run) +" +if(NOT \"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\") message(STATUS \"Avoiding repeated hg clone, stamp file is up to date: '${hgclone_stampfile}'\") return() endif() @@ -1230,7 +1214,6 @@ execute_process( COMMAND \${CMAKE_COMMAND} -E copy \"${hgclone_infofile}\" \"${hgclone_stampfile}\" - WORKING_DIRECTORY \"${work_dir}/${src_name}\" RESULT_VARIABLE error_code ) if(error_code) @@ -1244,16 +1227,16 @@ endfunction() function(_ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name git_submodules git_repository work_dir) + if("${git_tag}" STREQUAL "") + message(FATAL_ERROR "Tag for git checkout should not be empty.") + endif() if(NOT GIT_VERSION_STRING VERSION_LESS 1.7.6) set(git_stash_save_options --all --quiet) else() set(git_stash_save_options --quiet) endif() file(WRITE ${script_filename} -"if(\"${git_tag}\" STREQUAL \"\") - message(FATAL_ERROR \"Tag for git checkout should not be empty.\") -endif() - +" execute_process( COMMAND \"${git_EXECUTABLE}\" rev-list --max-count=1 HEAD WORKING_DIRECTORY \"${work_dir}\" @@ -2460,7 +2443,7 @@ function(_ep_add_download_command name) # set(repository ${git_repository}) set(module) - set(tag) + set(tag ${git_remote_name}) configure_file( "${CMAKE_ROOT}/Modules/RepositoryInfo.txt.in" "${stamp_dir}/${name}-gitinfo.txt" @@ -2871,18 +2854,6 @@ function(_ep_extract_configure_command var name) set(has_cmake_cache_default_args 1) endif() - if(has_cmake_cache_args OR has_cmake_cache_default_args) - set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") - if(has_cmake_cache_args) - _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) - endif() - if(has_cmake_cache_default_args) - _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0) - endif() - _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") - list(APPEND cmd "-C${_ep_cache_args_script}") - endif() - get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE) get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM) @@ -2903,6 +2874,16 @@ function(_ep_extract_configure_command var name) list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}") else() list(APPEND cmd "-G${CMAKE_GENERATOR}") + if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") + set(has_cmake_cache_default_args 1) + set(cmake_cache_default_args ${cmake_cache_default_args} + "-DGHS_TARGET_PLATFORM:STRING=${GHS_TARGET_PLATFORM}" + "-DGHS_PRIMARY_TARGET:STRING=${GHS_PRIMARY_TARGET}" + "-DGHS_TOOLSET_ROOT:STRING=${GHS_TOOLSET_ROOT}" + "-DGHS_OS_ROOT:STRING=${GHS_OS_ROOT}" + "-DGHS_OS_DIR:STRING=${GHS_OS_DIR}" + "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}") + endif() endif() if(cmake_generator_platform) message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.") @@ -2924,6 +2905,18 @@ function(_ep_extract_configure_command var name) endif() endif() + if(has_cmake_cache_args OR has_cmake_cache_default_args) + set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") + if(has_cmake_cache_args) + _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) + endif() + if(has_cmake_cache_default_args) + _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0) + endif() + _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") + list(APPEND cmd "-C${_ep_cache_args_script}") + endif() + list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>") endif() diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index f27d7fe..88e2681 100644 --- a/Modules/FindALSA.cmake +++ b/Modules/FindALSA.cmake @@ -5,9 +5,9 @@ FindALSA -------- -Find alsa +Find Advanced Linux Sound Architecture (ALSA) -Find the alsa libraries (asound) +Find the alsa libraries (``asound``) IMPORTED Targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index c12512f..9655440 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -7,7 +7,7 @@ FindAVIFile Locate AVIFILE library and include paths -AVIFILE (http://avifile.sourceforge.net/)is a set of libraries for +AVIFILE (http://avifile.sourceforge.net/) is a set of libraries for i386 machines to use various AVI codecs. Support is limited beyond Linux. Windows provides native AVI support, and so doesn't need this library. This module defines diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index ce76c99..c4e55ce 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -5,9 +5,8 @@ FindArmadillo ------------- -Find Armadillo - -Find the Armadillo C++ library +Find the Armadillo C++ library. +Armadillo is library for linear algebra & scientific computing. Using Armadillo: diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index 06ac2d9..e75981c 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -16,10 +16,10 @@ The module defines the following variables: version of ``bison`` ``BISON_FOUND`` - true if the program was found + "True" if the program was found The minimum required version of ``bison`` can be specified using the -standard CMake syntax, e.g. ``find_package(BISON 2.1.3)``. +standard CMake syntax, e.g. :command:`find_package(BISON 2.1.3)`. If ``bison`` is found, the module defines the macro:: @@ -55,7 +55,7 @@ The options are: The macro defines the following variables: ``BISON_<Name>_DEFINED`` - true is the macro ran successfully + ``True`` is the macro ran successfully ``BISON_<Name>_INPUT`` The input source file, an alias for <YaccInput> diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 0aa4f50..77e689f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -5,12 +5,12 @@ FindBLAS -------- -Find BLAS library +Find Basic Linear Algebra Subprograms (BLAS) library -This module finds an installed fortran library that implements the +This module finds an installed Fortran library that implements the BLAS linear-algebra interface (see http://www.netlib.org/blas/). The -list of libraries searched for is taken from the autoconf macro file, -acx_blas.m4 (distributed at +list of libraries searched for is taken from the ``autoconf`` macro file, +``acx_blas.m4`` (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). Input Variables @@ -52,7 +52,7 @@ The following variables may be set to influence this module's behavior: if ``ON`` tries to find the BLAS95 interfaces ``BLA_PREFER_PKGCONFIG`` - if set pkg-config will be used to search for a BLAS library first + if set ``pkg-config`` will be used to search for a BLAS library first and if one is found that is preferred Result Variables @@ -63,7 +63,7 @@ This module defines the following variables: ``BLAS_FOUND`` library implementing the BLAS interface is found ``BLAS_LINKER_FLAGS`` - uncached list of required linker flags (excluding -l and -L). + uncached list of required linker flags (excluding ``-l`` and ``-L``). ``BLAS_LIBRARIES`` uncached list of libraries (using full path name) to link against to use BLAS (may be empty if compiler implicitly links BLAS) @@ -75,7 +75,7 @@ This module defines the following variables: .. note:: - C or CXX must be enabled to use Intel MKL + C or CXX must be enabled to use Intel Math Kernel Library (MKL) For example, to use Intel MKL libraries and/or Intel compiler: @@ -83,6 +83,13 @@ This module defines the following variables: set(BLA_VENDOR Intel10_64lp) find_package(BLAS) + +Hints +^^^^^ + +Set ``MKLROOT`` environment variable to a directory that contains an MKL +installation. + #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) @@ -394,6 +401,24 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif () endif () + if (DEFINED ENV{MKLROOT}) + set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}") + endif () + if (_BLAS_MKLROOT_LIB_DIR) + if( SIZEOF_INTEGER EQUAL 8 ) + set( _BLAS_MKL_PATH_PREFIX "intel64" ) + else() + set( _BLAS_MKL_PATH_PREFIX "ia32" ) + endif() + if (WIN32) + string(APPEND _BLAS_MKLROOT_LIB_DIR "/lib/${_BLAS_MKL_PATH_PREFIX}_win") + elseif (APPLE) + string(APPEND _BLAS_MKLROOT_LIB_DIR "/lib/${_BLAS_MKL_PATH_PREFIX}_mac") + else () + string(APPEND _BLAS_MKLROOT_LIB_DIR "/lib/${_BLAS_MKL_PATH_PREFIX}_lin") + endif () + endif () + foreach (IT ${BLAS_SEARCH_LIBS}) string(REPLACE " " ";" SEARCH_LIBS ${IT}) if (NOT ${_LIBRARIES}) @@ -404,6 +429,7 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") "" "${SEARCH_LIBS}" "${CMAKE_THREAD_LIBS_INIT};${BLAS_mkl_LM};${BLAS_mkl_LDL}" + "${_BLAS_MKLROOT_LIB_DIR}" ) endif () endforeach () diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index e1f45f7..cf1632a 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -5,30 +5,30 @@ FindBacktrace ------------- -Find provider for backtrace(3). +Find provider for `backtrace(3) <http://man7.org/linux/man-pages/man3/backtrace.3.html>`__. -Checks if OS supports backtrace(3) via either libc or custom library. +Checks if OS supports ``backtrace(3)`` via either ``libc`` or custom library. This module defines the following variables: ``Backtrace_HEADER`` - The header file needed for backtrace(3). Cached. + The header file needed for ``backtrace(3)``. Cached. Could be forcibly set by user. ``Backtrace_INCLUDE_DIRS`` - The include directories needed to use backtrace(3) header. + The include directories needed to use ``backtrace(3)`` header. ``Backtrace_LIBRARIES`` - The libraries (linker flags) needed to use backtrace(3), if any. + The libraries (linker flags) needed to use ``backtrace(3)``, if any. ``Backtrace_FOUND`` - Is set if and only if backtrace(3) support detected. + Is set if and only if ``backtrace(3)`` support detected. The following cache variables are also available to set or use: ``Backtrace_LIBRARY`` The external library providing backtrace, if any. ``Backtrace_INCLUDE_DIR`` - The directory holding the backtrace(3) header. + The directory holding the ``backtrace(3)`` header. -Typical usage is to generate of header file using configure_file() with the -contents like the following:: +Typical usage is to generate of header file using :command:`configure_file` +with the contents like the following:: #cmakedefine01 Backtrace_FOUND #if Backtrace_FOUND diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index b5cc4cf..023cc8d 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -85,33 +85,33 @@ The following :prop_tgt:`IMPORTED` targets are also defined:: Boost::dynamic_linking - interface target to enable dynamic linking linking with MSVC (adds BOOST_ALL_DYN_LINK) -Implicit dependencies such as Boost::filesystem requiring -Boost::system will be automatically detected and satisfied, even -if system is not specified when using find_package and if -Boost::system is not added to target_link_libraries. If using -Boost::thread, then Threads::Threads will also be added automatically. +Implicit dependencies such as ``Boost::filesystem`` requiring +``Boost::system`` will be automatically detected and satisfied, even +if system is not specified when using :command:`find_package` and if +``Boost::system`` is not added to :command:`target_link_libraries`. If using +``Boost::thread``, then ``Threads::Threads`` will also be added automatically. It is important to note that the imported targets behave differently than variables created by this module: multiple calls to -find_package(Boost) in the same directory or sub-directories with +:command:`find_package(Boost)` in the same directory or sub-directories with different options (e.g. static or shared) will not override the values of the targets created by the first call. -Users may set these hints or results as cache entries. Projects +Users may set these hints or results as ``CACHE`` entries. Projects should not read these entries directly but instead use the above result variables. Note that some hint names start in upper-case "BOOST". One may specify these as environment variables if they are not specified as CMake variables or cache entries. -This module first searches for the Boost header files using the above -hint variables (excluding BOOST_LIBRARYDIR) and saves the result in -Boost_INCLUDE_DIR. Then it searches for requested component libraries -using the above hints (excluding BOOST_INCLUDEDIR and -Boost_ADDITIONAL_VERSIONS), "lib" directories near Boost_INCLUDE_DIR, +This module first searches for the ``Boost`` header files using the above +hint variables (excluding ``BOOST_LIBRARYDIR``) and saves the result in +``Boost_INCLUDE_DIR``. Then it searches for requested component libraries +using the above hints (excluding ``BOOST_INCLUDEDIR`` and +``Boost_ADDITIONAL_VERSIONS``), "lib" directories near ``Boost_INCLUDE_DIR``, and the library name configuration settings below. It saves the -library directories in Boost_LIBRARY_DIR_DEBUG and -Boost_LIBRARY_DIR_RELEASE and individual library -locations in Boost_<C>_LIBRARY_DEBUG and Boost_<C>_LIBRARY_RELEASE. +library directories in ``Boost_LIBRARY_DIR_DEBUG`` and +``Boost_LIBRARY_DIR_RELEASE`` and individual library +locations in ``Boost_<C>_LIBRARY_DEBUG`` and ``Boost_<C>_LIBRARY_RELEASE``. When one changes settings used by previous searches in the same build tree (excluding environment variables) this module discards previous search results affected by the changes and searches again. @@ -179,9 +179,9 @@ Other variables one may set to control this module are:: On Visual Studio and Borland compilers Boost headers request automatic linking to corresponding libraries. This requires matching libraries to be linked explicitly or available in the link library search path. -In this case setting Boost_USE_STATIC_LIBS to OFF may not achieve +In this case setting ``Boost_USE_STATIC_LIBS`` to ``OFF`` may not achieve dynamic linking. Boost automatic linking typically requests static -libraries with a few exceptions (such as Boost.Python). Use:: +libraries with a few exceptions (such as ``Boost.Python``). Use:: add_definitions(${Boost_LIB_DIAGNOSTIC_DEFINITIONS}) @@ -230,12 +230,12 @@ Boost CMake If Boost was built using the boost-cmake project it provides a package configuration file for use with find_package's Config mode. This module looks for the package configuration file called -BoostConfig.cmake or boost-config.cmake and stores the result in cache -entry "Boost_DIR". If found, the package configuration file is loaded +``BoostConfig.cmake`` or ``boost-config.cmake`` and stores the result in +``CACHE`` entry "Boost_DIR". If found, the package configuration file is loaded and this module returns with no further action. See documentation of the Boost CMake package configuration for details on what it provides. -Set Boost_NO_BOOST_CMAKE to ON to disable the search for boost-cmake. +Set ``Boost_NO_BOOST_CMAKE`` to ``ON``, to disable the search for boost-cmake. #]=======================================================================] # Save project's policies @@ -465,7 +465,7 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) endif() elseif (GHSMULTI) set(_boost_COMPILER "-ghs") - elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC") + elseif("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(MSVC_TOOLSET_VERSION GREATER_EQUAL 150) # Not yet known. set(_boost_COMPILER "") @@ -486,6 +486,12 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) else() # VS 6.0 Good luck! set(_boost_COMPILER "-vc6") # yes, this is correct endif() + + if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xClang") + string(REPLACE "." ";" VERSION_LIST "${CMAKE_CXX_COMPILER_VERSION}") + list(GET VERSION_LIST 0 CLANG_VERSION_MAJOR) + set(_boost_COMPILER "-clangw${CLANG_VERSION_MAJOR};${_boost_COMPILER}") + endif() elseif (BORLAND) set(_boost_COMPILER "-bcb") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") @@ -1048,11 +1054,17 @@ endfunction() # Some boost libraries may require particular set of compler features. # The very first one was `boost::fiber` introduced in Boost 1.62. # One can check required compiler features of it in -# `${Boost_ROOT}/libs/fiber/build/Jamfile.v2`. +# - `${Boost_ROOT}/libs/fiber/build/Jamfile.v2`; +# - `${Boost_ROOT}/libs/context/build/Jamfile.v2`. +# +# TODO (Re)Check compiler features on (every?) release ??? +# One may use the following command to get the files to check: +# +# $ find . -name Jamfile.v2 | grep build | xargs grep -l cxx1 # function(_Boost_COMPILER_FEATURES component _ret) - # Boost >= 1.62 and < 1.67 - if(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106700) + # Boost >= 1.62 + if(NOT Boost_VERSION VERSION_LESS 106200) set(_Boost_FIBER_COMPILER_FEATURES cxx_alias_templates cxx_auto_type @@ -1066,6 +1078,8 @@ function(_Boost_COMPILER_FEATURES component _ret) cxx_thread_local cxx_variadic_templates ) + # Compiler feature for `context` same as for `fiber`. + set(_Boost_CONTEXT_COMPILER_FEATURES ${_Boost_FIBER_COMPILER_FEATURES}) endif() string(TOUPPER ${component} uppercomponent) set(${_ret} ${_Boost_${uppercomponent}_COMPILER_FEATURES} PARENT_SCOPE) @@ -1216,6 +1230,8 @@ if(NOT TARGET Boost::diagnostic_definitions) add_library(Boost::diagnostic_definitions INTERFACE IMPORTED) add_library(Boost::disable_autolinking INTERFACE IMPORTED) add_library(Boost::dynamic_linking INTERFACE IMPORTED) + set_target_properties(Boost::dynamic_linking PROPERTIES + INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") endif() if(WIN32) # In windows, automatic linking is performed, so you do not have @@ -1240,8 +1256,6 @@ if(WIN32) INTERFACE_COMPILE_DEFINITIONS "BOOST_LIB_DIAGNOSTIC") set_target_properties(Boost::disable_autolinking PROPERTIES INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_NO_LIB") - set_target_properties(Boost::dynamic_linking PROPERTIES - INTERFACE_COMPILE_DEFINITIONS "BOOST_ALL_DYN_LINK") endif() _Boost_CHECK_SPELLING(Boost_ROOT) diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index b1989b1..aeebc84 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -27,16 +27,16 @@ Result Variables This module defines the following variables: ``CURL_FOUND`` - True if curl found. + "True" if ``curl`` found. ``CURL_INCLUDE_DIRS`` - where to find curl/curl.h, etc. + where to find ``curl``/``curl.h``, etc. ``CURL_LIBRARIES`` - List of libraries when using curl. + List of libraries when using ``curl``. ``CURL_VERSION_STRING`` - The version of curl found. + The version of ``curl`` found. #]=======================================================================] find_package(PkgConfig QUIET) diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake index 89dbc0e..f819800 100644 --- a/Modules/FindCVS.cmake +++ b/Modules/FindCVS.cmake @@ -5,7 +5,7 @@ FindCVS ------- - +Find the Concurrent Versions System (CVS). The module defines the following variables: diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 10ce229..4e8232d 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -5,18 +5,38 @@ FindCups -------- -Try to find the Cups printing system +Find the Common UNIX Printing System (CUPS). -Once done this will define +Set ``CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE`` to ``TRUE`` if you need a version which +features this function (i.e. at least ``1.1.19``) -:: +Imported targets +^^^^^^^^^^^^^^^^ - CUPS_FOUND - system has Cups - CUPS_INCLUDE_DIR - the Cups include directory - CUPS_LIBRARIES - Libraries needed to use Cups - CUPS_VERSION_STRING - version of Cups found (since CMake 2.8.8) - Set CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE to TRUE if you need a version which - features this function (i.e. at least 1.1.19) +This module defines :prop_tgt:`IMPORTED` target ``Cups::Cups``, if Cups has +been found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``CUPS_FOUND`` + true if CUPS headers and libraries were found +``CUPS_INCLUDE_DIRS`` + the directory containing the Cups headers +``CUPS_LIBRARIES`` + the libraries to link against to use CUPS. +``CUPS_VERSION_STRING`` + the version of CUPS found (since CMake 2.8.8) + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``CUPS_INCLUDE_DIR`` + the directory containing the Cups headers #]=======================================================================] find_path(CUPS_INCLUDE_DIR cups/cups.h ) @@ -66,3 +86,13 @@ else () endif () mark_as_advanced(CUPS_INCLUDE_DIR CUPS_LIBRARIES) + +if (CUPS_FOUND) + set(CUPS_INCLUDE_DIRS "${CUPS_INCLUDE_DIR}") + if (NOT TARGET Cups::Cups) + add_library(Cups::Cups INTERFACE IMPORTED) + set_target_properties(Cups::Cups PROPERTIES + INTERFACE_LINK_LIBRARIES "${CUPS_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${CUPS_INCLUDE_DIR}") + endif () +endif () diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 4eec5fc..321f004 100644 --- a/Modules/FindCxxTest.cmake +++ b/Modules/FindCxxTest.cmake @@ -5,7 +5,7 @@ FindCxxTest ----------- -Find CxxTest +Find CxxTest unit testing framework. Find the CxxTest suite and declare a helper macro for creating unit tests and integrating them with CTest. For more details on CxxTest diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake index 8811623..5bbc802 100644 --- a/Modules/FindCygwin.cmake +++ b/Modules/FindCygwin.cmake @@ -5,7 +5,8 @@ FindCygwin ---------- -this module looks for Cygwin +Find Cygwin, a POSIX-compatible environment that runs natively +on Microsoft Windows #]=======================================================================] if (WIN32) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 111e0ff..d48de08 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -5,7 +5,7 @@ FindDCMTK --------- -Find DCMTK libraries and applications +Find DICOM ToolKit (DCMTK) libraries and applications The module defines the following variables:: diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 58e0841..15b419a 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -6,6 +6,7 @@ FindEXPAT --------- Find the native Expat headers and library. +Expat is a stream-oriented XML parser library written in C. Imported Targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindEnvModules.cmake b/Modules/FindEnvModules.cmake new file mode 100644 index 0000000..5d3452d --- /dev/null +++ b/Modules/FindEnvModules.cmake @@ -0,0 +1,333 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindEnvModules +-------------- + +Locate an environment module implementation and make commands available to +CMake scripts to use them. This is compatible with both Lua-based Lmod +and TCL-based EnvironmentModules. + +This module is intended for the use case of setting up the compiler and library +environment within a :ref:`CTest Script <CTest Script>` (``ctest -S``). It can +also be used in a :ref:`CMake Script <Script Processing Mode>` (``cmake -P``). + +.. note:: + + The loaded environment will not survive past the end of the calling process. + Do not use this module in project code (``CMakeLists.txt`` files) to load + a compiler environment; it will not be available during the build. Instead + load the environment manually before running CMake or using the generated + build system. + +Example Usage +^^^^^^^^^^^^^ + +.. code-block:: cmake + + set(CTEST_BUILD_NAME "CrayLinux-CrayPE-Cray-dynamic") + set(CTEST_BUILD_CONFIGURATION Release) + set(CTEST_BUILD_FLAGS "-k -j8") + set(CTEST_CMAKE_GENERATOR "Unix Makefiles") + + ... + + find_package(EnvModules REQUIRED) + + env_module(purge) + env_module(load modules) + env_module(load craype) + env_module(load PrgEnv-cray) + env_module(load craype-knl) + env_module(load cray-mpich) + env_module(load cray-libsci) + + set(ENV{CRAYPE_LINK_TYPE} dynamic) + + ... + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``EnvModules_FOUND`` + Found the a compatible environment modules framework + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variable will be set: + +``EnvModules_COMMAND`` + The low level module command to use. Currently supported are + implementations are the Lua based Lmod and TCL based EnvironmentModules. + +Environment Variables +^^^^^^^^^^^^^^^^^^^^^ + +``ENV{MODULESHOME}`` + Usually set by the module environment implementation, used as a hint to + locate the module command to execute. + +Provided Functions +^^^^^^^^^^^^^^^^^^ + +This defines the following cmake functions for interacting with environment +modules: + +.. command:: env_module + + Execute an aribitrary module command: + + .. code-block:: cmake + + env_module(cmd arg1 ... argN) + env_module( + COMMAND cmd arg1 ... argN + [OUTPUT_VARIABLE <out-var>] + [RESULT_VARIABLE <ret-var>] + ) + + The options are: + + ``cmd arg1 ... argN`` + The module sub-command and arguments to execute as if they were + passed directly to the module command in your shell environment. + + ``OUTPUT_VARIABLE <out-var>`` + The standard output from executing the module command. + + ``RESULT_VARIABLE <ret-var>`` + The return code from executing the module command. + +.. command:: env_module_swap + + Swap one module for another: + + .. code-block:: cmake + + env_module_swap(out_mod in_mod + [OUTPUT_VARIABLE <out-var>] + [RESULT_VARIABLE <ret-var>] + ) + + This is functionally equivalent to the ``module swap out_mod in_mod`` shell + command. The options are: + + ``OUTPUT_VARIABLE <out-var>`` + The standard output from executing the module command. + + ``RESULT_VARIABLE <ret-var>`` + The return code from executing the module command. + +.. command:: env_module_list + + Retrieve the list of currently loaded modules: + + .. code-block:: cmake + + env_module_list(<out-var>) + + This is functionally equivalent to the ``module list`` shell command. + The result is stored in ``<out-var>`` as a properly formatted CMake + :ref:`semicolon-separated list <CMake Language Lists>` variable. + +.. command:: env_module_avail + + Retrieve the list of available modules: + + .. code-block:: cmake + + env_module_avail([<mod-prefix>] <out-var>) + + This is functionally equivalent to the ``module avail <mod-prefix>`` shell + command. The result is stored in ``<out-var>`` as a properly formatted + CMake :ref:`semicolon-separated list <CMake Language Lists>` variable. + +#]=======================================================================] + +function(env_module) + if(NOT EnvModules_COMMAND) + message(FATAL_ERROR "Failed to process module command. EnvModules_COMMAND not found") + return() + endif() + + set(options) + set(oneValueArgs OUTPUT_VARIABLE RESULT_VARIABLE) + set(multiValueArgs COMMAND) + cmake_parse_arguments(MOD_ARGS + "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV} + ) + if(NOT MOD_ARGS_COMMAND) + # If no explicit command argument was given, then treat the calling syntax + # as: module(cmd args...) + set(exec_cmd ${ARGV}) + else() + set(exec_cmd ${MOD_ARGS_COMMAND}) + endif() + + if(MOD_ARGS_OUTPUT_VARIABLE) + set(err_var_args ERROR_VARIABLE err_var) + endif() + + execute_process( + COMMAND mktemp -t module.cmake.XXXXXXXXXXXX + OUTPUT_VARIABLE tempfile_name + ) + string(STRIP "${tempfile_name}" tempfile_name) + + # If the $MODULESHOME/init/cmake file exists then assume that the CMake + # "shell" functionality exits + if(EXISTS "$ENV{MODULESHOME}/init/cmake") + execute_process( + COMMAND ${EnvModules_COMMAND} cmake ${exec_cmd} + OUTPUT_FILE ${tempfile_name} + ${err_var_args} + RESULT_VARIABLE ret_var + ) + + else() # fallback to the sh shell and manually convert to CMake + execute_process( + COMMAND ${EnvModules_COMMAND} sh ${exec_cmd} + OUTPUT_VARIABLE out_var + ${err_var_args} + RESULT_VARIABLE ret_var + ) + endif() + + # If we executed successfully then process and cleanup the temp file + if(ret_var EQUAL 0) + # No CMake shell so we need to process the sh output into CMake code + if(NOT EXISTS "$ENV{MODULESHOME}/init/cmake") + file(WRITE ${tempfile_name} "") + string(REPLACE "\n" ";" out_var "${out_var}") + foreach(sh_cmd IN LISTS out_var) + if(sh_cmd MATCHES "^ *unset *([^ ]*)") + set(cmake_cmd "unset(ENV{${CMAKE_MATCH_1}})") + elseif(sh_cmd MATCHES "^ *export *([^ ]*)") + set(cmake_cmd "set(ENV{${CMAKE_MATCH_1}} \"\${${CMAKE_MATCH_1}}\")") + elseif(sh_cmd MATCHES " *([^ =]*) *= *(.*)") + set(var_name "${CMAKE_MATCH_1}") + set(var_value "${CMAKE_MATCH_2}") + if(var_value MATCHES "^\"(.*[^\\])\"") + # If it's in quotes, take the value as is + set(var_value "${CMAKE_MATCH_1}") + else() + # Otherwise, strip trailing spaces + string(REGEX REPLACE "([^\\])? +$" "\\1" var_value "${var_value}") + endif() + string(REPLACE "\\ " " " var_value "${var_value}") + set(cmake_cmd "set(${var_name} \"${var_value}\")") + else() + continue() + endif() + file(APPEND ${tempfile_name} "${cmake_cmd}\n") + endforeach() + endif() + + # Process the change in environment variables + include(${tempfile_name}) + file(REMOVE ${tempfile_name}) + endif() + + # Push the output back out to the calling scope + if(MOD_ARGS_OUTPUT_VARIABLE) + set(${MOD_ARGS_OUTPUT_VARIABLE} "${err_var}" PARENT_SCOPE) + endif() + if(MOD_ARGS_RESULT_VARIABLE) + set(${MOD_ARGS_RESULT_VARIABLE} ${ret_var} PARENT_SCOPE) + endif() +endfunction(env_module) + +#------------------------------------------------------------------------------ +function(env_module_swap out_mod in_mod) + set(options) + set(oneValueArgs OUTPUT_VARIABLE RESULT_VARIABLE) + set(multiValueArgs) + + cmake_parse_arguments(MOD_ARGS + "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV} + ) + + env_module(COMMAND -t swap ${out_mod} ${in_mod} + OUTPUT_VARIABLE tmp_out + RETURN_VARIABLE tmp_ret + ) + + if(MOD_ARGS_OUTPUT_VARIABLE) + set(${MOD_ARGS_OUTPUT_VARIABLE} "${err_var}" PARENT_SCOPE) + endif() + if(MOD_ARGS_RESULT_VARIABLE) + set(${MOD_ARGS_RESULT_VARIABLE} ${tmp_ret} PARENT_SCOPE) + endif() +endfunction() + +#------------------------------------------------------------------------------ +function(env_module_list out_var) + cmake_policy(SET CMP0007 NEW) + env_module(COMMAND -t list OUTPUT_VARIABLE tmp_out) + + # Convert output into a CMake list + string(REPLACE "\n" ";" ${out_var} "${tmp_out}") + + # Remove title headers and empty entries + list(REMOVE_ITEM ${out_var} "No modules loaded") + if(${out_var}) + list(FILTER ${out_var} EXCLUDE REGEX "^(.*:)?$") + endif() + list(FILTER ${out_var} EXCLUDE REGEX "^(.*:)?$") + + set(${out_var} ${${out_var}} PARENT_SCOPE) +endfunction() + +#------------------------------------------------------------------------------ +function(env_module_avail) + cmake_policy(SET CMP0007 NEW) + + if(ARGC EQUAL 1) + set(mod_prefix) + set(out_var ${ARGV0}) + elseif(ARGC EQUAL 2) + set(mod_prefix ${ARGV0}) + set(out_var ${ARGV1}) + else() + message(FATAL_ERROR "Usage: env_module_avail([mod_prefix] out_var)") + endif() + env_module(COMMAND -t avail ${mod_prefix} OUTPUT_VARIABLE tmp_out) + + # Convert output into a CMake list + string(REPLACE "\n" ";" tmp_out "${tmp_out}") + + set(${out_var}) + foreach(MOD IN LISTS tmp_out) + # Remove directory entries and empty values + if(MOD MATCHES "^(.*:)?$") + continue() + endif() + + # Convert default modules + if(MOD MATCHES "^(.*)/$" ) # "foo/" + list(APPEND ${out_var} ${CMAKE_MATCH_1}) + elseif(MOD MATCHES "^((.*)/.*)\\(default\\)$") # "foo/1.2.3(default)" + list(APPEND ${out_var} ${CMAKE_MATCH_2}) + list(APPEND ${out_var} ${CMAKE_MATCH_1}) + else() + list(APPEND ${out_var} ${MOD}) + endif() + endforeach() + + set(${out_var} ${${out_var}} PARENT_SCOPE) +endfunction() + +#------------------------------------------------------------------------------ +# Make sure we know where the underlying module command is +find_program(EnvModules_COMMAND + NAMES lmod modulecmd + HINTS ENV MODULESHOME + PATH_SUFFIXES libexec +) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(EnvModules DEFAULT_MSG EnvModules_COMMAND) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index edebe75..09d57d2 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -5,7 +5,8 @@ FindFLEX -------- -Find flex executable and provides a macro to generate custom build rules +Find Fast Lexical Analyzer (Flex) executable and provides a macro +to generate custom build rules @@ -13,7 +14,7 @@ The module defines the following variables: :: - FLEX_FOUND - true is flex executable is found + FLEX_FOUND - True is flex executable is found FLEX_EXECUTABLE - the path to the flex executable FLEX_VERSION - the version of flex FLEX_LIBRARIES - The flex libraries @@ -22,7 +23,7 @@ The module defines the following variables: The minimum required version of flex can be specified using the -standard syntax, e.g. find_package(FLEX 2.5.13) +standard syntax, e.g. :command:`find_package(FLEX 2.5.13)` @@ -35,10 +36,10 @@ If flex is found on the system, the module provides the macro: [DEFINES_FILE <string>] ) -which creates a custom command to generate the <FlexOutput> file from -the <FlexInput> file. If COMPILE_FLAGS option is specified, the next +which creates a custom command to generate the ``FlexOutput`` file from +the ``FlexInput`` file. If ``COMPILE_FLAGS`` option is specified, the next parameter is added to the flex command line. If flex is configured to -output a header file, the DEFINES_FILE option may be used to specify its +output a header file, the ``DEFINES_FILE`` option may be used to specify its name. Name is an alias used to get details of this custom command. Indeed the macro defines the following variables: @@ -61,8 +62,8 @@ defines a macro: ADD_FLEX_BISON_DEPENDENCY(FlexTarget BisonTarget) which adds the required dependency between a scanner and a parser -where <FlexTarget> and <BisonTarget> are the first parameters of -respectively FLEX_TARGET and BISON_TARGET macros. +where ``FlexTarget`` and ``BisonTarget`` are the first parameters of +respectively ``FLEX_TARGET`` and ``BISON_TARGET`` macros. :: diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index 89122c0..e273642 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -5,14 +5,14 @@ FindFLTK -------- -Find the FLTK library +Find the Fast Light Toolkit (FLTK) library Input Variables ^^^^^^^^^^^^^^^ By default this module will search for all of the FLTK components and -add them to the FLTK_LIBRARIES variable. You can limit the components -which get placed in FLTK_LIBRARIES by defining one or more of the +add them to the ``FLTK_LIBRARIES`` variable. You can limit the components +which get placed in ``FLTK_LIBRARIES`` by defining one or more of the following three options: ``FLTK_SKIP_OPENGL`` diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake index 161d15c..a43f7a4 100644 --- a/Modules/FindFLTK2.cmake +++ b/Modules/FindFLTK2.cmake @@ -5,7 +5,7 @@ FindFLTK2 --------- -Find the native FLTK2 includes and library +Find the native FLTK 2.0 includes and library The following settings are defined @@ -243,4 +243,3 @@ else() endif() endif() endif() - diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index 8522f9b..fde84d4 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -5,7 +5,7 @@ FindGDAL -------- -Find GDAL. +Find Geospatial Data Abstraction Library (GDAL). IMPORTED Targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 9687b57..d5a143e 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -5,7 +5,7 @@ FindGIF ------- -This finds the GIF library (giflib) +This finds the Graphics Interchange Format (GIF) library (``giflib``) Imported targets ^^^^^^^^^^^^^^^^ @@ -13,7 +13,7 @@ Imported targets This module defines the following :prop_tgt:`IMPORTED` target: ``GIF::GIF`` - The giflib library, if found. + The ``giflib`` library, if found. Result variables ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindGLEW.cmake b/Modules/FindGLEW.cmake index ad8a810..2e9a052 100644 --- a/Modules/FindGLEW.cmake +++ b/Modules/FindGLEW.cmake @@ -7,64 +7,305 @@ FindGLEW Find the OpenGL Extension Wrangler Library (GLEW) -IMPORTED Targets +Input Variables +^^^^^^^^^^^^^^^ + +The following variables may be set to influence this module’s behavior: + +``GLEW_USE_STATIC_LIBS`` + to find and create :prop_tgt:`IMPORTED` target for static linkage. + +``GLEW_VERBOSE`` + to output a detailed log of this module. + +Imported Targets ^^^^^^^^^^^^^^^^ -This module defines the :prop_tgt:`IMPORTED` target ``GLEW::GLEW``, -if GLEW has been found. +This module defines the following :ref:`Imported Targets <Imported Targets>`: + + +``GLEW::glew`` + The GLEW shared library. +``GLEW::glew_s`` + The GLEW static library, if ``GLEW_USE_STATIC_LIBS`` is set to ``TRUE``. +``GLEW::GLEW`` + Duplicates either ``GLEW::glew`` or ``GLEW::glew_s`` based on availability. Result Variables ^^^^^^^^^^^^^^^^ This module defines the following variables: -:: +``GLEW_INCLUDE_DIRS`` + include directories for GLEW +``GLEW_LIBRARIES`` + libraries to link against GLEW +``GLEW_SHARED_LIBRARIES`` + libraries to link against shared GLEW +``GLEW_STATIC_LIBRARIES`` + libraries to link against static GLEW +``GLEW_FOUND`` + true if GLEW has been found and can be used +``GLEW_VERSION`` + GLEW version +``GLEW_VERSION_MAJOR`` + GLEW major version +``GLEW_VERSION_MINOR`` + GLEW minor version +``GLEW_VERSION_MICRO`` + GLEW micro version - GLEW_INCLUDE_DIRS - include directories for GLEW - GLEW_LIBRARIES - libraries to link against GLEW - GLEW_FOUND - true if GLEW has been found and can be used #]=======================================================================] +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +find_package(GLEW CONFIG QUIET) + +if(GLEW_FOUND) + find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_CONFIG) + return() +endif() + +if(GLEW_VERBOSE) + message(STATUS "FindGLEW: did not find GLEW CMake config file. Searching for libraries.") +endif() + + +function(__glew_set_find_library_suffix shared_or_static) + if(UNIX AND "${shared_or_static}" MATCHES "SHARED") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" PARENT_SCOPE) + elseif(UNIX AND "${shared_or_static}" MATCHES "STATIC") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) + elseif(APPLE AND "${shared_or_static}" MATCHES "SHARED") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so" PARENT_SCOPE) + elseif(APPLE AND "${shared_or_static}" MATCHES "STATIC") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE) + elseif(WIN32 AND "${shared_or_static}" MATCHES "SHARED") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" PARENT_SCOPE) + elseif(WIN32 AND "${shared_or_static}" MATCHES "STATIC") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll.a" PARENT_SCOPE) + endif() + + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: CMAKE_FIND_LIBRARY_SUFFIXES for ${shared_or_static}: ${CMAKE_FIND_LIBRARY_SUFFIXES}") + endif() +endfunction() + + +if(GLEW_VERBOSE) + if(DEFINED GLEW_USE_STATIC_LIBS) + message(STATUS "FindGLEW: GLEW_USE_STATIC_LIBS: ${GLEW_USE_STATIC_LIBS}.") + else() + message(STATUS "FindGLEW: GLEW_USE_STATIC_LIBS is undefined. Treated as FALSE.") + endif() +endif() + find_path(GLEW_INCLUDE_DIR GL/glew.h) +mark_as_advanced(GLEW_INCLUDE_DIR) + +set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) -if(NOT GLEW_LIBRARY) - find_library(GLEW_LIBRARY_RELEASE NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64 libx32) - find_library(GLEW_LIBRARY_DEBUG NAMES GLEWd glew32d glewd PATH_SUFFIXES lib64) +if(GLEW_VERBOSE) + message(STATUS "FindGLEW: GLEW_INCLUDE_DIR: ${GLEW_INCLUDE_DIR}") + message(STATUS "FindGLEW: GLEW_INCLUDE_DIRS: ${GLEW_INCLUDE_DIRS}") +endif() - include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) - select_library_configurations(GLEW) -endif () +if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "x64" OR "${CMAKE_GENERATOR}" MATCHES "Win64") + set(_arch "x64") +else() + set(_arch "Win32") +endif() + + +set(__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + +__glew_set_find_library_suffix(SHARED) + +find_library(GLEW_SHARED_LIBRARY_RELEASE + NAMES GLEW glew glew32 + PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch} + PATHS ENV GLEW_ROOT) + +find_library(GLEW_SHARED_LIBRARY_DEBUG + NAMES GLEWd glewd glew32d + PATH_SUFFIXES lib lib64 + PATHS ENV GLEW_ROOT) + + +__glew_set_find_library_suffix(STATIC) + +find_library(GLEW_STATIC_LIBRARY_RELEASE + NAMES GLEW glew glew32s + PATH_SUFFIXES lib lib64 libx32 lib/Release/${_arch} + PATHS ENV GLEW_ROOT) + +find_library(GLEW_STATIC_LIBRARY_DEBUG + NAMES GLEWds glewds glew32ds + PATH_SUFFIXES lib lib64 + PATHS ENV GLEW_ROOT) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES}) +unset(__GLEW_CURRENT_FIND_LIBRARY_SUFFIXES) + +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + +select_library_configurations(GLEW_SHARED) +select_library_configurations(GLEW_STATIC) + +if(NOT GLEW_USE_STATIC_LIBS) + set(GLEW_LIBRARIES ${GLEW_SHARED_LIBRARY}) +else() + set(GLEW_LIBRARIES ${GLEW_STATIC_LIBRARY}) +endif() + + +if(GLEW_VERBOSE) + message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY_RELEASE: ${GLEW_SHARED_LIBRARY_RELEASE}") + message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY_RELEASE: ${GLEW_STATIC_LIBRARY_RELEASE}") + message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY_DEBUG: ${GLEW_SHARED_LIBRARY_DEBUG}") + message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY_DEBUG: ${GLEW_STATIC_LIBRARY_DEBUG}") + message(STATUS "FindGLEW: GLEW_SHARED_LIBRARY: ${GLEW_SHARED_LIBRARY}") + message(STATUS "FindGLEW: GLEW_STATIC_LIBRARY: ${GLEW_STATIC_LIBRARY}") + message(STATUS "FindGLEW: GLEW_LIBRARIES: ${GLEW_LIBRARIES}") +endif() + + +# Read version from GL/glew.h file +if(EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") + file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" _contents REGEX "^VERSION_.+ [0-9]+") + if(_contents) + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MAJOR "${_contents}") + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MINOR "${_contents}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" GLEW_VERSION_MICRO "${_contents}") + set(GLEW_VERSION "${GLEW_VERSION_MAJOR}.${GLEW_VERSION_MINOR}.${GLEW_VERSION_MICRO}") + endif() +endif() + +if(GLEW_VERBOSE) + message(STATUS "FindGLEW: GLEW_VERSION_MAJOR: ${GLEW_VERSION_MAJOR}") + message(STATUS "FindGLEW: GLEW_VERSION_MINOR: ${GLEW_VERSION_MINOR}") + message(STATUS "FindGLEW: GLEW_VERSION_MICRO: ${GLEW_VERSION_MICRO}") + message(STATUS "FindGLEW: GLEW_VERSION: ${GLEW_VERSION}") +endif() -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) find_package_handle_standard_args(GLEW - REQUIRED_VARS GLEW_INCLUDE_DIR GLEW_LIBRARY) + REQUIRED_VARS GLEW_INCLUDE_DIRS GLEW_LIBRARIES + VERSION_VAR GLEW_VERSION) -if(GLEW_FOUND) - set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR}) +if(NOT GLEW_FOUND) + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: could not found GLEW library.") + endif() + return() +endif() + + +if(NOT TARGET GLEW::glew AND NOT GLEW_USE_STATIC_LIBS) + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: Creating GLEW::glew imported target.") + endif() + + add_library(GLEW::glew UNKNOWN IMPORTED) + + set_target_properties(GLEW::glew + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + + if(GLEW_SHARED_LIBRARY_RELEASE) + set_property(TARGET GLEW::glew + APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + + set_target_properties(GLEW::glew + PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_SHARED_LIBRARY_RELEASE}") + endif() + + if(GLEW_SHARED_LIBRARY_DEBUG) + set_property(TARGET GLEW::glew + APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + + set_target_properties(GLEW::glew + PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_SHARED_LIBRARY_DEBUG}") + endif() - if(NOT GLEW_LIBRARIES) - set(GLEW_LIBRARIES ${GLEW_LIBRARY}) +elseif(NOT TARGET GLEW::glew_s AND GLEW_USE_STATIC_LIBS) + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: Creating GLEW::glew_s imported target.") endif() - if (NOT TARGET GLEW::GLEW) - add_library(GLEW::GLEW UNKNOWN IMPORTED) - set_target_properties(GLEW::GLEW PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + add_library(GLEW::glew_s UNKNOWN IMPORTED) - if(GLEW_LIBRARY_RELEASE) - set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_LIBRARY_RELEASE}") + set_target_properties(GLEW::glew_s + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + + if(GLEW_STATIC_LIBRARY_RELEASE) + set_property(TARGET GLEW::glew_s + APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + + set_target_properties(GLEW::glew_s + PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_STATIC_LIBRARY_RELEASE}") + endif() + + if(GLEW_STATIC_LIBRARY_DEBUG) + set_property(TARGET GLEW::glew_s + APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + + set_target_properties(GLEW::glew_s + PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_STATIC_LIBRARY_DEBUG}") + endif() +endif() + +if(NOT TARGET GLEW::GLEW) + if(GLEW_VERBOSE) + message(STATUS "FindGLEW: Creating GLEW::GLEW imported target.") + endif() + + add_library(GLEW::GLEW UNKNOWN IMPORTED) + + set_target_properties(GLEW::GLEW + PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLEW_INCLUDE_DIRS}") + + if(TARGET GLEW::glew) + if(GLEW_SHARED_LIBRARY_RELEASE) + set_property(TARGET GLEW::GLEW + APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + + set_target_properties(GLEW::GLEW + PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_SHARED_LIBRARY_RELEASE}") + endif() + + if(GLEW_SHARED_LIBRARY_DEBUG) + set_property(TARGET GLEW::GLEW + APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + + set_target_properties(GLEW::GLEW + PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_SHARED_LIBRARY_DEBUG}") endif() - if(GLEW_LIBRARY_DEBUG) - set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(GLEW::GLEW PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_LIBRARY_DEBUG}") + elseif(TARGET GLEW::glew_s) + if(GLEW_STATIC_LIBRARY_RELEASE) + set_property(TARGET GLEW::GLEW + APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + + set_target_properties(GLEW::GLEW + PROPERTIES IMPORTED_LOCATION_RELEASE "${GLEW_STATIC_LIBRARY_RELEASE}") endif() - if(NOT GLEW_LIBRARY_RELEASE AND NOT GLEW_LIBRARY_DEBUG) - set_property(TARGET GLEW::GLEW APPEND PROPERTY IMPORTED_LOCATION "${GLEW_LIBRARY}") + if(GLEW_STATIC_LIBRARY_DEBUG AND GLEW_USE_STATIC_LIBS) + set_property(TARGET GLEW::GLEW + APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + + set_target_properties(GLEW::GLEW + PROPERTIES IMPORTED_LOCATION_DEBUG "${GLEW_STATIC_LIBRARY_DEBUG}") endif() + + elseif(GLEW_VERBOSE) + message(WARNING "FindGLEW: no `GLEW::glew` or `GLEW::glew_s` target was created. Something went wrong in FindGLEW target creation.") endif() endif() - -mark_as_advanced(GLEW_INCLUDE_DIR) diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake index dbec6d1..9892805 100644 --- a/Modules/FindGLU.cmake +++ b/Modules/FindGLU.cmake @@ -15,4 +15,3 @@ if (OPENGL_GLU_FOUND) set (GLU_LIBRARY ${OPENGL_LIBRARIES}) set (GLU_INCLUDE_PATH ${OPENGL_INCLUDE_DIR}) endif () - diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index d42db53..a22bf5b 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -5,7 +5,7 @@ FindGLUT -------- -try to find glut library and include files. +Find OpenGL Utility Toolkit (GLUT) library and include files. IMPORTED Targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake index db05121..da1b3c4 100644 --- a/Modules/FindGSL.cmake +++ b/Modules/FindGSL.cmake @@ -5,7 +5,7 @@ FindGSL -------- -Find the native GSL includes and libraries. +Find the native GNU Scientific Library (GSL) includes and libraries. The GNU Scientific Library (GSL) is a numerical library for C and C++ programmers. It is free software under the GNU General Public diff --git a/Modules/FindGTK.cmake b/Modules/FindGTK.cmake index 8cc6c97..552b19a 100644 --- a/Modules/FindGTK.cmake +++ b/Modules/FindGTK.cmake @@ -5,7 +5,7 @@ FindGTK ------- -try to find GTK (and glib) and GTKGLArea +Find GTK, glib and GTKGLArea :: @@ -151,6 +151,3 @@ if(UNIX) ) endif() - - - diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index 6c1897c..02e96c6 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -5,10 +5,8 @@ FindGTK2 -------- -FindGTK2.cmake - -This module can find the GTK2 widget libraries and several of its -other optional components like gtkmm, glade, and glademm. +Find the GTK2 widget libraries and several of its +other optional components like ``gtkmm``, ``glade``, and ``glademm``. NOTE: If you intend to use version checking, CMake 2.6.2 or later is @@ -303,9 +301,7 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) /opt/gnome/lib /opt/openwin/include /usr/openwin/lib - /sw/include /sw/lib - /opt/local/include /opt/local/lib /usr/pkg/lib /usr/pkg/include/glib @@ -415,7 +411,6 @@ function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version) PATHS /opt/gnome/lib /usr/openwin/lib - /sw/lib $ENV{GTKMM_BASEPATH}/lib [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index 9c07444..4b4019c 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -5,7 +5,7 @@ FindGnuTLS ---------- -Try to find the GNU Transport Layer Security library (gnutls) +Find the GNU Transport Layer Security library (gnutls) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 70bfc96..08863c8 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -5,43 +5,44 @@ FindHDF5 -------- -Find HDF5, a library for reading and writing self describing array data. +Find Hierarchical Data Format (HDF5), a library for reading and writing +self describing array data. -This module invokes the HDF5 wrapper compiler that should be installed -alongside HDF5. Depending upon the HDF5 Configuration, the wrapper -compiler is called either h5cc or h5pcc. If this succeeds, the module -will then call the compiler with the -show argument to see what flags -are used when compiling an HDF5 client application. +This module invokes the ``HDF5`` wrapper compiler that should be installed +alongside ``HDF5``. Depending upon the ``HDF5`` Configuration, the wrapper +compiler is called either ``h5cc`` or ``h5pcc``. If this succeeds, the module +will then call the compiler with the show argument to see what flags +are used when compiling an ``HDF5`` client application. -The module will optionally accept the COMPONENTS argument. If no -COMPONENTS are specified, then the find module will default to finding -only the HDF5 C library. If one or more COMPONENTS are specified, the +The module will optionally accept the ``COMPONENTS`` argument. If no +``COMPONENTS`` are specified, then the find module will default to finding +only the ``HDF5`` C library. If one or more ``COMPONENTS`` are specified, the module will attempt to find the language bindings for the specified -components. The only valid components are C, CXX, Fortran, HL, and -Fortran_HL. If the COMPONENTS argument is not given, the module will +components. The only valid components are ``C``, ``CXX``, ``Fortran``, ``HL``, +and ``Fortran_HL``. If the ``COMPONENTS`` argument is not given, the module will attempt to find only the C bindings. This module will read the variable -HDF5_USE_STATIC_LIBRARIES to determine whether or not to prefer a -static link to a dynamic link for HDF5 and all of it's dependencies. -To use this feature, make sure that the HDF5_USE_STATIC_LIBRARIES +``HDF5_USE_STATIC_LIBRARIES`` to determine whether or not to prefer a +static link to a dynamic link for ``HDF5`` and all of it's dependencies. +To use this feature, make sure that the ``HDF5_USE_STATIC_LIBRARIES`` variable is set before the call to find_package. -To provide the module with a hint about where to find your HDF5 -installation, you can set the environment variable HDF5_ROOT. The -Find module will then look in this path when searching for HDF5 +To provide the module with a hint about where to find your ``HDF5`` +installation, you can set the environment variable ``HDF5_ROOT``. The +Find module will then look in this path when searching for ``HDF5`` executables, paths, and libraries. -Both the serial and parallel HDF5 wrappers are considered and the first +Both the serial and parallel ``HDF5`` wrappers are considered and the first directory to contain either one will be used. In the event that both appear in the same directory the serial version is preferentially selected. This -behavior can be reversed by setting the variable HDF5_PREFER_PARALLEL to -true. +behavior can be reversed by setting the variable ``HDF5_PREFER_PARALLEL`` to +``True``. In addition to finding the includes and libraries required to compile -an HDF5 client application, this module also makes an effort to find -tools that come with the HDF5 distribution that may be useful for +an ``HDF5`` client application, this module also makes an effort to find +tools that come with the ``HDF5`` distribution that may be useful for regression testing. Result Variables diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake index ec077a5..9724d2c 100644 --- a/Modules/FindHSPELL.cmake +++ b/Modules/FindHSPELL.cmake @@ -5,7 +5,7 @@ FindHSPELL ---------- -Try to find Hspell +Try to find Hebrew spell-checker (Hspell) and morphology engine. Once done this will define diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake index 32fc4ae..d19c145 100644 --- a/Modules/FindIcotool.cmake +++ b/Modules/FindIcotool.cmake @@ -7,8 +7,8 @@ FindIcotool Find icotool -This module looks for icotool. This module defines the following -values: +This module looks for icotool. Convert and create Win32 icon and cursor files. +This module defines the following values: :: diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 2ddd11c..8bf5123 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -5,11 +5,11 @@ FindImageMagick --------------- -Find the ImageMagick binary suite. +Find ImageMagick binary suite. This module will search for a set of ImageMagick tools specified as -components in the FIND_PACKAGE call. Typical components include, but -are not limited to (future versions of ImageMagick might have +components in the :command:`find_package` call. Typical components include, +but are not limited to (future versions of ImageMagick might have additional components not listed here): :: @@ -28,7 +28,7 @@ additional components not listed here): -If no component is specified in the FIND_PACKAGE call, then it only +If no component is specified in the :command:`find_package` call, then it only searches for the ImageMagick executable directory. This code defines the following variables: @@ -43,7 +43,7 @@ the following variables: -ImageMagick_VERSION_STRING will not work for old versions like 5.2.3. +``ImageMagick_VERSION_STRING`` will not work for old versions like 5.2.3. There are also components for the following ImageMagick APIs: @@ -80,8 +80,8 @@ Example Usages: -Note that the standard FIND_PACKAGE features are supported (i.e., -QUIET, REQUIRED, etc.). +Note that the standard :command:`find_package` features are supported (i.e., +``QUIET``, ``REQUIRED``, etc.). #]=======================================================================] find_package(PkgConfig QUIET) diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index f50f79e..0bb6989 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -5,7 +5,7 @@ FindJPEG -------- -Find the JPEG library (libjpeg) +Find the Joint Photographic Experts Group (JPEG) library (``libjpeg``) Imported targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index c7ad6e1..f916359 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -35,7 +35,7 @@ The following user adjustable options are provided: ``KDE3_BUILD_TESTS`` enable this to build KDE testcases -It also adds the following macros (from KDE3Macros.cmake) SRCS_VAR is +It also adds the following macros (from ``KDE3Macros.cmake``) ``SRCS_VAR`` is always the variable which contains the list of source files for your application or library. @@ -358,4 +358,3 @@ endif () #add the found Qt and KDE include directories to the current include path set(KDE3_INCLUDE_DIRS ${QT_INCLUDE_DIR} ${KDE3_INCLUDE_DIR}) - diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake index c04804b..2a1838f 100644 --- a/Modules/FindKDE4.cmake +++ b/Modules/FindKDE4.cmake @@ -19,7 +19,7 @@ the given order: -Please look in FindKDE4Internal.cmake and KDE4Macros.cmake for more +Please look in ``FindKDE4Internal.cmake`` and ``KDE4Macros.cmake`` for more information. They are installed with the KDE 4 libraries in $KDEDIRS/share/apps/cmake/modules/. diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index d6646ea..6582eea 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -5,13 +5,13 @@ FindLAPACK ---------- -Find LAPACK library +Find Linear Algebra PACKage (LAPACK) library This module finds an installed fortran library that implements the LAPACK linear-algebra interface (see http://www.netlib.org/lapack/). The approach follows that taken for the autoconf macro file, -acx_lapack.m4 (distributed at +``acx_lapack.m4`` (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html). Input Variables diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake index 01f4793..b365d63 100644 --- a/Modules/FindLATEX.cmake +++ b/Modules/FindLATEX.cmake @@ -5,9 +5,9 @@ FindLATEX --------- -Find Latex +Find LaTeX -This module finds an installed Latex and determines the location +This module finds an installed LaTeX and determines the location of the compiler. Additionally the module looks for Latex-related software like BibTeX. diff --git a/Modules/FindLTTngUST.cmake b/Modules/FindLTTngUST.cmake index a074187..9cd17eb 100644 --- a/Modules/FindLTTngUST.cmake +++ b/Modules/FindLTTngUST.cmake @@ -5,7 +5,8 @@ FindLTTngUST ------------ -This module finds the `LTTng-UST <http://lttng.org/>`__ library. +Find +`Linux Trace Toolkit Next Generation (LTTng-UST) <http://lttng.org/>`__ library. Imported target ^^^^^^^^^^^^^^^ diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake index 34fc2e2..ef27b7d 100644 --- a/Modules/FindLibArchive.cmake +++ b/Modules/FindLibArchive.cmake @@ -5,7 +5,8 @@ FindLibArchive -------------- -Find libarchive library and headers +Find libarchive library and headers. +Libarchive is multi-format archive and compression library. The module defines the following variables: diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 4cca64f..01a9d8b 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -5,7 +5,8 @@ FindLibXslt ----------- -Try to find the LibXslt library +Find the XSL Transformations, Extensible Stylesheet Language +Transformations (XSLT) library (LibXslt) Once done this will define diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index eb3b5fb..d229e18 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -7,7 +7,9 @@ FindLua -Locate Lua library This module defines +Locate Lua library. + +This module defines:: :: diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake index aafc056..0575caa 100644 --- a/Modules/FindLua50.cmake +++ b/Modules/FindLua50.cmake @@ -7,7 +7,8 @@ FindLua50 -Locate Lua library This module defines +Locate Lua library. +This module defines:: :: @@ -40,9 +41,6 @@ find_path(LUA_INCLUDE_DIR lua.h PATHS ~/Library/Frameworks /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave /opt ) @@ -54,9 +52,6 @@ find_library(LUA_LIBRARY_lua PATHS ~/Library/Frameworks /Library/Frameworks - /sw - /opt/local - /opt/csw /opt ) @@ -72,9 +67,6 @@ else() ENV LUA_DIR PATH_SUFFIXES lib PATHS - /sw - /opt/local - /opt/csw /opt ) if(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua) @@ -96,4 +88,3 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES) - diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index 31eaf87..283a3eb 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -7,7 +7,8 @@ FindLua51 -Locate Lua library This module defines +Locate Lua library. +This module defines:: :: @@ -41,9 +42,6 @@ find_path(LUA_INCLUDE_DIR lua.h PATHS ~/Library/Frameworks /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave /opt ) @@ -55,9 +53,6 @@ find_library(LUA_LIBRARY PATHS ~/Library/Frameworks /Library/Frameworks - /sw - /opt/local - /opt/csw /opt ) @@ -87,4 +82,3 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 VERSION_VAR LUA_VERSION_STRING) mark_as_advanced(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) - diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index 9738ac5..e366619 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -5,7 +5,7 @@ FindMFC ------- -Find MFC on Windows +Find Microsoft Foundation Class Library (MFC) on Windows Find the native MFC - i.e. decide if an application can link to the MFC libraries. diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 8c45a8c..5288640 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -770,18 +770,20 @@ function (_MPI_interrogate_compiler LANG) endforeach() # Add the link directories given explicitly that we haven't used back as linker directories. - foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER) - file(TO_NATIVE_PATH "${_MPI_LINK_DIRECTORY}" _MPI_LINK_DIRECTORY_ACTUAL) - string(FIND "${_MPI_LINK_DIRECTORY_ACTUAL}" " " _MPI_LINK_DIRECTORY_CONTAINS_SPACE) - if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL -1) - set(_MPI_LINK_DIRECTORY_ACTUAL "\"${_MPI_LINK_DIRECTORY_ACTUAL}\"") - endif() - if(MPI_LINK_FLAGS_WORK) - string(APPEND MPI_LINK_FLAGS_WORK " ${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}") - else() - set(MPI_LINK_FLAGS_WORK "${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}") - endif() - endforeach() + if(NOT WIN32) + foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER) + file(TO_NATIVE_PATH "${_MPI_LINK_DIRECTORY}" _MPI_LINK_DIRECTORY_ACTUAL) + string(FIND "${_MPI_LINK_DIRECTORY_ACTUAL}" " " _MPI_LINK_DIRECTORY_CONTAINS_SPACE) + if(NOT _MPI_LINK_DIRECTORY_CONTAINS_SPACE EQUAL -1) + set(_MPI_LINK_DIRECTORY_ACTUAL "\"${_MPI_LINK_DIRECTORY_ACTUAL}\"") + endif() + if(MPI_LINK_FLAGS_WORK) + string(APPEND MPI_LINK_FLAGS_WORK " ${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}") + else() + set(MPI_LINK_FLAGS_WORK "${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY_ACTUAL}") + endif() + endforeach() + endif() # Deal with the libraries given with full path next unset(MPI_DIRECT_LIB_NAMES_WORK) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index dbd7961..27dcaf5 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -6,15 +6,15 @@ FindOpenAL ---------- +Finds Open Audio Library (OpenAL). +This module defines ``OPENAL_LIBRARY OPENAL_FOUND``, if +false, do not try to link to OpenAL ``OPENAL_INCLUDE_DIR``, where to find +the headers. -Locate OpenAL This module defines OPENAL_LIBRARY OPENAL_FOUND, if -false, do not try to link to OpenAL OPENAL_INCLUDE_DIR, where to find -the headers +``$OPENALDIR`` is an environment variable that would correspond to the +``./configure --prefix=$OPENALDIR`` used in building OpenAL. -$OPENALDIR is an environment variable that would correspond to the -./configure --prefix=$OPENALDIR used in building OpenAL. - -Created by Eric Wing. This was influenced by the FindSDL.cmake +Created by Eric Wing. This was influenced by the ``FindSDL.cmake`` module. #]=======================================================================] @@ -63,9 +63,6 @@ find_path(OPENAL_INCLUDE_DIR al.h PATHS ~/Library/Frameworks /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] ) @@ -84,9 +81,6 @@ find_library(OPENAL_LIBRARY PATHS ~/Library/Frameworks /Library/Frameworks - /sw - /opt/local - /opt/csw /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] ) diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 79c0382..9891724 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -5,7 +5,7 @@ FindOpenCL ---------- -Try to find OpenCL +Finds Open Computing Language (OpenCL) IMPORTED Targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 00db033..23bb001d 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -5,7 +5,7 @@ FindOpenGL ---------- -FindModule for OpenGL and GLU. +FindModule for OpenGL and OpenGL Utility Library (GLU). Optional COMPONENTS ^^^^^^^^^^^^^^^^^^^ @@ -23,9 +23,9 @@ This module defines the :prop_tgt:`IMPORTED` targets: ``OpenGL::OpenGL`` Defined to libOpenGL if the system is GLVND-based. ``OpenGL::GLU`` - Defined if the system has GLU. + Defined if the system has OpenGL Utility Library (GLU). ``OpenGL::GLX`` - Defined if the system has GLX. + Defined if the system has OpenGL Extension to the X Window System (GLX). ``OpenGL::EGL`` Defined if the system has EGL. diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 7e37212..b909db8 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -5,7 +5,7 @@ FindOpenMP ---------- -Finds OpenMP support +Finds Open Multi-Processing (OpenMP) support. This module can be used to detect OpenMP support in a compiler. If the compiler supports OpenMP, the flags required to compile with @@ -96,7 +96,6 @@ function(_OPENMP_FLAG_CANDIDATES LANG) else() set(OMP_FLAG_Intel "-qopenmp") endif() - set(OMP_FLAG_MIPSpro "-mp") set(OMP_FLAG_MSVC "-openmp") set(OMP_FLAG_PathScale "-openmp") set(OMP_FLAG_NAG "-openmp") diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 6f7d3c8..27909bc 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -5,11 +5,11 @@ FindOpenSceneGraph ------------------ -Find OpenSceneGraph +Find OpenSceneGraph (3D graphics application programming interface) This module searches for the OpenSceneGraph core "osg" library as well -as OpenThreads, and whatever additional COMPONENTS (nodekits) that you -specify. +as :module:`FindOpenThreads`, and whatever additional ``COMPONENTS`` +(nodekits) that you specify. :: @@ -17,10 +17,11 @@ specify. -NOTE: To use this module effectively you must either require CMake >= -2.6.3 with cmake_minimum_required(VERSION 2.6.3) or download and place -FindOpenThreads.cmake, Findosg_functions.cmake, Findosg.cmake, and -Find<etc>.cmake files into your CMAKE_MODULE_PATH. +NOTE: To use this module effectively you must either require ``CMake >= +2.6.3`` with :command:`cmake_minimum_required(VERSION 2.6.3)` or download +and place :module:`FindOpenThreads`, :module:`Findosg` functions, +:module:`Findosg` and ``Find<etc>.cmake`` files into your +:variable:`CMAKE_MODULE_PATH`. ================================== @@ -40,11 +41,12 @@ This module accepts the following variables (note mixed case) The following environment variables are also respected for finding the -OSG and it's various components. CMAKE_PREFIX_PATH can also be used -for this (see find_library() CMake documentation). +OSG and it's various components. :variable:`CMAKE_PREFIX_PATH` can also be +used for this (see :command:`find_library` CMake documentation). ``<MODULE>_DIR`` - (where MODULE is of the form "OSGVOLUME" and there is a FindosgVolume.cmake file) + (where ``MODULE`` is of the form "OSGVOLUME" and there is + a :module:`FindosgVolume`.cmake` file) ``OSG_DIR`` .. ``OSGDIR`` @@ -53,7 +55,7 @@ for this (see find_library() CMake documentation). .. -[CMake 2.8.10]: The CMake variable OSG_DIR can now be used as well to +[CMake 2.8.10]: The CMake variable ``OSG_DIR`` can now be used as well to influence detection, instead of needing to specify an environment variable. diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index 0366f77..a32f83a 100644 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -24,9 +24,6 @@ find_path(PHYSFS_INCLUDE_DIR physfs.h PATHS ~/Library/Frameworks /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave /opt ) @@ -38,9 +35,6 @@ find_library(PHYSFS_LIBRARY PATHS ~/Library/Frameworks /Library/Frameworks - /sw - /opt/local - /opt/csw /opt ) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index e192426..e05d5c8 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -84,26 +84,8 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) endif() endmacro() -#[========================================[.rst: -.. command:: pkg_get_variable - - Retrieves the value of a pkg-config variable ``varName`` and stores it in the - result variable ``resultVar`` in the calling scope. - - .. code-block:: cmake - - pkg_get_variable(<resultVar> <moduleName> <varName>) - - If ``pkg-config`` returns multiple values for the specified variable, - ``resultVar`` will contain a :ref:`;-list <CMake Language Lists>`. - - For example: - - .. code-block:: cmake - - pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir) -#]========================================] -function (pkg_get_variable result pkg variable) +# Internal version of pkg_get_variable; expects PKG_CONFIG_PATH to already be set +function (_pkg_get_variable result pkg variable) _pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}") set("${result}" "${prefix_result}" @@ -242,7 +224,7 @@ endfunction() function(_pkg_create_imp_target _prefix _imp_target_global) # only create the target if it is linkable, i.e. no executables if (NOT TARGET PkgConfig::${_prefix} - AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_CFLAGS_OTHER )) + AND ( ${_prefix}_INCLUDE_DIRS OR ${_prefix}_LINK_LIBRARIES OR ${_prefix}_LDFLAGS_OTHER OR ${_prefix}_CFLAGS_OTHER )) if(${_imp_target_global}) set(_global_opt "GLOBAL") else() @@ -258,6 +240,10 @@ function(_pkg_create_imp_target _prefix _imp_target_global) set_property(TARGET PkgConfig::${_prefix} PROPERTY INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}") endif() + if(${_prefix}_LDFLAGS_OTHER) + set_property(TARGET PkgConfig::${_prefix} PROPERTY + INTERFACE_LINK_OPTIONS "${${_prefix}_LDFLAGS_OTHER}") + endif() if(${_prefix}_CFLAGS_OTHER) set_property(TARGET PkgConfig::${_prefix} PROPERTY INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}") @@ -275,6 +261,102 @@ macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_ta endmacro() ### +macro(_pkg_set_path_internal) + set(_extra_paths) + + if(NOT _no_cmake_path) + _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH) + endif() + + if(NOT _no_cmake_environment_path) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH) + _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH) + endif() + + if(NOT _extra_paths STREQUAL "") + # Save the PKG_CONFIG_PATH environment variable, and add paths + # from the CMAKE_PREFIX_PATH variables + set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}") + set(_pkgconfig_path "${_pkgconfig_path_old}") + if(NOT _pkgconfig_path STREQUAL "") + file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path) + endif() + + # Create a list of the possible pkgconfig subfolder (depending on + # the system + set(_lib_dirs) + if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") + endif() + else() + # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties + get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS) + if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) + list(APPEND _lib_dirs "lib32/pkgconfig") + endif() + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND _lib_dirs "lib64/pkgconfig") + endif() + get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS) + if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32") + list(APPEND _lib_dirs "libx32/pkgconfig") + endif() + endif() + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_CROSSCOMPILING) + list(APPEND _lib_dirs "libdata/pkgconfig") + endif() + list(APPEND _lib_dirs "lib/pkgconfig") + list(APPEND _lib_dirs "share/pkgconfig") + + # Check if directories exist and eventually append them to the + # pkgconfig path list + foreach(_prefix_dir ${_extra_paths}) + foreach(_lib_dir ${_lib_dirs}) + if(EXISTS "${_prefix_dir}/${_lib_dir}") + list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}") + list(REMOVE_DUPLICATES _pkgconfig_path) + endif() + endforeach() + endforeach() + + # Prepare and set the environment variable + if(NOT _pkgconfig_path STREQUAL "") + # remove empty values from the list + list(REMOVE_ITEM _pkgconfig_path "") + file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) + if(UNIX) + string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") + string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") + endif() + set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}") + endif() + + # Unset variables + unset(_lib_dirs) + unset(_pkgconfig_path) + endif() +endmacro() + +macro(_pkg_restore_path_internal) + if(NOT _extra_paths STREQUAL "") + # Restore the environment variable + set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}") + endif() + + unset(_extra_paths) + unset(_pkgconfig_path_old) +endmacro() + +### macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) @@ -314,88 +396,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma set(_pkg_check_modules_packages) set(_pkg_check_modules_failed) - set(_extra_paths) - - if(NOT _no_cmake_path) - _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH) - _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH) - _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH) - endif() - - if(NOT _no_cmake_environment_path) - _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH) - _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH) - _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH) - endif() - - if(NOT "${_extra_paths}" STREQUAL "") - # Save the PKG_CONFIG_PATH environment variable, and add paths - # from the CMAKE_PREFIX_PATH variables - set(_pkgconfig_path_old "$ENV{PKG_CONFIG_PATH}") - set(_pkgconfig_path "${_pkgconfig_path_old}") - if(NOT "${_pkgconfig_path}" STREQUAL "") - file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path) - endif() - - # Create a list of the possible pkgconfig subfolder (depending on - # the system - set(_lib_dirs) - if(NOT DEFINED CMAKE_SYSTEM_NAME - OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" - AND NOT CMAKE_CROSSCOMPILING)) - if(EXISTS "/etc/debian_version") # is this a debian system ? - if(CMAKE_LIBRARY_ARCHITECTURE) - list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") - endif() - else() - # not debian, check the FIND_LIBRARY_USE_LIB32_PATHS and FIND_LIBRARY_USE_LIB64_PATHS properties - get_property(uselib32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS) - if(uselib32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) - list(APPEND _lib_dirs "lib32/pkgconfig") - endif() - get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) - if(uselib64 AND CMAKE_SIZEOF_VOID_P EQUAL 8) - list(APPEND _lib_dirs "lib64/pkgconfig") - endif() - get_property(uselibx32 GLOBAL PROPERTY FIND_LIBRARY_USE_LIBX32_PATHS) - if(uselibx32 AND CMAKE_INTERNAL_PLATFORM_ABI STREQUAL "ELF X32") - list(APPEND _lib_dirs "libx32/pkgconfig") - endif() - endif() - endif() - if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT CMAKE_CROSSCOMPILING) - list(APPEND _lib_dirs "libdata/pkgconfig") - endif() - list(APPEND _lib_dirs "lib/pkgconfig") - list(APPEND _lib_dirs "share/pkgconfig") - - # Check if directories exist and eventually append them to the - # pkgconfig path list - foreach(_prefix_dir ${_extra_paths}) - foreach(_lib_dir ${_lib_dirs}) - if(EXISTS "${_prefix_dir}/${_lib_dir}") - list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}") - list(REMOVE_DUPLICATES _pkgconfig_path) - endif() - endforeach() - endforeach() - - # Prepare and set the environment variable - if(NOT "${_pkgconfig_path}" STREQUAL "") - # remove empty values from the list - list(REMOVE_ITEM _pkgconfig_path "") - file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) - if(UNIX) - string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") - string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") - endif() - set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}") - endif() - - # Unset variables - unset(_lib_dirs) - unset(_pkgconfig_path) - endif() + _pkg_set_path_internal() # iterate through module list and check whether they exist and match the required version foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) @@ -498,13 +499,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) endif() - if(NOT "${_extra_paths}" STREQUAL "") - # Restore the environment variable - set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path_old}") - endif() - - unset(_extra_paths) - unset(_pkgconfig_path_old) + _pkg_restore_path_internal() else() if (${_is_required}) message(SEND_ERROR "pkg-config tool not found") @@ -708,6 +703,34 @@ macro(pkg_search_module _prefix _module0) endif() endmacro() +#[========================================[.rst: +.. command:: pkg_get_variable + + Retrieves the value of a pkg-config variable ``varName`` and stores it in the + result variable ``resultVar`` in the calling scope. + + .. code-block:: cmake + + pkg_get_variable(<resultVar> <moduleName> <varName>) + + If ``pkg-config`` returns multiple values for the specified variable, + ``resultVar`` will contain a :ref:`;-list <CMake Language Lists>`. + + For example: + + .. code-block:: cmake + + pkg_get_variable(GI_GIRDIR gobject-introspection-1.0 girdir) +#]========================================] +function (pkg_get_variable result pkg variable) + _pkg_set_path_internal() + _pkgconfig_invoke("${pkg}" "prefix" "result" "" "--variable=${variable}") + set("${result}" + "${prefix_result}" + PARENT_SCOPE) + _pkg_restore_path_internal() +endfunction () + #[========================================[.rst: Variables Affecting Behavior diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake index fba0494..65495b5 100644 --- a/Modules/FindProducer.cmake +++ b/Modules/FindProducer.cmake @@ -45,12 +45,9 @@ find_path(PRODUCER_INCLUDE_DIR Producer/CameraGroup PATHS ~/Library/Frameworks /Library/Frameworks - /sw/include # Fink - /opt/local/include # DarwinPorts - /opt/csw/include # Blastwave - /opt/include - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT]/include - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include + /opt + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] + [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] ) find_library(PRODUCER_LIBRARY @@ -61,9 +58,6 @@ find_library(PRODUCER_LIBRARY ENV OSGDIR PATH_SUFFIXES lib PATHS - /sw - /opt/local - /opt/csw /opt ) diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 1c134e2..c5074e8 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -145,18 +145,30 @@ Hints * ``NEVER``: Never try to use registry. ``CMAKE_FIND_FRAMEWORK`` - On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of + On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of preference between Apple-style and unix-style package components. .. note:: Value ``ONLY`` is not supported so ``FIRST`` will be used instead. -.. note:: +``Python_FIND_VIRTUALENV`` + This variable defines the handling of virtual environments. It is meaningfull + only when a virtual environment is active (i.e. the ``activate`` script has + been evaluated). In this case, it takes precedence over + ``Python_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. + The ``Python_FIND_VIRTUALENV`` variable can be set to empty or one of the + following: - If a Python virtual environment is configured, set variable - ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with - value ``LAST`` or ``NEVER`` to select it preferably. + * ``FIRST``: The virtual environment is used before any other standard + paths to look-up for the interpreter. This is the default. + * ``ONLY``: Only the virtual environment is used to look-up for the + interpreter. + * ``STANDARD``: The virtual environment is not used to look-up for the + interpreter. In this case, variable ``Python_FIND_REGISTRY`` (Windows) + or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + ``NEVER`` to select preferably the interpreter from the virtual + environment. Commands ^^^^^^^^ diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 8f67082..8bd5eb3 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -298,6 +298,22 @@ else() set (_${_PYTHON_PREFIX}_FIND_REGISTRY "FIRST") endif() +# virtual environments handling +if (DEFINED ENV{VIRTUAL_ENV}) + if (DEFINED ${_PYTHON_PREFIX}_FIND_VIRTUALENV) + if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$") + message (AUTHOR_WARNING "Find${_PYTHON_PREFIX}: ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}: invalid value for '${_PYTHON_PREFIX}_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'IGNORE' expected.") + set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV "FIRST") + else() + set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV ${${_PYTHON_PREFIX}_FIND_VIRTUALENV}) + endif() + else() + set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV FIRST) + endif() +else() + set (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STANDARD) +endif() + unset (_${_PYTHON_PREFIX}_REQUIRED_VARS) unset (_${_PYTHON_PREFIX}_CACHED_VARS) @@ -318,6 +334,30 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + # Virtual environments handling + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + find_program (${_PYTHON_PREFIX}_EXECUTABLE + NAMES python${_${_PYTHON_PREFIX}_VERSION} + python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} + python + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ENV VIRTUAL_ENV + PATH_SUFFIXES bin Scripts + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + + _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION}) + if (${_PYTHON_PREFIX}_EXECUTABLE) + break() + endif() + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") + continue() + endif() + endif() + # Apple frameworks handling if (APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") find_program (${_PYTHON_PREFIX}_EXECUTABLE @@ -423,7 +463,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() endforeach() - if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) + if (NOT ${_PYTHON_PREFIX}_EXECUTABLE AND + NOT _${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "ONLY") # No specific version found. Retry with generic names # try using HINTS find_program (${_PYTHON_PREFIX}_EXECUTABLE @@ -685,18 +726,32 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # if python interpreter is found, use its location and version to ensure consistency # between interpreter and development environment unset (_${_PYTHON_PREFIX}_PREFIX) + unset (_${_PYTHON_PREFIX}_EXEC_PREFIX) + unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX) if (${_PYTHON_PREFIX}_Interpreter_FOUND) execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.PREFIX)" + "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.EXEC_PREFIX)" RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PREFIX + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_EXEC_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if (_${_PYTHON_PREFIX}_RESULT) - unset (_${_PYTHON_PREFIX}_PREFIX) + unset (_${_PYTHON_PREFIX}_EXEC_PREFIX) + endif() + + if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "STANDARD") + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c + "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.BASE_EXEC_PREFIX)" + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_BASE_EXEC_PREFIX + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX) + endif() endif() endif() - set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_EXEC_PREFIX}" "${_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) string (REPLACE "." "" _${_PYTHON_PREFIX}_VERSION_NO_DOTS ${_${_PYTHON_PREFIX}_VERSION}) diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index b9c0b6b..a2be84f 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -153,11 +153,23 @@ Hints Value ``ONLY`` is not supported so ``FIRST`` will be used instead. -.. note:: +``Python2_FIND_VIRTUALENV`` + This variable defines the handling of virtual environments. It is meaningfull + only when a virtual environment is active (i.e. the ``activate`` script has + been evaluated). In this case, it takes precedence over + ``Python2_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. + The ``Python2_FIND_VIRTUALENV`` variable can be set to empty or one of the + following: - If a Python virtual environment is configured, set variable - ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with - value ``LAST`` or ``NEVER`` to select it preferably. + * ``FIRST``: The virtual environment is used before any other standard + paths to look-up for the interpreter. This is the default. + * ``ONLY``: Only the virtual environment is used to look-up for the + interpreter. + * ``STANDARD``: The virtual environment is not used to look-up for the + interpreter. In this case, variable ``Python2_FIND_REGISTRY`` (Windows) + or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + ``NEVER`` to select preferably the interpreter from the virtual + environment. Commands ^^^^^^^^ diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index c2f3384..3409554 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -137,7 +137,7 @@ Hints ``Python3_FIND_REGISTRY`` On Windows the ``Python3_FIND_REGISTRY`` variable determine the order of preference between registry and environment variables. - the ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the + The ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the following: * ``FIRST``: Try to use registry before environment variables. @@ -146,18 +146,30 @@ Hints * ``NEVER``: Never try to use registry. ``CMAKE_FIND_FRAMEWORK`` - On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of + On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of preference between Apple-style and unix-style package components. .. note:: Value ``ONLY`` is not supported so ``FIRST`` will be used instead. -.. note:: +``Python3_FIND_VIRTUALENV`` + This variable defines the handling of virtual environments. It is meaningfull + only when a virtual environment is active (i.e. the ``activate`` script has + been evaluated). In this case, it takes precedence over + ``Python3_FIND_REGISTRY`` and ``CMAKE_FIND_FRAMEWORK`` variables. + The ``Python3_FIND_VIRTUALENV`` variable can be set to empty or one of the + following: - If a Python virtual environment is configured, set variable - ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with - value ``LAST`` or ``NEVER`` to select it preferably. + * ``FIRST``: The virtual environment is used before any other standard + paths to look-up for the interpreter. This is the default. + * ``ONLY``: Only the virtual environment is used to look-up for the + interpreter. + * ``STANDARD``: The virtual environment is not used to look-up for the + interpreter. In this case, variable ``Python3_FIND_REGISTRY`` (Windows) + or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or + ``NEVER`` to select preferably the interpreter from the virtual + environment. Commands ^^^^^^^^ diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 2813831..8d793a9 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -112,9 +112,6 @@ if(NOT SDL_BUILDING_LIBRARY) ENV SDLDIR PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} PATHS - /sw - /opt/local - /opt/csw /opt ) endif() diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index e217981..c986574 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -208,9 +208,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV MIKMODDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -228,9 +225,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV MODPLUGDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -250,9 +244,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV OGGDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -268,9 +259,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV VORBISDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -289,9 +277,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV SMPEGDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -310,9 +295,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV FLACDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -334,9 +316,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV SPEEXDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib @@ -356,9 +335,6 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY) ENV SPEEXDIR ENV SDLSOUNDDIR ENV SDLDIR - /sw - /opt/local - /opt/csw /opt PATH_SUFFIXES lib ) diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index fc0ed00..a5e3a37 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -5,13 +5,13 @@ FindSWIG -------- -Find SWIG +Find Simplified Wrapper and Interface Generator (SWIG) This module finds an installed SWIG. It sets the following variables: :: - SWIG_FOUND - set to true if SWIG is found + SWIG_FOUND - set to "True" if SWIG is found SWIG_DIR - the directory where swig is installed SWIG_EXECUTABLE - the path to the swig executable SWIG_VERSION - the version number of the swig executable @@ -19,11 +19,11 @@ This module finds an installed SWIG. It sets the following variables: The minimum required version of SWIG can be specified using the -standard syntax, e.g. find_package(SWIG 1.1) +standard syntax, e.g. :command:`find_package(SWIG 1.1)` -All information is collected from the SWIG_EXECUTABLE so the version +All information is collected from the ``SWIG_EXECUTABLE``, so the version to be found can be changed from the command line by means of setting -SWIG_EXECUTABLE +``SWIG_EXECUTABLE`` #]=======================================================================] find_program(SWIG_EXECUTABLE NAMES swig3.0 swig2.0 swig) @@ -64,4 +64,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR VERSION_VAR SWIG_VERSION ) -mark_as_advanced(SWIG_DIR SWIG_VERSION) +mark_as_advanced(SWIG_DIR SWIG_VERSION SWIG_EXECUTABLE) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 63ca936..00a3a41 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -5,7 +5,7 @@ FindTIFF -------- -Find the TIFF library (libtiff). +Find the TIFF library (``libtiff``). Imported targets ^^^^^^^^^^^^^^^^ diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 919392a..d317b71 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -38,19 +38,42 @@ This module is not needed for C++11 and later if threading is done using #]=======================================================================] include (CheckLibraryExists) -include (CheckSymbolExists) set(Threads_FOUND FALSE) set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY}) if(CMAKE_C_COMPILER_LOADED) include (CheckIncludeFile) + include (CheckCSourceCompiles) elseif(CMAKE_CXX_COMPILER_LOADED) include (CheckIncludeFileCXX) + include (CheckCXXSourceCompiles) else() message(FATAL_ERROR "FindThreads only works if either C or CXX language is enabled") endif() +# simple pthread test code +set(PTHREAD_C_CXX_TEST_SOURCE [====[ +#include <pthread.h> + +void* test_func(void* data) +{ + return data; +} + +int main(void) +{ + pthread_t thread; + pthread_create(&thread, NULL, test_func, NULL); + pthread_detach(thread); + pthread_join(thread, NULL); + pthread_atfork(NULL, NULL, NULL); + pthread_exit(NULL); + + return 0; +} +]====]) + # Internal helper macro. # Do NOT even think about using it outside of this file! macro(_check_threads_lib LIBNAME FUNCNAME VARNAME) @@ -109,8 +132,8 @@ if(CMAKE_C_COMPILER_LOADED) else() CHECK_INCLUDE_FILE_CXX("pthread.h" CMAKE_HAVE_PTHREAD_H) endif() -if(CMAKE_HAVE_PTHREAD_H) +if(CMAKE_HAVE_PTHREAD_H) # # We have pthread.h # Let's check for the library now. @@ -118,13 +141,19 @@ if(CMAKE_HAVE_PTHREAD_H) set(CMAKE_HAVE_THREADS_LIBRARY) if(NOT THREADS_HAVE_PTHREAD_ARG) # Check if pthread functions are in normal C library. - CHECK_SYMBOL_EXISTS(pthread_create pthread.h CMAKE_HAVE_LIBC_CREATE) - if(CMAKE_HAVE_LIBC_CREATE) + # We list some pthread functions in PTHREAD_C_CXX_TEST_SOURCE test code. + # If the pthread functions already exist in C library, we could just use + # them instead of linking to the additional pthread library. + if(CMAKE_C_COMPILER_LOADED) + CHECK_C_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) + elseif(CMAKE_CXX_COMPILER_LOADED) + CHECK_CXX_SOURCE_COMPILES("${PTHREAD_C_CXX_TEST_SOURCE}" CMAKE_HAVE_LIBC_PTHREAD) + endif() + if(CMAKE_HAVE_LIBC_PTHREAD) set(CMAKE_THREAD_LIBS_INIT "") set(CMAKE_HAVE_THREADS_LIBRARY 1) set(Threads_FOUND TRUE) else() - # Check for -pthread first if enabled. This is the recommended # way, but not backwards compatible as one must also pass -pthread # as compiler flag then. @@ -132,6 +161,9 @@ if(CMAKE_HAVE_PTHREAD_H) _check_pthreads_flag() endif () + if(CMAKE_SYSTEM MATCHES "GHS-MULTI") + _check_threads_lib(posix pthread_create CMAKE_HAVE_PTHREADS_CREATE) + endif() _check_threads_lib(pthreads pthread_create CMAKE_HAVE_PTHREADS_CREATE) _check_threads_lib(pthread pthread_create CMAKE_HAVE_PTHREAD_CREATE) if(CMAKE_SYSTEM_NAME MATCHES "SunOS") @@ -144,7 +176,7 @@ if(CMAKE_HAVE_PTHREAD_H) _check_pthreads_flag() endif() -if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE) +if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_PTHREAD) set(CMAKE_USE_PTHREADS_INIT 1) set(Threads_FOUND TRUE) endif() diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake index 3a735f7..2513f5c 100644 --- a/Modules/FindUnixCommands.cmake +++ b/Modules/FindUnixCommands.cmake @@ -7,8 +7,9 @@ FindUnixCommands Find Unix commands, including the ones from Cygwin -This module looks for the Unix commands bash, cp, gzip, mv, rm, and tar -and stores the result in the variables BASH, CP, GZIP, MV, RM, and TAR. +This module looks for the Unix commands ``bash``, ``cp``, ``gzip``, +``mv``, ``rm``, and ``tar`` and stores the result in the variables +``BASH``, ``CP``, ``GZIP``, ``MV``, ``RM``, and ``TAR``. #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake) diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index b1201b4..ae8d72d 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -5,7 +5,8 @@ FindVulkan ---------- -Try to find Vulkan +Find Vulkan, which isis a low-overhead, cross-platform 3D graphics +and computing API. IMPORTED Targets ^^^^^^^^^^^^^^^^ @@ -18,7 +19,7 @@ Result Variables This module defines the following variables:: - Vulkan_FOUND - True if Vulkan was found + Vulkan_FOUND - "True" if Vulkan was found Vulkan_INCLUDE_DIRS - include directories for Vulkan Vulkan_LIBRARIES - link against this library to use Vulkan diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index bb28454..027f315 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -7,8 +7,6 @@ Findosg - - NOTE: It is highly recommended that you use the new FindOpenSceneGraph.cmake introduced in CMake 2.6.3 and not use this Find module directly. diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index d0789ba..a28f650 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -7,30 +7,38 @@ FindosgDB -This is part of the Findosg* suite used to find OpenSceneGraph +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 +module (perhaps because the default :module:`FindOpenGL` 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. +:module:`FindOpenSceneGraph` instead of the ``Findosg*.cmake`` modules. -Locate osgDB This module defines +Locate osgDB This module defines: -OSGDB_FOUND - Was osgDB found? OSGDB_INCLUDE_DIR - Where to find the -headers OSGDB_LIBRARIES - The libraries to link against for the osgDB -(use this) +``OSGDB_FOUND`` + Was osgDB found? -OSGDB_LIBRARY - The osgDB library OSGDB_LIBRARY_DEBUG - The osgDB -debug library +``OSGDB_INCLUDE_DIR`` + Where to find the headers -$OSGDIR is an environment variable that would correspond to the -./configure --prefix=$OSGDIR used in building osg. +``OSGDB_LIBRARIES`` + The libraries to link against for the osgDB + +``OSGDB_LIBRARY`` + The osgDB library + +``OSGDB_LIBRARY_DEBUG`` + The osgDB debug library + +``$OSGDIR`` is an environment variable that would correspond to:: + + ./configure --prefix=$OSGDIR used in building osg. -Created by Eric Wing. #]=======================================================================] # Header files are presumed to be included like diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index e3b81d7..381080b 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -15,11 +15,11 @@ int main() { return 0; } # List manglings of global symbol names to try. set(global_symbols my_sub # VisualAge - my_sub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI + my_sub_ # GNU, Intel, HP, SunPro, PGI my_sub__ # GNU g77 MY_SUB # Intel on Windows mysub # VisualAge - mysub_ # GNU, Intel, HP, SunPro, MIPSpro, PGI + mysub_ # GNU, Intel, HP, SunPro, PGI MYSUB # Intel on Windows ${FortranCInterface_GLOBAL_SYMBOLS} ) @@ -48,7 +48,6 @@ set(module_symbols list(REMOVE_DUPLICATES module_symbols) # Note that some compiler manglings cannot be invoked from C: -# MIPSpro uses "MY_SUB.in.MY_MODULE" # SunPro uses "my_module.my_sub_" # PathScale uses "MY_SUB.in.MY_MODULE" diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake index f2e4527..e4481f6 100644 --- a/Modules/GenerateExportHeader.cmake +++ b/Modules/GenerateExportHeader.cmake @@ -7,7 +7,7 @@ GenerateExportHeader Function for generation of export macros for libraries -This module provides the function GENERATE_EXPORT_HEADER(). +This module provides the function ``GENERATE_EXPORT_HEADER()``. The ``GENERATE_EXPORT_HEADER`` function can be used to generate a file suitable for preprocessor inclusion which contains EXPORT macros to be diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 2de71ee..26b2517 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -63,6 +63,11 @@ function(get_unix_permissions_octal_notation PERMISSIONS_VAR RETURN_VAR) set(${RETURN_VAR} "${OWNER_PERMISSIONS}${GROUP_PERMISSIONS}${WORLD_PERMISSIONS}" PARENT_SCOPE) endfunction() +function(cpack_rpm_exact_regex regex_var string) + string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" regex "${string}") + set("${regex_var}" "${regex}" PARENT_SCOPE) +endfunction() + function(cpack_rpm_prepare_relocation_paths) # set appropriate prefix, remove possible trailing slash and convert backslashes to slashes if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_PREFIX) @@ -482,7 +487,9 @@ function(cpack_rpm_prepare_install_files INSTALL_FILES_LIST WDIR PACKAGE_PREFIXE # recalculate path length after conversion to canonical form string(LENGTH "${SYMLINK_POINT_}" SYMLINK_POINT_LENGTH_) - if(SYMLINK_POINT_ MATCHES "${WDIR}/.*") + cpack_rpm_exact_regex(IN_SYMLINK_POINT_REGEX "${WDIR}") + string(APPEND IN_SYMLINK_POINT_REGEX "/.*") + if(SYMLINK_POINT_ MATCHES "${IN_SYMLINK_POINT_REGEX}") # only symlinks that are pointing inside the packaging structure should be checked for relocation string(SUBSTRING "${SYMLINK_POINT_}" ${WDR_LEN_} -1 SYMLINK_POINT_WD_) cpack_rpm_symlink_get_relocation_prefixes("${F}" "${PACKAGE_PREFIXES}" "SYMLINK_RELOCATIONS") diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index de336e7..75be473 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -71,10 +71,35 @@ endmacro() macro(_record_compiler_features_c std) list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std}) - _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) + + get_property(lang_level_has_features GLOBAL PROPERTY CMAKE_C${std}_KNOWN_FEATURES) + if(lang_level_has_features) + _record_compiler_features(C "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) + endif() + unset(lang_level_has_features) endmacro() macro(_record_compiler_features_cxx std) list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std}) - _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) + + get_property(lang_level_has_features GLOBAL PROPERTY CMAKE_CXX${std}_KNOWN_FEATURES) + if(lang_level_has_features) + _record_compiler_features(CXX "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) + endif() + unset(lang_level_has_features) +endmacro() + +macro(_has_compiler_features lang level compile_flags feature_list) + # presume all known features are supported + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(APPEND ${feature_list} ${known_features}) +endmacro() + +macro(_has_compiler_features_c std) + list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std}) + _has_compiler_features(C ${std} "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) +endmacro() +macro(_has_compiler_features_cxx std) + list(APPEND CMAKE_CXX${std}_COMPILE_FEATURES cxx_std_${std}) + _has_compiler_features(CXX ${std} "${CMAKE_CXX${std}_STANDARD_COMPILE_OPTION}" CMAKE_CXX${std}_COMPILE_FEATURES) endmacro() diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake index b3078ff..06a806b 100644 --- a/Modules/Platform/AIX-XL.cmake +++ b/Modules/Platform/AIX-XL.cmake @@ -25,4 +25,26 @@ macro(__aix_compiler_xl lang) set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ") set(CMAKE_${lang}_LINK_FLAGS "-Wl,-bnoipath") + + # Find the CreateExportList program that comes with this toolchain. + find_program(CMAKE_XL_CreateExportList + NAMES CreateExportList + DOC "IBM XL CreateExportList tool" + ) + + # 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> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" + ) + endif() endmacro() diff --git a/Modules/Platform/AIX-XLClang-C.cmake b/Modules/Platform/AIX-XLClang-C.cmake new file mode 100644 index 0000000..f0bedc5 --- /dev/null +++ b/Modules/Platform/AIX-XLClang-C.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-XLClang) +__aix_compiler_xlclang(C) diff --git a/Modules/Platform/AIX-XLClang-CXX.cmake b/Modules/Platform/AIX-XLClang-CXX.cmake new file mode 100644 index 0000000..cceb576 --- /dev/null +++ b/Modules/Platform/AIX-XLClang-CXX.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-XLClang) +__aix_compiler_xlclang(CXX) diff --git a/Modules/Platform/AIX-XLClang.cmake b/Modules/Platform/AIX-XLClang.cmake new file mode 100644 index 0000000..c932095 --- /dev/null +++ b/Modules/Platform/AIX-XLClang.cmake @@ -0,0 +1,15 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__AIX_COMPILER_XLCLANG) + return() +endif() +set(__AIX_COMPILER_XLCLANG 1) + +include(Platform/AIX-XL) + +macro(__aix_compiler_xlclang lang) + __aix_compiler_xl(${lang}) +endmacro() diff --git a/Modules/Platform/Android.cmake b/Modules/Platform/Android.cmake index 3d69733..f08f841 100644 --- a/Modules/Platform/Android.cmake +++ b/Modules/Platform/Android.cmake @@ -2,9 +2,11 @@ include(Platform/Linux) set(ANDROID 1) -# Android has soname, but binary names must end in ".so" so we cannot append -# a version number. Also we cannot portably represent symlinks on the host. -set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1) +# Conventionally Android does not use versioned soname +# But in modern versions it is acceptable +if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME) + set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1) +endif() # Android reportedly ignores RPATH, and we cannot predict the install # location anyway. diff --git a/Modules/Platform/CrayLinuxEnvironment.cmake b/Modules/Platform/CrayLinuxEnvironment.cmake index a1a3d3f..f2aaf3f 100644 --- a/Modules/Platform/CrayLinuxEnvironment.cmake +++ b/Modules/Platform/CrayLinuxEnvironment.cmake @@ -1,6 +1,5 @@ -# Compute Node Linux doesn't quite work the same as native Linux so all of this -# needs to be custom. We use the variables defined through Cray's environment -# modules to set up the right paths for things. +# CrayLinuxEnvironment: loaded by users cross-compiling on a Cray front-end +# node by specifying "-DCMAKE_SYSTEM_NAME=CrayLinuxEnvironment" to cmake set(UNIX 1) @@ -30,13 +29,6 @@ endif() # Note: this may need to change in the future with 64-bit ARM set(CMAKE_SYSTEM_PROCESSOR "x86_64") -set(CMAKE_SHARED_LIBRARY_PREFIX "lib") -set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") -set(CMAKE_STATIC_LIBRARY_PREFIX "lib") -set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") - -set(CMAKE_FIND_LIBRARY_PREFIXES "lib") - # Don't override shared lib support if it's already been set and possibly # overridden elsewhere by the CrayPrgEnv module if(NOT CMAKE_FIND_LIBRARY_SUFFIXES) @@ -44,12 +36,9 @@ if(NOT CMAKE_FIND_LIBRARY_SUFFIXES) set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) endif() -set(CMAKE_DL_LIBS dl) +# The rest of this file is based on UnixPaths.cmake, adjusted for Cray -# Note: Much of this is pulled from UnixPaths.cmake but adjusted to the Cray -# environment accordingly - -# Get the install directory of the running cmake to the search directories +# add the install directory of the running cmake to the search directories # CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up get_filename_component(__cmake_install_dir "${CMAKE_ROOT}" PATH) get_filename_component(__cmake_install_dir "${__cmake_install_dir}" PATH) @@ -81,7 +70,6 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) endif() list(APPEND CMAKE_SYSTEM_INCLUDE_PATH - $ENV{SYSROOT_DIR}/usr/include $ENV{SYSROOT_DIR}/usr/include/X11 ) list(APPEND CMAKE_SYSTEM_LIBRARY_PATH @@ -95,57 +83,5 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES $ENV{SYSROOT_DIR}/lib64 ) -# Compute the intersection of several lists -function(__cray_list_intersect OUTPUT INPUT0) - if(ARGC EQUAL 2) - list(APPEND ${OUTPUT} ${${INPUT0}}) - else() - foreach(I IN LISTS ${INPUT0}) - set(__is_common 1) - foreach(L IN LISTS ARGN) - list(FIND ${L} "${I}" __idx) - if(__idx EQUAL -1) - set(__is_common 0) - break() - endif() - endforeach() - if(__is_common) - list(APPEND ${OUTPUT} "${I}") - endif() - endforeach() - endif() - set(${OUTPUT} ${${OUTPUT}} PARENT_SCOPE) -endfunction() - -macro(__list_clean_dupes var) - if(${var}) - list(REMOVE_DUPLICATES ${var}) - endif() -endmacro() - -get_property(__langs GLOBAL PROPERTY ENABLED_LANGUAGES) -set(__cray_inc_path_vars) -set(__cray_lib_path_vars) -foreach(__lang IN LISTS __langs) - list(APPEND __cray_inc_path_vars CMAKE_${__lang}_IMPLICIT_INCLUDE_DIRECTORIES) - list(APPEND __cray_lib_path_vars CMAKE_${__lang}_IMPLICIT_LINK_DIRECTORIES) -endforeach() -if(__cray_inc_path_vars) - __cray_list_intersect(__cray_implicit_include_dirs ${__cray_inc_path_vars}) - if(__cray_implicit_include_dirs) - list(INSERT CMAKE_SYSTEM_INCLUDE_PATH 0 ${__cray_implicit_include_dirs}) - endif() -endif() -if(__cray_lib_path_vars) - __cray_list_intersect(__cray_implicit_library_dirs ${__cray_lib_path_vars}) - if(__cray_implicit_library_dirs) - list(INSERT CMAKE_SYSTEM_LIBRARY_PATH 0 ${__cray_implicit_library_dirs}) - endif() -endif() -__list_clean_dupes(CMAKE_SYSTEM_PREFIX_PATH) -__list_clean_dupes(CMAKE_SYSTEM_INCLUDE_PATH) -__list_clean_dupes(CMAKE_SYSTEM_LIBRARY_PATH) -__list_clean_dupes(CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES) - # Enable use of lib64 search path variants by default. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE) diff --git a/Modules/Platform/GHS-MULTI-Initialize.cmake b/Modules/Platform/GHS-MULTI-Determine.cmake index 25004c6..349d906 100644 --- a/Modules/Platform/GHS-MULTI-Initialize.cmake +++ b/Modules/Platform/GHS-MULTI-Determine.cmake @@ -3,45 +3,50 @@ #Setup Green Hills MULTI specific compilation information -set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") +if(CMAKE_HOST_UNIX) + set(GHS_OS_ROOT "/usr/ghs" CACHE PATH "GHS platform OS search root directory") +else() + set(GHS_OS_ROOT "C:/ghs" CACHE PATH "GHS platform OS search root directory") +endif() mark_as_advanced(GHS_OS_ROOT) set(GHS_OS_DIR "NOTFOUND" CACHE PATH "GHS platform OS directory") mark_as_advanced(GHS_OS_DIR) -set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler os option") -mark_as_advanced(GHS_OS_DIR) +set(GHS_OS_DIR_OPTION "-os_dir " CACHE STRING "GHS compiler OS option") +mark_as_advanced(GHS_OS_DIR_OPTION) #set GHS_OS_DIR if not set by user -if ( NOT GHS_OS_DIR ) - if (EXISTS ${GHS_OS_ROOT}) +if(NOT GHS_OS_DIR) + if(EXISTS ${GHS_OS_ROOT}) #get all directories in root directory FILE(GLOB GHS_CANDIDATE_OS_DIRS LIST_DIRECTORIES true RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*) FILE(GLOB GHS_CANDIDATE_OS_FILES LIST_DIRECTORIES false RELATIVE ${GHS_OS_ROOT} ${GHS_OS_ROOT}/*) - if ( GHS_CANDIDATE_OS_FILES ) + if(GHS_CANDIDATE_OS_FILES) list(REMOVE_ITEM GHS_CANDIDATE_OS_DIRS ${GHS_CANDIDATE_OS_FILES}) endif () #filter based on platform name - if (GHS_TARGET_PLATFORM MATCHES "integrity") - list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z].*") + if(GHS_TARGET_PLATFORM MATCHES "integrity") + list(FILTER GHS_CANDIDATE_OS_DIRS INCLUDE REGEX "int[0-9][0-9][0-9][0-9a-z]") else() #fall-back for standalone unset(GHS_CANDIDATE_OS_DIRS) set(GHS_OS_DIR "IGNORE") - endif () + endif() - if (GHS_CANDIDATE_OS_DIRS) + if(GHS_CANDIDATE_OS_DIRS) list(SORT GHS_CANDIDATE_OS_DIRS) list(GET GHS_CANDIDATE_OS_DIRS -1 GHS_OS_DIR) string(CONCAT GHS_OS_DIR ${GHS_OS_ROOT} "/" ${GHS_OS_DIR}) endif() + #update cache with new value set(GHS_OS_DIR "${GHS_OS_DIR}" CACHE PATH "GHS platform OS directory" FORCE) - endif () -endif () + endif() +endif() set(GHS_BSP_NAME "IGNORE" CACHE STRING "BSP name") diff --git a/Modules/Platform/Windows-Intel-Fortran.cmake b/Modules/Platform/Windows-Intel-Fortran.cmake index 3981a09..e3804fb 100644 --- a/Modules/Platform/Windows-Intel-Fortran.cmake +++ b/Modules/Platform/Windows-Intel-Fortran.cmake @@ -4,8 +4,41 @@ set(_COMPILE_Fortran " /fpp") set(CMAKE_Fortran_MODDIR_FLAG "-module:") set(CMAKE_Fortran_STANDARD_LIBRARIES_INIT "user32.lib") __windows_compiler_intel(Fortran) -string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1 /nologo /fpp /libs:dll /threads") -string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full /dbglibs") +if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + set(_LIBSDLL "") + set(_DBGLIBS "") + set(_THREADS "") +else() + set(_LIBSDLL " /libs:dll") + set(_DBGLIBS " /dbglibs") + set(_THREADS " /threads") +endif() + +cmake_policy(GET CMP0092 _cmp0092) +if(NOT _cmp0092 STREQUAL "NEW") + string(APPEND CMAKE_Fortran_FLAGS_INIT " /W1") +endif() +unset(_cmp0092) + +string(APPEND CMAKE_Fortran_FLAGS_INIT " /nologo /fpp${_LIBSDLL}${_THREADS}") +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT " /Od /debug:full${_DBGLIBS}") string(APPEND CMAKE_Fortran_FLAGS_MINSIZEREL_INIT " /O1 /DNDEBUG") string(APPEND CMAKE_Fortran_FLAGS_RELEASE_INIT " /O2 /DNDEBUG") string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT " /O2 /debug:full /DNDEBUG") +unset(_LIBSDLL) +unset(_DBGLIBS) +unset(_THREADS) + +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -threads -libs:static) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -threads -libs:dll) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -threads -libs:static -dbglibs) +set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -threads -libs:dll -dbglibs) + +# Intel Fortran for Windows supports single-threaded RTL but it is +# not implemented by the Visual Studio integration. +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreaded -libs:static) + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDLL -libs:dll) + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDebug -libs:static -dbglibs) + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_SingleThreadedDebugDLL -libs:dll -dbglibs) +endif() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index a6448a0..ed0e7fb 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -298,6 +298,14 @@ endforeach() string(APPEND CMAKE_STATIC_LINKER_FLAGS_INIT " ${_MACHINE_ARCH_FLAG}") unset(_MACHINE_ARCH_FLAG) +cmake_policy(GET CMP0091 __WINDOWS_MSVC_CMP0091) +if(__WINDOWS_MSVC_CMP0091 STREQUAL "NEW") + set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL") +else() + set(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT "") +endif() +unset(__WINDOWS_MSVC_CMP0091) + macro(__windows_compiler_msvc lang) if(NOT MSVC_VERSION LESS 1400) # for 2005 make sure the manifest is put in the dll with mt @@ -351,21 +359,48 @@ macro(__windows_compiler_msvc lang) if("x${lang}" STREQUAL "xC" OR "x${lang}" STREQUAL "xCXX") + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + set(_MDd "") + set(_MD "") + else() + set(_MDd " /MDd") + set(_MD " /MD") + endif() + + cmake_policy(GET CMP0092 _cmp0092) + if(_cmp0092 STREQUAL "NEW") + set(_W3 "") + set(_Wall "") + else() + set(_W3 " /W3") + set(_Wall " -Wall") + endif() + unset(_cmp0092) + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") # note: MSVC 14 2015 Update 1 sets -fno-ms-compatibility by default, but this does not allow one to compile many projects # that include MS's own headers. CMake itself is affected project too. - string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS -Wall${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd -gline-tables-only -fno-inline -O0 ${_RTC1}") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD -O2 -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD -gline-tables-only -O2 -fno-inline -DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} -fms-extensions -fms-compatibility -D_WINDOWS${_Wall}${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} -gline-tables-only -fno-inline -O0 ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} -O2 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} -gline-tables-only -O2 -fno-inline -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} -DNDEBUG") # TODO: Add '-Os' once VS generator maps it properly for Clang else() - string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS /W3${_FLAGS_${lang}}") - string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " /MDd /Zi /Ob0 /Od ${_RTC1}") - string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " /MD /O2 /Ob2 /DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " /MD /Zi /O2 /Ob1 /DNDEBUG") - string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " /MD /O1 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_${lang}} /D_WINDOWS${_W3}${_FLAGS_${lang}}") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT "${_MDd} /Zi /Ob0 /Od ${_RTC1}") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT "${_MD} /O2 /Ob2 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "${_MD} /Zi /O2 /Ob1 /DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "${_MD} /O1 /Ob1 /DNDEBUG") endif() + unset(_Wall) + unset(_W3) + unset(_MDd) + unset(_MD) + + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -MT) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -MD) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -MTd) + set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -MDd) endif() set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON) set(CMAKE_NINJA_DEPTYPE_${lang} msvc) @@ -377,10 +412,12 @@ macro(__windows_compiler_msvc_enable_rc flags) set(CMAKE_RC_COMPILER_INIT rc) endif() if(NOT CMAKE_RC_FLAGS_INIT) - string(APPEND CMAKE_RC_FLAGS_INIT " ${flags}") + # llvm-rc fails when flags are specified with /D and no space after + string(REPLACE " /D" " -D" fixed_flags " ${flags}") + string(APPEND CMAKE_RC_FLAGS_INIT " ${fixed_flags}") endif() if(NOT CMAKE_RC_FLAGS_DEBUG_INIT) - string(APPEND CMAKE_RC_FLAGS_DEBUG_INIT " /D_DEBUG") + string(APPEND CMAKE_RC_FLAGS_DEBUG_INIT " -D_DEBUG") endif() enable_language(RC) diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index 6a2667a..f160c7b 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -60,11 +60,20 @@ unset(__IMPLICT_DLINK_FLAGS) string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}") -string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"/W3${_FLAGS_CXX}\"") +cmake_policy(GET CMP0092 _cmp0092) +if(_cmp0092 STREQUAL "NEW") + set(_W3 "") +else() + set(_W3 "/W3") +endif() +unset(_cmp0092) + +string(APPEND CMAKE_CUDA_FLAGS_INIT " ${PLATFORM_DEFINES_CUDA} -D_WINDOWS -Xcompiler=\"${_W3}${_FLAGS_CXX}\"") string(APPEND CMAKE_CUDA_FLAGS_DEBUG_INIT " -Xcompiler=\"-MDd -Zi -Ob0 -Od ${_RTC1}\"") string(APPEND CMAKE_CUDA_FLAGS_RELEASE_INIT " -Xcompiler=\"-MD -O2 -Ob2\" -DNDEBUG") string(APPEND CMAKE_CUDA_FLAGS_RELWITHDEBINFO_INIT " -Xcompiler=\"-MD -Zi -O2 -Ob1\" -DNDEBUG") string(APPEND CMAKE_CUDA_FLAGS_MINSIZEREL_INIT " -Xcompiler=\"-MD -O1 -Ob1\" -DNDEBUG") +unset(_W3) set(CMAKE_CUDA_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index e4b4e53..8c25256 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -70,6 +70,20 @@ function(ProcessorCount var) endif() if(NOT count) + # Linux (systems with nproc): + # Prefer nproc to getconf if available as getconf may return the host CPU count in Linux containers + find_program(ProcessorCount_cmd_nproc nproc) + mark_as_advanced(ProcessorCount_cmd_nproc) + if(ProcessorCount_cmd_nproc) + execute_process(COMMAND ${ProcessorCount_cmd_nproc} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE count) + #message("ProcessorCount: trying nproc '${ProcessorCount_cmd_nproc}'") + endif() + endif() + + if(NOT count) # Linux (systems with getconf): find_program(ProcessorCount_cmd_getconf getconf) mark_as_advanced(ProcessorCount_cmd_getconf) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index dc2348e..8fec717 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -7,8 +7,8 @@ UseQt4 Use Module for QT4 -Sets up C and C++ to use Qt 4. It is assumed that FindQt.cmake has -already been loaded. See FindQt.cmake for information on how to load +Sets up C and C++ to use Qt 4. It is assumed that :module:`FindQt` has +already been loaded. See :module:`FindQt` for information on how to load Qt 4 into your CMake project. #]=======================================================================] @@ -105,4 +105,3 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN endif () endforeach() - diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake index 21ccd7c..23d81b5 100644 --- a/Modules/WriteCompilerDetectionHeader.cmake +++ b/Modules/WriteCompilerDetectionHeader.cmake @@ -5,7 +5,7 @@ WriteCompilerDetectionHeader ---------------------------- -This module provides the function write_compiler_detection_header(). +This module provides the function ``write_compiler_detection_header()``. This function can be used to generate a file suitable for preprocessor inclusion which contains macros to be used in source code:: |