From d140263a497b4a86818ab5e2017a66df43eb83fb Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Fri, 8 Oct 2021 09:14:03 +0900 Subject: Imported Upstream version 3.15.0 --- Modules/AddFileDependencies.cmake | 16 +- .../BasicConfigVersion-AnyNewerVersion.cmake.in | 8 +- Modules/BasicConfigVersion-ExactVersion.cmake.in | 2 +- .../BasicConfigVersion-SameMajorVersion.cmake.in | 2 +- .../BasicConfigVersion-SameMinorVersion.cmake.in | 2 +- Modules/BundleUtilities.cmake | 126 +- Modules/CMakeASM_NASMInformation.cmake | 4 +- Modules/CMakeAddFortranSubdirectory.cmake | 8 +- Modules/CMakeAddNewLanguage.txt | 22 +- Modules/CMakeCCompiler.cmake.in | 1 + Modules/CMakeCXXCompiler.cmake.in | 1 + Modules/CMakeCheckCompilerFlagCommonPatterns.cmake | 49 +- Modules/CMakeCompilerIdDetection.cmake | 6 +- Modules/CMakeDetermineASMCompiler.cmake | 23 +- Modules/CMakeDetermineASM_MASMCompiler.cmake | 6 +- Modules/CMakeDetermineCCompiler.cmake | 7 +- Modules/CMakeDetermineCSharpCompiler.cmake | 2 +- Modules/CMakeDetermineCXXCompiler.cmake | 7 +- Modules/CMakeDetermineCompilerId.cmake | 131 +- Modules/CMakeDetermineSwiftCompiler.cmake | 49 +- Modules/CMakeDetermineVSServicePack.cmake | 52 +- Modules/CMakeExpandImportedTargets.cmake | 195 ++- Modules/CMakeFindBinUtils.cmake | 21 +- Modules/CMakeFindCodeBlocks.cmake | 2 +- Modules/CMakeFindDependencyMacro.cmake | 51 +- Modules/CMakeFindSublimeText2.cmake | 2 +- Modules/CMakeForceCompiler.cmake | 33 +- Modules/CMakeFortranCompilerId.F.in | 7 - Modules/CMakeJavaInformation.cmake | 4 +- Modules/CMakeNinjaFindMake.cmake | 2 +- Modules/CMakeParseImplicitIncludeInfo.cmake | 6 +- Modules/CMakePlatformId.h.in | 15 + Modules/CMakePrintHelpers.cmake | 16 +- Modules/CMakePushCheckState.cmake | 66 +- Modules/CMakeRCInformation.cmake | 2 +- Modules/CMakeSwiftCompiler.cmake.in | 9 + Modules/CMakeSwiftInformation.cmake | 71 +- Modules/CMakeSystemSpecificInformation.cmake | 2 +- Modules/CMakeTestSwiftCompiler.cmake | 7 +- Modules/CTestCoverageCollectGCOV.cmake | 40 +- Modules/CheckCCompilerFlag.cmake | 42 +- Modules/CheckCXXCompilerFlag.cmake | 46 +- Modules/CheckCXXSymbolExists.cmake | 2 +- Modules/CheckLanguage.cmake | 37 +- Modules/CheckPIESupported.cmake | 4 +- Modules/CheckStructHasMember.cmake | 46 +- Modules/CheckTypeSize.c.in | 2 +- Modules/Compiler/ARMCC-ASM.cmake | 2 +- Modules/Compiler/ARMClang-ASM.cmake | 9 + Modules/Compiler/ARMClang-C-FeatureTests.cmake | 1 + Modules/Compiler/ARMClang-C.cmake | 15 + Modules/Compiler/ARMClang-CXX-FeatureTests.cmake | 1 + Modules/Compiler/ARMClang-CXX.cmake | 3 + Modules/Compiler/ARMClang-DetermineCompiler.cmake | 10 + Modules/Compiler/ARMClang.cmake | 71 + Modules/Compiler/AppleClang-C.cmake | 3 + Modules/Compiler/AppleClang-CXX.cmake | 12 + Modules/Compiler/CMakeCommonCompilerMacros.cmake | 56 +- Modules/Compiler/Clang-C.cmake | 6 + Modules/Compiler/Clang-CXX.cmake | 18 +- Modules/Compiler/Cray-C.cmake | 3 + Modules/Compiler/Cray-CXX.cmake | 3 + Modules/Compiler/Cray-Fortran.cmake | 2 + Modules/Compiler/CrayPrgEnv.cmake | 111 +- Modules/Compiler/GNU-C.cmake | 3 + Modules/Compiler/GNU-CXX.cmake | 9 + Modules/Compiler/GNU-FindBinUtils.cmake | 4 +- Modules/Compiler/IAR-ASM.cmake | 37 +- Modules/Compiler/IAR-C.cmake | 83 +- Modules/Compiler/IAR-CXX.cmake | 97 +- Modules/Compiler/IAR-DetermineCompiler.cmake | 2 +- Modules/Compiler/IAR-FindBinUtils.cmake | 47 +- Modules/Compiler/IAR.cmake | 37 +- .../IBMCPP-C-DetermineVersionInternal.cmake | 16 +- .../IBMCPP-CXX-DetermineVersionInternal.cmake | 16 +- Modules/Compiler/Intel-C.cmake | 6 + Modules/Compiler/Intel-CXX-FeatureTests.cmake | 2 +- Modules/Compiler/Intel-CXX.cmake | 10 + Modules/Compiler/Intel-DetermineCompiler.cmake | 14 + Modules/Compiler/MIPSpro-C.cmake | 1 - Modules/Compiler/MIPSpro-CXX.cmake | 1 - Modules/Compiler/MIPSpro-DetermineCompiler.cmake | 15 - Modules/Compiler/MIPSpro-Fortran.cmake | 3 - Modules/Compiler/MSVC-C.cmake | 19 +- Modules/Compiler/MSVC-CXX-FeatureTests.cmake | 6 +- Modules/Compiler/MSVC-CXX.cmake | 23 +- Modules/Compiler/NVIDIA-CUDA.cmake | 5 + Modules/Compiler/PGI-C.cmake | 3 + Modules/Compiler/PGI-CXX.cmake | 4 + Modules/Compiler/SunPro-C.cmake | 3 + Modules/Compiler/SunPro-CXX-FeatureTests.cmake | 8 + Modules/Compiler/SunPro-CXX.cmake | 6 + Modules/Compiler/XL-C-DetermineCompiler.cmake | 2 +- Modules/Compiler/XL-C.cmake | 40 +- Modules/Compiler/XL-CXX-DetermineCompiler.cmake | 2 +- Modules/Compiler/XL-CXX.cmake | 46 +- Modules/Compiler/XL.cmake | 22 - Modules/Compiler/XLClang-C-DetermineCompiler.cmake | 8 + Modules/Compiler/XLClang-C.cmake | 20 + .../Compiler/XLClang-CXX-DetermineCompiler.cmake | 8 + Modules/Compiler/XLClang-CXX.cmake | 27 + Modules/Compiler/XLClang.cmake | 22 + Modules/ExternalProject.cmake | 175 ++- Modules/FindALSA.cmake | 4 +- Modules/FindAVIFile.cmake | 2 +- Modules/FindArmadillo.cmake | 5 +- Modules/FindBISON.cmake | 6 +- Modules/FindBLAS.cmake | 58 +- Modules/FindBZip2.cmake | 64 +- Modules/FindBacktrace.cmake | 18 +- Modules/FindBoost.cmake | 779 ++++++----- Modules/FindBullet.cmake | 12 +- Modules/FindCUDA.cmake | 2 +- Modules/FindCURL.cmake | 8 +- Modules/FindCVS.cmake | 2 +- Modules/FindCups.cmake | 48 +- Modules/FindCurses.cmake | 2 +- Modules/FindCxxTest.cmake | 68 +- Modules/FindCygwin.cmake | 3 +- Modules/FindDCMTK.cmake | 2 +- Modules/FindDoxygen.cmake | 2 +- Modules/FindEXPAT.cmake | 1 + Modules/FindEnvModules.cmake | 333 +++++ Modules/FindFLEX.cmake | 18 +- Modules/FindFLTK.cmake | 6 +- Modules/FindFLTK2.cmake | 3 +- Modules/FindGDAL.cmake | 2 +- Modules/FindGIF.cmake | 4 +- Modules/FindGLEW.cmake | 307 ++++- Modules/FindGLU.cmake | 1 - Modules/FindGLUT.cmake | 2 +- Modules/FindGSL.cmake | 2 +- Modules/FindGTK.cmake | 5 +- Modules/FindGTK2.cmake | 11 +- Modules/FindGettext.cmake | 244 ++-- Modules/FindGnuTLS.cmake | 40 +- Modules/FindHDF5.cmake | 45 +- Modules/FindHSPELL.cmake | 2 +- Modules/FindICU.cmake | 12 +- Modules/FindIce.cmake | 4 +- Modules/FindIcotool.cmake | 4 +- Modules/FindImageMagick.cmake | 14 +- Modules/FindJPEG.cmake | 2 +- Modules/FindJasper.cmake | 2 +- Modules/FindKDE3.cmake | 213 ++- Modules/FindKDE4.cmake | 60 +- Modules/FindLAPACK.cmake | 116 +- Modules/FindLATEX.cmake | 6 +- Modules/FindLTTngUST.cmake | 3 +- Modules/FindLibArchive.cmake | 3 +- Modules/FindLibLZMA.cmake | 14 +- Modules/FindLibXml2.cmake | 6 +- Modules/FindLibXslt.cmake | 3 +- Modules/FindLua.cmake | 219 ++-- Modules/FindLua50.cmake | 13 +- Modules/FindLua51.cmake | 10 +- Modules/FindMFC.cmake | 2 +- Modules/FindMPI.cmake | 75 +- Modules/FindMPI/libver_mpi.c | 1 + Modules/FindMPI/test_mpi.c | 1 + Modules/FindOpenAL.cmake | 20 +- Modules/FindOpenCL.cmake | 2 +- Modules/FindOpenGL.cmake | 6 +- Modules/FindOpenMP.cmake | 7 +- Modules/FindOpenSceneGraph.cmake | 24 +- Modules/FindPNG.cmake | 5 +- Modules/FindPhysFS.cmake | 6 - Modules/FindPkgConfig.cmake | 243 ++-- Modules/FindPostgreSQL.cmake | 68 +- Modules/FindProducer.cmake | 12 +- Modules/FindProtobuf.cmake | 7 +- Modules/FindPython.cmake | 54 +- Modules/FindPython/Support.cmake | 1350 ++++++++++++++------ Modules/FindPython2.cmake | 56 +- Modules/FindPython3.cmake | 58 +- Modules/FindRuby.cmake | 313 ++--- Modules/FindSDL.cmake | 3 - Modules/FindSDL_sound.cmake | 411 +++--- Modules/FindSWIG.cmake | 12 +- Modules/FindTIFF.cmake | 2 +- Modules/FindTclsh.cmake | 10 +- Modules/FindThreads.cmake | 44 +- Modules/FindUnixCommands.cmake | 5 +- Modules/FindVulkan.cmake | 5 +- Modules/FindZLIB.cmake | 4 +- Modules/Findosg.cmake | 2 - Modules/FindosgDB.cmake | 32 +- Modules/Findosg_functions.cmake | 98 +- Modules/FortranCInterface/CMakeLists.txt | 5 +- Modules/GenerateExportHeader.cmake | 2 +- Modules/GetPrerequisites.cmake | 16 +- Modules/Internal/CPack/CPackNuGet.cmake | 2 +- Modules/Internal/CPack/CPackRPM.cmake | 13 +- Modules/Internal/FeatureTesting.cmake | 29 +- Modules/KDE3Macros.cmake | 453 +++---- Modules/MacroAddFileDependencies.cmake | 16 +- Modules/Platform/AIX-XL.cmake | 22 + Modules/Platform/AIX-XLClang-C.cmake | 2 + Modules/Platform/AIX-XLClang-CXX.cmake | 2 + Modules/Platform/AIX-XLClang.cmake | 15 + Modules/Platform/Android.cmake | 8 +- Modules/Platform/CrayLinuxEnvironment.cmake | 72 +- Modules/Platform/Darwin.cmake | 17 +- Modules/Platform/GHS-MULTI-Determine.cmake | 56 + Modules/Platform/GHS-MULTI-Initialize.cmake | 51 - Modules/Platform/SunOS.cmake | 12 +- Modules/Platform/Windows-Clang.cmake | 117 +- Modules/Platform/Windows-Intel-Fortran.cmake | 37 +- Modules/Platform/Windows-MSVC.cmake | 67 +- Modules/Platform/Windows-NVIDIA-CUDA.cmake | 34 +- Modules/ProcessorCount.cmake | 14 + Modules/Qt4Macros.cmake | 108 +- Modules/UseEcos.cmake | 212 +-- Modules/UseJava.cmake | 526 ++++---- Modules/UseQt4.cmake | 5 +- Modules/UseSWIG.cmake | 13 +- Modules/WriteCompilerDetectionHeader.cmake | 2 +- Modules/ecos_clean.cmake | 12 +- 218 files changed, 6146 insertions(+), 3979 deletions(-) create mode 100644 Modules/Compiler/ARMClang-ASM.cmake create mode 100644 Modules/Compiler/ARMClang-C-FeatureTests.cmake create mode 100644 Modules/Compiler/ARMClang-C.cmake create mode 100644 Modules/Compiler/ARMClang-CXX-FeatureTests.cmake create mode 100644 Modules/Compiler/ARMClang-CXX.cmake create mode 100644 Modules/Compiler/ARMClang-DetermineCompiler.cmake create mode 100644 Modules/Compiler/ARMClang.cmake delete mode 100644 Modules/Compiler/MIPSpro-C.cmake delete mode 100644 Modules/Compiler/MIPSpro-CXX.cmake delete mode 100644 Modules/Compiler/MIPSpro-DetermineCompiler.cmake delete mode 100644 Modules/Compiler/MIPSpro-Fortran.cmake create mode 100644 Modules/Compiler/XLClang-C-DetermineCompiler.cmake create mode 100644 Modules/Compiler/XLClang-C.cmake create mode 100644 Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake create mode 100644 Modules/Compiler/XLClang-CXX.cmake create mode 100644 Modules/Compiler/XLClang.cmake create mode 100644 Modules/FindEnvModules.cmake create mode 100644 Modules/Platform/AIX-XLClang-C.cmake create mode 100644 Modules/Platform/AIX-XLClang-CXX.cmake create mode 100644 Modules/Platform/AIX-XLClang.cmake create mode 100644 Modules/Platform/GHS-MULTI-Determine.cmake delete mode 100644 Modules/Platform/GHS-MULTI-Initialize.cmake (limited to 'Modules') diff --git a/Modules/AddFileDependencies.cmake b/Modules/AddFileDependencies.cmake index 4a4e645cd..598a52fa9 100644 --- a/Modules/AddFileDependencies.cmake +++ b/Modules/AddFileDependencies.cmake @@ -16,13 +16,13 @@ Adds the given ```` to the dependencies of file ````. macro(ADD_FILE_DEPENDENCIES _file) - get_source_file_property(_deps ${_file} OBJECT_DEPENDS) - if (_deps) - set(_deps ${_deps} ${ARGN}) - else () - set(_deps ${ARGN}) - endif () - - set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}") + get_source_file_property(_deps ${_file} OBJECT_DEPENDS) + if (_deps) + set(_deps ${_deps} ${ARGN}) + else () + set(_deps ${ARGN}) + endif () + + set_source_files_properties(${_file} PROPERTIES OBJECT_DEPENDS "${_deps}") endmacro() diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index afffc047f..a6e5fda38 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -26,12 +26,12 @@ endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() + return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@") - math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") - set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") - set(PACKAGE_VERSION_UNSUITABLE TRUE) + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) endif() diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index fe5c2e5a8..43fc4d0b1 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -41,7 +41,7 @@ endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() + return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index d885c0f93..8c3b6a212 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -40,7 +40,7 @@ endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() + return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in index bf055e8d4..e2030d230 100644 --- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in @@ -44,7 +44,7 @@ endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") - return() + return() endif() # check that the installed version has the same 32/64bit-ness as the one which is currently searching: diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 8c7646e4d..f94fc5cff 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( ) -Fix up a bundle in-place and make it standalone, such that it can be +Fix up ```` 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 ```` 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( ) -Makes a copy of the bundle at location and then fixes up -the new copied bundle in-place at ... +Makes a copy of the bundle ```` at location ```` and then fixes up +the new copied bundle in-place at ````. .. code-block:: cmake verify_app() -Verifies that an application appears valid based on running -analysis tools on it. Calls "message(FATAL_ERROR" if the application +Verifies that an application ```` 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( ) 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( ) -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( ) -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 and the path to its main executable in - +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 ```` and the path to its main executable in +````. .. code-block:: cmake get_bundle_all_executables( ) -Scans the given bundle recursively for all executable files and -accumulates them into a variable. +Scans ```` bundle recursively for all ```` executable +files and accumulates them into a variable. .. code-block:: cmake get_item_key( ) -Given a file (item) name, generate a key that should be unique +Given ```` file name, generate ```` 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() -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 ```` 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( []) -Add a key to the list (if necessary) for the given item. If added, -also set all the variables associated with that key. +Add ```` 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( ) -Loop over all the executable and library files within the bundle (and -given as extra ) and accumulate a list of keys representing +Loop over all the executable and library files within ```` bundle (and +given as extra ````) 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( ) -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 ```` is "the same as" the +````. .. code-block:: cmake copy_resolved_framework_into_bundle( ) -Copy a resolved framework into the bundle if necessary. Copy is not -necessary if the resolved_item is "the same as" the -resolved_embedded_item. +Copy a resolved framework into the bundle if necessary. +Copy is not necessary, if the ```` is "the same as" the +````. -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( ) -Get the direct/non-system prerequisites of the resolved embedded item. +Get the direct/non-system prerequisites of the ````. 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 ```` 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( ) 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( ) -Verifies that any symlinks found in the bundle point to other files +Verifies that any symlinks found in the ```` 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 1e3c60845..cb793e7c2 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 " -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o ") +if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) + set(CMAKE_ASM_NASM_COMPILE_OBJECT " -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o ") +endif() # Load the generic ASMInformation file: set(ASM_DIALECT "_NASM") diff --git a/Modules/CMakeAddFortranSubdirectory.cmake b/Modules/CMakeAddFortranSubdirectory.cmake index 50b280721..2613569d1 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 612e1a3a5..b0be590ae 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, @@ -17,17 +17,15 @@ changes in release notes. CMakeDetermine(LANG)Compiler.cmake -> this should find the compiler for LANG and configure CMake(LANG)Compiler.cmake.in CMake(LANG)Compiler.cmake.in -> used by CMakeDetermine(LANG)Compiler.cmake - This file is used to store compiler information and is copied down into try - compile directories so that try compiles do not need to re-determine and test the LANG + This file is used to store compiler information and is copied down into try + compile directories so that try compiles do not need to re-determine and test the LANG CMakeTest(LANG)Compiler.cmake -> test the compiler and set: - SET(CMAKE_(LANG)_COMPILER_WORKS 1 CACHE INTERNAL "") + SET(CMAKE_(LANG)_COMPILER_WORKS 1 CACHE INTERNAL "") CMake(LANG)Information.cmake -> set up rule variables for LANG : - CMAKE_(LANG)_CREATE_SHARED_LIBRARY - CMAKE_(LANG)_CREATE_SHARED_MODULE - CMAKE_(LANG)_CREATE_STATIC_LIBRARY - CMAKE_(LANG)_COMPILE_OBJECT - CMAKE_(LANG)_LINK_EXECUTABLE - - + CMAKE_(LANG)_CREATE_SHARED_LIBRARY + CMAKE_(LANG)_CREATE_SHARED_MODULE + CMAKE_(LANG)_CREATE_STATIC_LIBRARY + CMAKE_(LANG)_COMPILE_OBJECT + CMAKE_(LANG)_LINK_EXECUTABLE diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index f473b0d1c..9b8d423a6 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -12,6 +12,7 @@ set(CMAKE_C11_COMPILE_FEATURES "@CMAKE_C11_COMPILE_FEATURES@") set(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@") +set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@") set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@") @_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@ @SET_MSVC_C_ARCHITECTURE_ID@ diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index a1be02b5c..e7f0e7074 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -14,6 +14,7 @@ set(CMAKE_CXX20_COMPILE_FEATURES "@CMAKE_CXX20_COMPILE_FEATURES@") set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@") +set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@") set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@") @_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@ @SET_MSVC_CXX_ARCHITECTURE_ID@ diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index e60ffe019..e1ce617dc 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -7,28 +7,29 @@ # any way between releases. macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) - set(${_VAR} - FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG - FAIL_REGEX "unknown .*option" # Clang - FAIL_REGEX "optimization flag .* not supported" # Clang - FAIL_REGEX "unknown argument ignored" # Clang (cl) - FAIL_REGEX "ignoring unknown option" # MSVC, Intel - FAIL_REGEX "warning D9002" # MSVC, any lang - FAIL_REGEX "option.*not supported" # Intel - FAIL_REGEX "invalid argument .*option" # Intel - FAIL_REGEX "ignoring option .*argument required" # Intel - FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel - FAIL_REGEX "[Uu]nknown option" # HP - FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro - FAIL_REGEX "command option .* is not recognized" # XL - FAIL_REGEX "command option .* contains an incorrect subargument" # XL - FAIL_REGEX "Option .* is not recognized. Option will be ignored." # XL - FAIL_REGEX "not supported in this configuration. ignored" # AIX - FAIL_REGEX "File with unknown suffix passed to linker" # PGI - FAIL_REGEX "[Uu]nknown switch" # PGI - FAIL_REGEX "WARNING: unknown flag:" # Open64 - FAIL_REGEX "Incorrect command line option:" # Borland - FAIL_REGEX "Warning: illegal option" # SunStudio 12 - FAIL_REGEX "[Ww]arning: Invalid suboption" # Fujitsu - ) + set(${_VAR} + FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG + FAIL_REGEX "unknown .*option" # Clang + FAIL_REGEX "optimization flag .* not supported" # Clang + FAIL_REGEX "unknown argument ignored" # Clang (cl) + FAIL_REGEX "ignoring unknown option" # MSVC, Intel + FAIL_REGEX "warning D9002" # MSVC, any lang + FAIL_REGEX "option.*not supported" # Intel + FAIL_REGEX "invalid argument .*option" # Intel + FAIL_REGEX "ignoring option .*argument required" # Intel + FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel + FAIL_REGEX "[Uu]nknown option" # HP + FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro + FAIL_REGEX "command option .* is not recognized" # XL + FAIL_REGEX "command option .* contains an incorrect subargument" # XL + FAIL_REGEX "Option .* is not recognized. Option will be ignored." # XL + FAIL_REGEX "not supported in this configuration. ignored" # AIX + FAIL_REGEX "File with unknown suffix passed to linker" # PGI + FAIL_REGEX "[Uu]nknown switch" # PGI + FAIL_REGEX "WARNING: unknown flag:" # Open64 + 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 6a22d2768..bb573b7dc 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 @@ -75,6 +76,7 @@ function(compiler_id_detection outvar lang) SCO ARMCC AppleClang + ARMClang Clang GNU MSVC @@ -86,8 +88,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 +98,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 b8c8c5d35..e47f3a441 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -66,6 +66,10 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_AppleClang "--version") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_AppleClang "(Apple LLVM version)") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS ARMClang ) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMClang "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMClang "armclang") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS HP ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_HP "-V") set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_HP "HP C") @@ -119,35 +123,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 AND "x${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}" STREQUAL "xIAR") + 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/CMakeDetermineASM_MASMCompiler.cmake b/Modules/CMakeDetermineASM_MASMCompiler.cmake index 789b0494c..80188fb25 100644 --- a/Modules/CMakeDetermineASM_MASMCompiler.cmake +++ b/Modules/CMakeDetermineASM_MASMCompiler.cmake @@ -8,10 +8,10 @@ set(ASM_DIALECT "_MASM") # if we are using the 64bit cl compiler, assume we also want the 64bit assembler if(";${CMAKE_VS_PLATFORM_NAME};${MSVC_C_ARCHITECTURE_ID};${MSVC_CXX_ARCHITECTURE_ID};" - MATCHES ";(Win64|Itanium|x64|IA64);") - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml64) + MATCHES ";(Win64|Itanium|x64|IA64);") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml64) else() - set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT ml) endif() include(CMakeDetermineASMCompiler) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index d7f6f97d0..8be781a08 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -82,6 +82,9 @@ else() # Try compiling K&R-compatible code (needed by Bruce C Compiler). "-D__CLASSIC_C__" + + # ARMClang need target options + "--target=arm-arm-none-eabi -mcpu=cortex-m3" ) endif() @@ -111,7 +114,6 @@ if(NOT CMAKE_C_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c) - CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(C CC) # Set old compiler and platform id variables. if(CMAKE_C_COMPILER_ID STREQUAL "GNU") @@ -139,8 +141,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/CMakeDetermineCSharpCompiler.cmake b/Modules/CMakeDetermineCSharpCompiler.cmake index 5802b1511..dab941431 100644 --- a/Modules/CMakeDetermineCSharpCompiler.cmake +++ b/Modules/CMakeDetermineCSharpCompiler.cmake @@ -2,7 +2,7 @@ # file Copyright.txt or https://cmake.org/licensing for details. if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio ([^9]|[9][0-9])") - message(FATAL_ERROR + message(FATAL_ERROR "C# is currently only supported for Microsoft Visual Studio 2010 and later.") endif() diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index bd878b292..00ef5b9f8 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -77,6 +77,9 @@ else() # IAR does not detect language automatically "--c++" "--ec++" + + # ARMClang need target options + "--target=arm-arm-none-eabi -mcpu=cortex-m3" ) endif() @@ -106,7 +109,6 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN) include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) - CMAKE_DIAGNOSE_UNSUPPORTED_CLANG(CXX CXX) # Set old compiler and platform id variables. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") @@ -136,8 +138,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 59dab6de4..6083358b3 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -28,6 +28,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) foreach(testflags ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS_FIRST} "" ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) + separate_arguments(testflags UNIX_COMMAND "${testflags}") CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${testflags}" "${userflags}" "${src}") CMAKE_DETERMINE_COMPILER_ID_MATCH_VENDOR("${lang}" "${COMPILER_${lang}_PRODUCED_OUTPUT}") if(CMAKE_${lang}_COMPILER_ID) @@ -45,6 +46,14 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endforeach() + # Check if compiler id detection gave us the compiler tool. + if(CMAKE_${lang}_COMPILER_ID_TOOL) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}") + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE) + elseif(NOT CMAKE_${lang}_COMPILER) + set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE) + endif() + # If the compiler is still unknown, try to query its vendor. if(CMAKE_${lang}_COMPILER AND NOT CMAKE_${lang}_COMPILER_ID) foreach(userflags "${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}" "") @@ -75,6 +84,30 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endif() + # For Swift we need to explicitly query the version. + if(lang STREQUAL "Swift" + AND CMAKE_${lang}_COMPILER + AND NOT CMAKE_${lang}_COMPILER_VERSION) + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" + -version + OUTPUT_VARIABLE output ERROR_VARIABLE output + RESULT_VARIABLE result + TIMEOUT 10 + ) + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" -version\n" + "${output}\n" + ) + + if(output MATCHES [[Swift version ([0-9]+\.[0-9]+(\.[0-9]+)?)]]) + set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}") + if(NOT CMAKE_${lang}_COMPILER_ID) + set(CMAKE_Swift_COMPILER_ID "Apple") + endif() + endif() + endif() + if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") execute_process( COMMAND "${CMAKE_${lang}_COMPILER}" @@ -103,6 +136,31 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "") endif() + set(_variant "") + if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xClang") + if(CMAKE_HOST_WIN32 AND "x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC") + if(CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC") + else() + # Test whether an MSVC-like command-line option works. + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -? + RESULT_VARIABLE _clang_result + OUTPUT_VARIABLE _clang_stdout + ERROR_VARIABLE _clang_stderr) + if(_clang_result EQUAL 0) + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "MSVC") + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") + endif() + endif() + set(_variant " with ${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}-like command-line") + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") + endif() + else() + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "") + endif() + # Display the final identification result. if(CMAKE_${lang}_COMPILER_ID) if(CMAKE_${lang}_COMPILER_VERSION) @@ -110,19 +168,20 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) else() set(_version "") endif() + if(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID AND "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xIAR") + 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}${_variant}") + unset(_archid) + unset(_version) + unset(_variant) else() message(STATUS "The ${lang} compiler identification is unknown") endif() - # Check if compiler id detection gave us the compiler tool. - if(CMAKE_${lang}_COMPILER_ID_TOOL) - set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_ID_TOOL}" PARENT_SCOPE) - elseif(NOT CMAKE_${lang}_COMPILER) - set(CMAKE_${lang}_COMPILER "CMAKE_${lang}_COMPILER-NOTFOUND" PARENT_SCOPE) - endif() - set(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) set(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID "${CMAKE_${lang}_COMPILER_ARCHITECTURE_ID}" PARENT_SCOPE) @@ -130,6 +189,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) PARENT_SCOPE) set(CMAKE_${lang}_XCODE_ARCHS "${CMAKE_${lang}_XCODE_ARCHS}" PARENT_SCOPE) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "${CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX}" PARENT_SCOPE) + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_${lang}_COMPILER_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_VERSION_INTERNAL "${CMAKE_${lang}_COMPILER_VERSION_INTERNAL}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_WRAPPER "${CMAKE_${lang}_COMPILER_WRAPPER}" PARENT_SCOPE) @@ -182,7 +242,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_platform ${CMAKE_VS_PLATFORM_NAME}) set(id_lang "${lang}") set(id_PostBuildEvent_Command "") - if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm]$") + if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "^[Ll][Ll][Vv][Mm](_v[0-9]+(_xp)?)?$") set(id_cl_var "ClangClExecutable") elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*") set(id_cl clang.exe) @@ -243,8 +303,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} else() set(id_system "") endif() - if(id_system AND CMAKE_SYSTEM_VERSION) - set(id_system_version "${CMAKE_SYSTEM_VERSION}") + if(id_system AND CMAKE_SYSTEM_VERSION MATCHES "^([0-9]+\\.[0-9]+)") + set(id_system_version "${CMAKE_MATCH_1}") else() set(id_system_version "") endif() @@ -431,10 +491,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) @@ -823,38 +891,3 @@ function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags) set(CMAKE_${lang}_CL_SHOWINCLUDES_PREFIX "" PARENT_SCOPE) endif() endfunction() - -function(CMAKE_DIAGNOSE_UNSUPPORTED_CLANG lang envvar) - if(NOT CMAKE_HOST_WIN32 OR CMAKE_GENERATOR MATCHES "Visual Studio" OR - NOT "${CMAKE_${lang}_COMPILER_ID};${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "Clang;MSVC") - return() - endif() - - # Test whether an MSVC-like command-line option works. - execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -? - RESULT_VARIABLE _clang_result - OUTPUT_VARIABLE _clang_stdout - ERROR_VARIABLE _clang_stderr) - if(_clang_result EQUAL 0) - return() - endif() - - # Help the user configure the environment to use the MSVC-like Clang. - string(CONCAT _msg - "The Clang compiler tool\n" - " \"${CMAKE_${lang}_COMPILER}\"\n" - "targets the MSVC ABI but has a GNU-like command-line interface. " - "This is not supported. " - "Use 'clang-cl' instead, e.g. by setting '${envvar}=clang-cl' in the environment." - ) - execute_process(COMMAND rc -help - RESULT_VARIABLE _rc_result - OUTPUT_VARIABLE _rc_stdout - ERROR_VARIABLE _rc_stderr) - if(NOT _rc_result EQUAL 0) - string(APPEND _msg " " - "Furthermore, use the MSVC command-line environment." - ) - endif() - message(FATAL_ERROR "${_msg}") -endfunction() diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index dd02d5447..2fcf7b0be 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -1,15 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) +# Local system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Swift OPTIONAL) +include(Platform/${CMAKE_SYSTEM_NAME}-Swift OPTIONAL) +if(NOT CMAKE_Swift_COMPILER_NAMES) + set(CMAKE_Swift_COMPILER_NAMES swiftc) +endif() + if("${CMAKE_GENERATOR}" STREQUAL "Xcode") if(XCODE_VERSION VERSION_LESS 6.1) message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}") endif() set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift) _cmake_find_compiler_path(Swift) +elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja") + if(CMAKE_Swift_COMPILER) + _cmake_find_compiler_path(Swift) + else() + set(CMAKE_Swift_COMPILER_INIT NOTFOUND) + + if(NOT $ENV{SWIFTC} STREQUAL "") + get_filename_component(CMAKE_Swift_COMPILER_INIT $ENV{SWIFTC} PROGRAM + PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT) + if(CMAKE_Swift_FLAGS_ENV_INIT) + set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE + STRING "First argument to the Swift compiler") + endif() + if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}") + endif() + endif() + + if(NOT CMAKE_Swift_COMPILER_INIT) + set(CMAKE_Swift_COMPILER_LIST swiftc ${_CMAKE_TOOLCHAIN_PREFIX}swiftc) + endif() + + _cmake_find_compiler(Swift) + endif() + mark_as_advanced(CMAKE_Swift_COMPILER) else() message(FATAL_ERROR "Swift language not supported by \"${CMAKE_GENERATOR}\" generator") endif() @@ -18,11 +49,13 @@ endif() if(NOT CMAKE_Swift_COMPILER_ID_RUN) set(CMAKE_Swift_COMPILER_ID_RUN 1) - list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) - set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") + if("${CMAKE_GENERATOR}" STREQUAL "Xcode") + list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) + set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) + endif() # Try to identify the compiler. set(CMAKE_Swift_COMPILER_ID) @@ -40,6 +73,6 @@ unset(_CMAKE_PROCESSING_LANGUAGE) # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake - @ONLY - ) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY) + +set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC") diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index a3c4d9cf1..53868d21a 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -44,32 +44,32 @@ endif() # [INTERNAL] # Please do not call this function directly function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version) - if (${_cl_version} VERSION_EQUAL "14.00.50727.42") - set(_version "vc80") - elseif(${_cl_version} VERSION_EQUAL "14.00.50727.762") - set(_version "vc80sp1") - elseif(${_cl_version} VERSION_EQUAL "15.00.21022.08") - set(_version "vc90") - elseif(${_cl_version} VERSION_EQUAL "15.00.30729.01") - set(_version "vc90sp1") - elseif(${_cl_version} VERSION_EQUAL "16.00.30319.01") - set(_version "vc100") - elseif(${_cl_version} VERSION_EQUAL "16.00.40219.01") - set(_version "vc100sp1") - elseif(${_cl_version} VERSION_EQUAL "17.00.50727.1") - set(_version "vc110") - elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1") - set(_version "vc110sp1") - elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1") - set(_version "vc110sp2") - elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1") - set(_version "vc110sp3") - elseif(${_cl_version} VERSION_EQUAL "17.00.61030") - set(_version "vc110sp4") - else() - set(_version "") - endif() - set(${_OUT_VAR} ${_version} PARENT_SCOPE) + if (${_cl_version} VERSION_EQUAL "14.00.50727.42") + set(_version "vc80") + elseif(${_cl_version} VERSION_EQUAL "14.00.50727.762") + set(_version "vc80sp1") + elseif(${_cl_version} VERSION_EQUAL "15.00.21022.08") + set(_version "vc90") + elseif(${_cl_version} VERSION_EQUAL "15.00.30729.01") + set(_version "vc90sp1") + elseif(${_cl_version} VERSION_EQUAL "16.00.30319.01") + set(_version "vc100") + elseif(${_cl_version} VERSION_EQUAL "16.00.40219.01") + set(_version "vc100sp1") + elseif(${_cl_version} VERSION_EQUAL "17.00.50727.1") + set(_version "vc110") + elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1") + set(_version "vc110sp1") + elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1") + set(_version "vc110sp2") + elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1") + set(_version "vc110sp3") + elseif(${_cl_version} VERSION_EQUAL "17.00.61030") + set(_version "vc110sp4") + else() + set(_version "") + endif() + set(${_OUT_VAR} ${_version} PARENT_SCOPE) endfunction() diff --git a/Modules/CMakeExpandImportedTargets.cmake b/Modules/CMakeExpandImportedTargets.cmake index ae26cc26e..b8f471c10 100644 --- a/Modules/CMakeExpandImportedTargets.cmake +++ b/Modules/CMakeExpandImportedTargets.cmake @@ -42,108 +42,107 @@ ${CMAKE_CONFIGURATION_TYPES} if set, otherwise ${CMAKE_BUILD_TYPE}. function(CMAKE_EXPAND_IMPORTED_TARGETS _RESULT ) - set(options ) - set(oneValueArgs CONFIGURATION ) - set(multiValueArgs LIBRARIES ) - - cmake_parse_arguments(CEIT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - if(CEIT_UNPARSED_ARGUMENTS) - message(FATAL_ERROR "Unknown keywords given to CMAKE_EXPAND_IMPORTED_TARGETS(): \"${CEIT_UNPARSED_ARGUMENTS}\"") - endif() - - if(NOT CEIT_CONFIGURATION) - # Would be better to test GENERATOR_IS_MULTI_CONFIG global property, - # but the documented behavior specifically says we check - # CMAKE_CONFIGURATION_TYPES and fall back to CMAKE_BUILD_TYPE if no - # config types are defined. - if(CMAKE_CONFIGURATION_TYPES) - list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION) - else() - set(CEIT_CONFIGURATION ${CMAKE_BUILD_TYPE}) - endif() - endif() - - # handle imported library targets - - set(_CCSR_REQ_LIBS ${CEIT_LIBRARIES}) - - set(_CHECK_FOR_IMPORTED_TARGETS TRUE) - set(_CCSR_LOOP_COUNTER 0) - while(_CHECK_FOR_IMPORTED_TARGETS) - math(EXPR _CCSR_LOOP_COUNTER "${_CCSR_LOOP_COUNTER} + 1 ") - set(_CCSR_NEW_REQ_LIBS ) - set(_CHECK_FOR_IMPORTED_TARGETS FALSE) - foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) - if(TARGET "${_CURRENT_LIB}") - get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) - else() - set(_importedConfigs "") - endif() - if (_importedConfigs) -# message(STATUS "Detected imported target ${_CURRENT_LIB}") - # Ok, so this is an imported target. - # First we get the imported configurations. - # Then we get the location of the actual library on disk of the first configuration. - # then we'll get its link interface libraries property, - # iterate through it and replace all imported targets we find there - # with there actual location. - - # guard against infinite loop: abort after 100 iterations ( 100 is arbitrary chosen) - if ("${_CCSR_LOOP_COUNTER}" LESS 100) - set(_CHECK_FOR_IMPORTED_TARGETS TRUE) -# else () -# message(STATUS "********* aborting loop, counter : ${_CCSR_LOOP_COUNTER}") - endif () - - # if one of the imported configurations equals ${CMAKE_TRY_COMPILE_CONFIGURATION}, - # use it, otherwise simply use the first one: - list(FIND _importedConfigs "${CEIT_CONFIGURATION}" _configIndexToUse) - if("${_configIndexToUse}" EQUAL -1) - set(_configIndexToUse 0) - endif() - list(GET _importedConfigs ${_configIndexToUse} _importedConfigToUse) - - get_target_property(_importedLocation "${_CURRENT_LIB}" IMPORTED_LOCATION_${_importedConfigToUse}) - get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}" IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} ) - - list(APPEND _CCSR_NEW_REQ_LIBS "${_importedLocation}") -# message(STATUS "Appending lib ${_CURRENT_LIB} as ${_importedLocation}") - if(_linkInterfaceLibs) - foreach(_currentLinkInterfaceLib ${_linkInterfaceLibs}) -# message(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}") - if(_currentLinkInterfaceLib) - list(APPEND _CCSR_NEW_REQ_LIBS "${_currentLinkInterfaceLib}" ) - endif() - endforeach() - endif() - else() - # "Normal" libraries are just used as they are. - list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" ) -# message(STATUS "Appending lib directly: ${_CURRENT_LIB}") - endif() - endforeach() - - set(_CCSR_REQ_LIBS ${_CCSR_NEW_REQ_LIBS} ) - endwhile() - - # Finally we iterate once more over all libraries. This loop only removes - # all remaining imported target names (there shouldn't be any left anyway). - set(_CCSR_NEW_REQ_LIBS ) - foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) + set(options ) + set(oneValueArgs CONFIGURATION ) + set(multiValueArgs LIBRARIES ) + + cmake_parse_arguments(CEIT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CEIT_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to CMAKE_EXPAND_IMPORTED_TARGETS(): \"${CEIT_UNPARSED_ARGUMENTS}\"") + endif() + + if(NOT CEIT_CONFIGURATION) + # Would be better to test GENERATOR_IS_MULTI_CONFIG global property, + # but the documented behavior specifically says we check + # CMAKE_CONFIGURATION_TYPES and fall back to CMAKE_BUILD_TYPE if no + # config types are defined. + if(CMAKE_CONFIGURATION_TYPES) + list(GET CMAKE_CONFIGURATION_TYPES 0 CEIT_CONFIGURATION) + else() + set(CEIT_CONFIGURATION ${CMAKE_BUILD_TYPE}) + endif() + endif() + + # handle imported library targets + + set(_CCSR_REQ_LIBS ${CEIT_LIBRARIES}) + + set(_CHECK_FOR_IMPORTED_TARGETS TRUE) + set(_CCSR_LOOP_COUNTER 0) + while(_CHECK_FOR_IMPORTED_TARGETS) + math(EXPR _CCSR_LOOP_COUNTER "${_CCSR_LOOP_COUNTER} + 1 ") + set(_CCSR_NEW_REQ_LIBS ) + set(_CHECK_FOR_IMPORTED_TARGETS FALSE) + foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) if(TARGET "${_CURRENT_LIB}") get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) else() set(_importedConfigs "") endif() - if (NOT _importedConfigs) - list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" ) -# message(STATUS "final: appending ${_CURRENT_LIB}") - else () -# message(STATUS "final: skipping ${_CURRENT_LIB}") - endif () - endforeach() -# message(STATUS "setting -${_RESULT}- to -${_CCSR_NEW_REQ_LIBS}-") - set(${_RESULT} "${_CCSR_NEW_REQ_LIBS}" PARENT_SCOPE) + if (_importedConfigs) + # message(STATUS "Detected imported target ${_CURRENT_LIB}") + # Ok, so this is an imported target. + # First we get the imported configurations. + # Then we get the location of the actual library on disk of the first configuration. + # then we'll get its link interface libraries property, + # iterate through it and replace all imported targets we find there + # with there actual location. + + # guard against infinite loop: abort after 100 iterations ( 100 is arbitrary chosen) + if ("${_CCSR_LOOP_COUNTER}" LESS 100) + set(_CHECK_FOR_IMPORTED_TARGETS TRUE) +# else () +# message(STATUS "********* aborting loop, counter : ${_CCSR_LOOP_COUNTER}") + endif () + + # if one of the imported configurations equals ${CMAKE_TRY_COMPILE_CONFIGURATION}, + # use it, otherwise simply use the first one: + list(FIND _importedConfigs "${CEIT_CONFIGURATION}" _configIndexToUse) + if("${_configIndexToUse}" EQUAL -1) + set(_configIndexToUse 0) + endif() + list(GET _importedConfigs ${_configIndexToUse} _importedConfigToUse) + + get_target_property(_importedLocation "${_CURRENT_LIB}" IMPORTED_LOCATION_${_importedConfigToUse}) + get_target_property(_linkInterfaceLibs "${_CURRENT_LIB}" IMPORTED_LINK_INTERFACE_LIBRARIES_${_importedConfigToUse} ) + + list(APPEND _CCSR_NEW_REQ_LIBS "${_importedLocation}") +# message(STATUS "Appending lib ${_CURRENT_LIB} as ${_importedLocation}") + if(_linkInterfaceLibs) + foreach(_currentLinkInterfaceLib ${_linkInterfaceLibs}) +# message(STATUS "Appending link interface lib ${_currentLinkInterfaceLib}") + if(_currentLinkInterfaceLib) + list(APPEND _CCSR_NEW_REQ_LIBS "${_currentLinkInterfaceLib}" ) + endif() + endforeach() + endif() + else() + # "Normal" libraries are just used as they are. + list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" ) +# message(STATUS "Appending lib directly: ${_CURRENT_LIB}") + endif() + endforeach() + set(_CCSR_REQ_LIBS ${_CCSR_NEW_REQ_LIBS} ) + endwhile() + + # Finally we iterate once more over all libraries. This loop only removes + # all remaining imported target names (there shouldn't be any left anyway). + set(_CCSR_NEW_REQ_LIBS ) + foreach(_CURRENT_LIB ${_CCSR_REQ_LIBS}) + if(TARGET "${_CURRENT_LIB}") + get_target_property(_importedConfigs "${_CURRENT_LIB}" IMPORTED_CONFIGURATIONS) + else() + set(_importedConfigs "") + endif() + if (NOT _importedConfigs) + list(APPEND _CCSR_NEW_REQ_LIBS "${_CURRENT_LIB}" ) +# message(STATUS "final: appending ${_CURRENT_LIB}") +# else () +# message(STATUS "final: skipping ${_CURRENT_LIB}") + endif () + endforeach() +# message(STATUS "setting -${_RESULT}- to -${_CCSR_NEW_REQ_LIBS}-") + set(${_RESULT} "${_CCSR_NEW_REQ_LIBS}" PARENT_SCOPE) endfunction() diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 35f75c938..0e8411640 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -60,7 +60,9 @@ __resolve_tool_path(CMAKE_MT "${_CMAKE_TOOLCHAIN_LOCATION}" "Default Manifes set(_CMAKE_TOOL_VARS "") # if it's the MS C/CXX compiler, search for link -if("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" +if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND + ("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" + OR NOT "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xClang")) OR "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xMSVC" OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xPGI") OR (CMAKE_HOST_WIN32 AND "x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL "xNVIDIA") @@ -80,17 +82,26 @@ else() if(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) set(_CMAKE_TOOLCHAIN_LOCATION ${_CMAKE_TOOLCHAIN_LOCATION} ${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}/bin) endif() - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ID}" STREQUAL Clang) + set(LLVM_OBJDUMP "llvm-objdump") + set(LLVM_LLD "ld.lld") + set(LLVM_RANLIB "llvm-ranlib") + set(LLVM_AR "llvm-ar") + endif() + + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} ${LLVM_AR} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + + find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${LLVM_RANLIB} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") endif() + find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld ${LLVM_LLD} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump ${LLVM_OBJDUMP} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake index 13bceb1a8..bf27ec111 100644 --- a/Modules/CMakeFindCodeBlocks.cmake +++ b/Modules/CMakeFindCodeBlocks.cmake @@ -8,7 +8,7 @@ find_program(CMAKE_CODEBLOCKS_EXECUTABLE NAMES codeblocks DOC "The CodeBlocks executable") if(CMAKE_CODEBLOCKS_EXECUTABLE) - set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_CODEBLOCKS_EXECUTABLE} " ) + set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_CODEBLOCKS_EXECUTABLE} " ) endif() # Determine builtin macros and include dirs: diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index de1a3329a..bcdfbebe3 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/CMakeFindSublimeText2.cmake b/Modules/CMakeFindSublimeText2.cmake index 022d0109e..7f67bf03d 100644 --- a/Modules/CMakeFindSublimeText2.cmake +++ b/Modules/CMakeFindSublimeText2.cmake @@ -19,5 +19,5 @@ find_program(CMAKE_SUBLIMETEXT_EXECUTABLE DOC "The Sublime Text executable") if(CMAKE_SUBLIMETEXT_EXECUTABLE) - set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_SUBLIMETEXT_EXECUTABLE} --project " ) + set(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_SUBLIMETEXT_EXECUTABLE} --project " ) endif() diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index 7ac09dcaa..704880631 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( ) -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 _COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_C_COMPILER_ID _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( ) -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 _COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_CXX_COMPILER_ID _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( ) -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 _COMPILER>` to +the given compiler and the cmake internal variable +:variable:`CMAKE_Fortran_COMPILER_ID _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 59956944b..30f8d4c45 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/CMakeJavaInformation.cmake b/Modules/CMakeJavaInformation.cmake index 11568a810..989afc11b 100644 --- a/Modules/CMakeJavaInformation.cmake +++ b/Modules/CMakeJavaInformation.cmake @@ -16,8 +16,8 @@ endif() if(CMAKE_USER_MAKE_RULES_OVERRIDE_Java) # Save the full path of the file so try_compile can use it. - include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Java} RESULT_VARIABLE _override) - set(CMAKE_USER_MAKE_RULES_OVERRIDE_Java "${_override}") + include(${CMAKE_USER_MAKE_RULES_OVERRIDE_Java} RESULT_VARIABLE _override) + set(CMAKE_USER_MAKE_RULES_OVERRIDE_Java "${_override}") endif() # this is a place holder if java needed flags for javac they would go here. diff --git a/Modules/CMakeNinjaFindMake.cmake b/Modules/CMakeNinjaFindMake.cmake index 6a0c47eec..702af1338 100644 --- a/Modules/CMakeNinjaFindMake.cmake +++ b/Modules/CMakeNinjaFindMake.cmake @@ -3,6 +3,6 @@ find_program(CMAKE_MAKE_PROGRAM - NAMES ninja-build ninja + NAMES ninja-build ninja samu DOC "Program used to build from build.ninja files.") mark_as_advanced(CMAKE_MAKE_PROGRAM) diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake index f044b106a..91d03cdc9 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 3cb7f2474..542a6fe3c 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -156,9 +156,24 @@ # if defined(__ICCARM__) # define ARCHITECTURE_ID "ARM" +# elif defined(__ICCRX__) +# define ARCHITECTURE_ID "RX" + +# elif defined(__ICCRH850__) +# define ARCHITECTURE_ID "RH850" + +# elif defined(__ICCRL78__) +# define ARCHITECTURE_ID "RL78" + +# elif defined(__ICCRISCV__) +# define ARCHITECTURE_ID "RISCV" + # elif defined(__ICCAVR__) # define ARCHITECTURE_ID "AVR" +# elif defined(__ICC430__) +# define ARCHITECTURE_ID "MSP430" + # else /* unknown architecture */ # define ARCHITECTURE_ID "" # endif diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake index 1af0bb730..aa40b59ca 100644 --- a/Modules/CMakePrintHelpers.cmake +++ b/Modules/CMakePrintHelpers.cmake @@ -42,14 +42,14 @@ Gives:: #]=======================================================================] function(cmake_print_variables) - set(msg "") - foreach(var ${ARGN}) - if(msg) - string(APPEND msg " ; ") - endif() - string(APPEND msg "${var}=\"${${var}}\"") - endforeach() - message(STATUS "${msg}") + set(msg "") + foreach(var ${ARGN}) + if(msg) + string(APPEND msg " ; ") + endif() + string(APPEND msg "${var}=\"${${var}}\"") + endforeach() + message(STATUS "${msg}") endfunction() diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake index f6bfc120e..3e519ee51 100644 --- a/Modules/CMakePushCheckState.cmake +++ b/Modules/CMakePushCheckState.cmake @@ -40,52 +40,52 @@ Usage: macro(CMAKE_RESET_CHECK_STATE) - set(CMAKE_EXTRA_INCLUDE_FILES) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_DEFINITIONS) - set(CMAKE_REQUIRED_LINK_OPTIONS) - set(CMAKE_REQUIRED_LIBRARIES) - set(CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_QUIET) + set(CMAKE_EXTRA_INCLUDE_FILES) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_DEFINITIONS) + set(CMAKE_REQUIRED_LINK_OPTIONS) + set(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_QUIET) endmacro() macro(CMAKE_PUSH_CHECK_STATE) - if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) - set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) - endif() + if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) + set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) + endif() - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") - set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) - set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) - set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) - set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS}) - set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) - set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) - set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) + set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) + set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) + set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) + set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS}) + set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) + set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) + set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) - if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") - cmake_reset_check_state() - endif() + if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") + cmake_reset_check_state() + endif() endmacro() macro(CMAKE_POP_CHECK_STATE) # don't pop more than we pushed - if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") - - set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) - - math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") - endif() + if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") + + set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") + endif() endmacro() diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index 1227fdf26..7bf656775 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 - " /fo ") + " /fo ") endif() # set this variable so we can avoid loading this more than once. diff --git a/Modules/CMakeSwiftCompiler.cmake.in b/Modules/CMakeSwiftCompiler.cmake.in index 45f0a3105..7c8d1c19a 100644 --- a/Modules/CMakeSwiftCompiler.cmake.in +++ b/Modules/CMakeSwiftCompiler.cmake.in @@ -1,5 +1,14 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + set(CMAKE_Swift_COMPILER "@CMAKE_Swift_COMPILER@") set(CMAKE_Swift_COMPILER_ID "@CMAKE_Swift_COMPILER_ID@") +set(CMAKE_Swift_COMPILER_VERSION "@CMAKE_Swift_COMPILER_VERSION@") + +set(CMAKE_Swift_COMPILER_LOADED 1) +set(CMAKE_Swift_COMPILER_WORKS "@CMAKE_Swift_COMPILER_WORKS@") + +set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC") set(CMAKE_Swift_COMPILER_ID_RUN 1) set(CMAKE_Swift_SOURCE_FILE_EXTENSIONS swift) diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 07ba6d077..21f18d400 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -1,32 +1,75 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. - -set(CMAKE_Swift_OUTPUT_EXTENSION .o) -set(CMAKE_INCLUDE_FLAG_Swift "-I") +if(UNIX) + set(CMAKE_Swift_OUTPUT_EXTENSION .o) +else() + set(CMAKE_Swift_OUTPUT_EXTENSION .obj) +endif() # Load compiler-specific information. if(CMAKE_Swift_COMPILER_ID) include(Compiler/${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL) -endif() -# load the system- and compiler specific files -if(CMAKE_Swift_COMPILER_ID) - # load a hardware specific file, mostly useful for embedded compilers if(CMAKE_SYSTEM_PROCESSOR) include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) endif() include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL) endif() -# for most systems a module is the same as a shared library -# so unless the variable CMAKE_MODULE_EXISTS is set just -# copy the values from the LIBRARY variables -if(NOT CMAKE_MODULE_EXISTS) - set(CMAKE_SHARED_MODULE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_Swift_FLAGS}) - set(CMAKE_SHARED_MODULE_CREATE_Swift_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Swift_FLAGS}) +set(CMAKE_INCLUDE_FLAG_Swift "-I ") + +set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ") +set(CMAKE_Swift_COMPILER_ARG1 -frontend) +set(CMAKE_Swift_DEFINE_FLAG -D) +set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ") +set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ") +set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @) + +set(CMAKE_Swift_LINKER_PREFERENCE 50) +set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1) + +# NOTE(compnerd) use the short form for convenience and ease of search. They +# are treated equivalent to their long form names as well as custom Swift +# specific names. +set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -libc MT) +set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -libc MD) +set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -libc MTd) +set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -libc MDd) + +set(CMAKE_Swift_FLAGS_DEBUG_INIT "-g") +set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") +set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") +set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") + +# NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step +if(NOT CMAKE_Swift_COMPILE_OBJECT) + set(CMAKE_Swift_COMPILE_OBJECT ":") +endif() + +if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY) + if(CMAKE_Swift_COMPILER_TARGET) + set(CMAKE_Swift_CREATE_SHARED_LIBRARY "${CMAKE_Swift_COMPILER} -target -output-file-map -incremental -emit-library -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ") + else() + set(CMAKE_Swift_CREATE_SHARED_LIBRARY "${CMAKE_Swift_COMPILER} -output-file-map -incremental -emit-library -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ") + endif() +endif() + +if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) + set(CMAKE_Swift_CREATE_SHARED_MODULE ${CMAKE_Swift_CREATE_SHARED_LIBRARY}) endif() -include(CMakeCommonLanguageInclude) +if(NOT CMAKE_Swift_LINK_EXECUTABLE) + if(CMAKE_Swift_COMPILER_TARGET) + set(CMAKE_Swift_LINK_EXECUTABLE "${CMAKE_Swift_COMPILER} -target -output-file-map -incremental -emit-executable -o -emit-module -emit-module-path -emit-dependencies ") + else() + set(CMAKE_Swift_LINK_EXECUTABLE "${CMAKE_Swift_COMPILER} -output-file-map -incremental -emit-executable -o -emit-module -emit-module-path -emit-dependencies ") + endif() +endif() + +if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY) + set(CMAKE_Swift_ARCHIVE_CREATE " crs ") + set(CMAKE_Swift_ARCHIVE_FINISH "") +endif() set(CMAKE_Swift_INFORMATION_LOADED 1) diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 66f172277..c6a88144f 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -34,7 +34,7 @@ if(NOT _INCLUDED_SYSTEM_INFO_FILE) ${CMAKE_BINARY_DIR}/CopyOfCMakeCache.txt COPYONLY) message("Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. " "Please send that file to cmake@www.cmake.org.") - endif() + endif() endif() # optionally include a file which can do extra-generator specific things, e.g. diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake index 858c1be79..841aee643 100644 --- a/Modules/CMakeTestSwiftCompiler.cmake +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -1,7 +1,6 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. - if(CMAKE_Swift_COMPILER_FORCED) # The compiler configuration was forced by the user. # Assume the user has configured all compiler information. @@ -23,7 +22,6 @@ unset(CMAKE_Swift_COMPILER_WORKS CACHE) if(NOT CMAKE_Swift_COMPILER_WORKS) PrintTestCompilerStatus("Swift" "") file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift - "import Foundation\n" "print(\"CMake\")\n") try_compile(CMAKE_Swift_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift @@ -51,6 +49,11 @@ else() "Determining if the Swift compiler works passed with " "the following output:\n${__CMAKE_Swift_COMPILER_OUTPUT}\n\n") endif() + + # Re-configure to save learned information. + configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in + ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY) + include(${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake) endif() unset(__CMAKE_Swift_COMPILER_OUTPUT) diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index 2258271cc..655827a73 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -52,7 +52,7 @@ After generating this tar file, it can be sent to CDash for display with the ``GCOV_OPTIONS ...`` Specify options to be passed to gcov. The ``gcov`` command is run as ``gcov ... -o .gcda``. - If not specified, the default option is just ``-b``. + If not specified, the default option is just ``-b -x``. ``GLOB`` Recursively search for .gcda files in build_dir rather than @@ -95,7 +95,7 @@ function(ctest_coverage_collect_gcov) set(gcda_files) set(label_files) if (GCOV_GLOB) - file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${binary_dir}/*.gcda") + file(GLOB_RECURSE gfiles "${binary_dir}/*.gcda") list(LENGTH gfiles len) # if we have gcda files then also grab the labels file for that target if(${len} GREATER 0) @@ -109,7 +109,7 @@ function(ctest_coverage_collect_gcov) file(STRINGS "${binary_dir}/CMakeFiles/TargetDirectories.txt" target_dirs ENCODING UTF-8) foreach(target_dir ${target_dirs}) - file(GLOB_RECURSE gfiles RELATIVE ${binary_dir} "${target_dir}/*.gcda") + file(GLOB_RECURSE gfiles "${target_dir}/*.gcda") list(LENGTH gfiles len) # if we have gcda files then also grab the labels file for that target if(${len} GREATER 0) @@ -132,27 +132,21 @@ function(ctest_coverage_collect_gcov) # setup the dir for the coverage files set(coverage_dir "${binary_dir}/Testing/CoverageInfo") file(MAKE_DIRECTORY "${coverage_dir}") - # call gcov on each .gcda file - foreach (gcda_file ${gcda_files}) - # get the directory of the gcda file - get_filename_component(gcda_file ${binary_dir}/${gcda_file} ABSOLUTE) - get_filename_component(gcov_dir ${gcda_file} DIRECTORY) - # run gcov, this will produce the .gcov file in the current - # working directory - if(NOT DEFINED GCOV_GCOV_OPTIONS) - set(GCOV_GCOV_OPTIONS -b) - endif() - execute_process(COMMAND - ${gcov_command} ${GCOV_GCOV_OPTIONS} -o ${gcov_dir} ${gcda_file} - OUTPUT_VARIABLE out - RESULT_VARIABLE res - WORKING_DIRECTORY ${coverage_dir}) - - if (GCOV_DELETE) - file(REMOVE ${gcda_file}) - endif() + # run gcov, this will produce the .gcov files in the current + # working directory + if(NOT DEFINED GCOV_GCOV_OPTIONS) + set(GCOV_GCOV_OPTIONS -b -x) + endif() + execute_process(COMMAND + ${gcov_command} ${GCOV_GCOV_OPTIONS} ${gcda_files} + OUTPUT_VARIABLE out + RESULT_VARIABLE res + WORKING_DIRECTORY ${coverage_dir}) + + if (GCOV_DELETE) + file(REMOVE ${gcda_files}) + endif() - endforeach() if(NOT "${res}" EQUAL 0) if (NOT GCOV_QUIET) message(STATUS "Error running gcov: ${res} ${out}") diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index f5c112717..a3e2da368 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -37,27 +37,27 @@ include(CheckCSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") + set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") # Normalize locale during test compilation. - set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) - set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}") - set(ENV{${v}} C) - endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) - CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} - # Some compilers do not fail with a bad flag - FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU - ${_CheckCCompilerFlag_COMMON_PATTERNS} - ) - foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}}) - unset(_CheckCCompilerFlag_SAVED_${v}) - endforeach() - unset(_CheckCCompilerFlag_LOCALE_VARS) - unset(_CheckCCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") + set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) + foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) + set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(ENV{${v}} C) + endforeach() + CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS) + CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU + ${_CheckCCompilerFlag_COMMON_PATTERNS} + ) + foreach(v ${_CheckCCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}}) + unset(_CheckCCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckCCompilerFlag_LOCALE_VARS) + unset(_CheckCCompilerFlag_COMMON_PATTERNS) + + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") endmacro () diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index a01e142ab..5729843c3 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -37,27 +37,27 @@ include(CheckCXXSourceCompiles) include(CMakeCheckCompilerFlagCommonPatterns) macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) - set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") - - # Normalize locale during test compilation. - set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}") - set(ENV{${v}} C) - endforeach() - CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) - CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT} - # Some compilers do not fail with a bad flag - FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU - ${_CheckCXXCompilerFlag_COMMON_PATTERNS} - ) - foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) - set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) - unset(_CheckCXXCompilerFlag_SAVED_${v}) - endforeach() - unset(_CheckCXXCompilerFlag_LOCALE_VARS) - unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) - - set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") + set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") + set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") + + # Normalize locale during test compilation. + set(_CheckCXXCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG) + foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) + set(_CheckCXXCompilerFlag_SAVED_${v} "$ENV{${v}}") + set(ENV{${v}} C) + endforeach() + CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCXXCompilerFlag_COMMON_PATTERNS) + CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU + ${_CheckCXXCompilerFlag_COMMON_PATTERNS} + ) + foreach(v ${_CheckCXXCompilerFlag_LOCALE_VARS}) + set(ENV{${v}} ${_CheckCXXCompilerFlag_SAVED_${v}}) + unset(_CheckCXXCompilerFlag_SAVED_${v}) + endforeach() + unset(_CheckCXXCompilerFlag_LOCALE_VARS) + unset(_CheckCXXCompilerFlag_COMMON_PATTERNS) + + set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") endmacro () diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index 970e301b4..2cccd09ff 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -24,7 +24,7 @@ Check if a symbol exists as a function, variable, or macro in C++ as a function or variable then the symbol must also be available for linking. If the symbol is a type or enum value it will not be recognized (consider using :module:`CheckTypeSize` - or :module:`CheckCSourceCompiles`). + or :module:`CheckCXXSourceCompiles`). The following variables may be set before calling this macro to modify the way the check is run: diff --git a/Modules/CheckLanguage.cmake b/Modules/CheckLanguage.cmake index efa88bdab..a1a3a7aac 100644 --- a/Modules/CheckLanguage.cmake +++ b/Modules/CheckLanguage.cmake @@ -13,12 +13,14 @@ Usage: check_language() -where is a language that may be passed to enable_language() -such as "Fortran". If CMAKE__COMPILER is already defined the -check does nothing. Otherwise it tries enabling the language in a -test project. The result is cached in CMAKE__COMPILER as the -compiler that was found, or NOTFOUND if the language cannot be -enabled. +where ```` is a language that may be passed to :command:`enable_language` +such as ``Fortran``. If :variable:`CMAKE__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__COMPILER` +as the compiler that was found, or ``NOTFOUND`` if the language cannot be +enabled. For CUDA which can have an explicit host compiler, the cache +:variable:`CMAKE_CUDA_HOST_COMPILER` variable will be set if it was required +for compilation. Example: @@ -39,13 +41,23 @@ macro(check_language lang) set(_desc "Looking for a ${lang} compiler") message(STATUS ${_desc}) file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt" + + set(extra_compiler_variables) + if(lang STREQUAL CUDA) + set(extra_compiler_variables "set(CMAKE_CUDA_HOST_COMPILER \\\"\${CMAKE_CUDA_HOST_COMPILER}\\\")") + endif() + + set(content "cmake_minimum_required(VERSION ${CMAKE_VERSION}) project(Check${lang} ${lang}) file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" \"set(CMAKE_${lang}_COMPILER \\\"\${CMAKE_${lang}_COMPILER}\\\")\\n\" - ) -") + \"${extra_compiler_variables}\\n\" + )" + ) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/Check${lang}/CMakeLists.txt" + "${content}") if(CMAKE_GENERATOR_INSTANCE) set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") else() @@ -75,5 +87,12 @@ file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" message(STATUS "${_desc} - ${CMAKE_${lang}_COMPILER}") set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER}" CACHE FILEPATH "${lang} compiler") mark_as_advanced(CMAKE_${lang}_COMPILER) + + if(CMAKE_${lang}_HOST_COMPILER) + message(STATUS "Looking for a ${lang} host compiler - ${CMAKE_${lang}_HOST_COMPILER}") + set(CMAKE_${lang}_HOST_COMPILER "${CMAKE_${lang}_HOST_COMPILER}" CACHE FILEPATH "${lang} host compiler") + mark_as_advanced(CMAKE_${lang}_HOST_COMPILER) + endif() + endif() endmacro() diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake index 720217db6..6d63f0bad 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/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index 7fef85770..842a8fdb7 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -50,33 +50,33 @@ include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) macro (CHECK_STRUCT_HAS_MEMBER _STRUCT _MEMBER _HEADER _RESULT) - set(_INCLUDE_FILES) - foreach (it ${_HEADER}) - string(APPEND _INCLUDE_FILES "#include <${it}>\n") - endforeach () - - if("x${ARGN}" STREQUAL "x") - set(_lang C) - elseif("x${ARGN}" MATCHES "^xLANGUAGE;([a-zA-Z]+)$") - set(_lang "${CMAKE_MATCH_1}") - else() - message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n") - endif() - - set(_CHECK_STRUCT_MEMBER_SOURCE_CODE " + set(_INCLUDE_FILES) + foreach (it ${_HEADER}) + string(APPEND _INCLUDE_FILES "#include <${it}>\n") + endforeach () + + if("x${ARGN}" STREQUAL "x") + set(_lang C) + elseif("x${ARGN}" MATCHES "^xLANGUAGE;([a-zA-Z]+)$") + set(_lang "${CMAKE_MATCH_1}") + else() + message(FATAL_ERROR "Unknown arguments:\n ${ARGN}\n") + endif() + + set(_CHECK_STRUCT_MEMBER_SOURCE_CODE " ${_INCLUDE_FILES} int main() { - (void)sizeof(((${_STRUCT} *)0)->${_MEMBER}); - return 0; + (void)sizeof(((${_STRUCT} *)0)->${_MEMBER}); + return 0; } ") - if("${_lang}" STREQUAL "C") - CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) - elseif("${_lang}" STREQUAL "CXX") - CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) - else() - message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n") - endif() + if("${_lang}" STREQUAL "C") + CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) + elseif("${_lang}" STREQUAL "CXX") + CHECK_CXX_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT}) + else() + message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n") + endif() endmacro () diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in index 2303c4e05..82035a336 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/ARMCC-ASM.cmake b/Modules/Compiler/ARMCC-ASM.cmake index 539d5259f..5819fc756 100644 --- a/Modules/Compiler/ARMCC-ASM.cmake +++ b/Modules/Compiler/ARMCC-ASM.cmake @@ -4,4 +4,4 @@ set(CMAKE_ASM_OUTPUT_EXTENSION ".o") set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) set(CMAKE_ASM_COMPILE_OBJECT " -o ") -set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa) diff --git a/Modules/Compiler/ARMClang-ASM.cmake b/Modules/Compiler/ARMClang-ASM.cmake new file mode 100644 index 000000000..ceff3e8ce --- /dev/null +++ b/Modules/Compiler/ARMClang-ASM.cmake @@ -0,0 +1,9 @@ +include(Compiler/ARMClang) + +set(CMAKE_ASM_OUTPUT_EXTENSION ".o") +set(CMAKE_ASM_OUTPUT_EXTENSION_REPLACE 1) + +set(CMAKE_ASM_COMPILE_OBJECT " -c -o ") +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS S;s;asm;msa) + +__compiler_armclang(ASM) diff --git a/Modules/Compiler/ARMClang-C-FeatureTests.cmake b/Modules/Compiler/ARMClang-C-FeatureTests.cmake new file mode 100644 index 000000000..ef79229d0 --- /dev/null +++ b/Modules/Compiler/ARMClang-C-FeatureTests.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-C-FeatureTests) diff --git a/Modules/Compiler/ARMClang-C.cmake b/Modules/Compiler/ARMClang-C.cmake new file mode 100644 index 000000000..0a64a8a4f --- /dev/null +++ b/Modules/Compiler/ARMClang-C.cmake @@ -0,0 +1,15 @@ +include(Compiler/Clang-C) +include(Compiler/ARMClang) +__compiler_armclang(C) + +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) diff --git a/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake b/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake new file mode 100644 index 000000000..e038e807b --- /dev/null +++ b/Modules/Compiler/ARMClang-CXX-FeatureTests.cmake @@ -0,0 +1 @@ +include(Compiler/Clang-CXX-FeatureTests) diff --git a/Modules/Compiler/ARMClang-CXX.cmake b/Modules/Compiler/ARMClang-CXX.cmake new file mode 100644 index 000000000..5dfb4011e --- /dev/null +++ b/Modules/Compiler/ARMClang-CXX.cmake @@ -0,0 +1,3 @@ +include(Compiler/Clang-CXX) +include(Compiler/ARMClang) +__compiler_armclang(CXX) diff --git a/Modules/Compiler/ARMClang-DetermineCompiler.cmake b/Modules/Compiler/ARMClang-DetermineCompiler.cmake new file mode 100644 index 000000000..eb0de5306 --- /dev/null +++ b/Modules/Compiler/ARMClang-DetermineCompiler.cmake @@ -0,0 +1,10 @@ +# ARMClang Toolchain +set(_compiler_id_pp_test "defined(__clang__) && defined(__ARMCOMPILER_VERSION)") + +set(_compiler_id_version_compute " + # define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__ARMCOMPILER_VERSION/1000000) + # define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__ARMCOMPILER_VERSION/10000 % 100) + # define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__ARMCOMPILER_VERSION % 10000)") + +string(APPEND _compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__ARMCOMPILER_VERSION)") diff --git a/Modules/Compiler/ARMClang.cmake b/Modules/Compiler/ARMClang.cmake new file mode 100644 index 000000000..2518ac714 --- /dev/null +++ b/Modules/Compiler/ARMClang.cmake @@ -0,0 +1,71 @@ +if(_ARMClang_CMAKE_LOADED) + return() +endif() +set(_ARMClang_CMAKE_LOADED TRUE) + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +get_filename_component(_CMAKE_C_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) +get_filename_component(_CMAKE_CXX_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) + +set(CMAKE_EXECUTABLE_SUFFIX ".elf") + +find_program(CMAKE_ARMClang_LINKER armlink HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) +find_program(CMAKE_ARMClang_AR armar HINTS "${_CMAKE_C_TOOLCHAIN_LOCATION}" "${_CMAKE_CXX_TOOLCHAIN_LOCATION}" ) + +set(CMAKE_LINKER "${CMAKE_ARMClang_LINKER}" CACHE FILEPATH "The ARMClang linker" FORCE) +mark_as_advanced(CMAKE_ARMClang_LINKER) +set(CMAKE_AR "${CMAKE_ARMClang_AR}" CACHE FILEPATH "The ARMClang archiver" FORCE) +mark_as_advanced(CMAKE_ARMClang_AR) + +# get compiler supported cpu list +function(__armclang_set_processor_list lang out_var) + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --target=${CMAKE_${lang}_COMPILER_TARGET} -mcpu=list + OUTPUT_VARIABLE processor_list + ERROR_VARIABLE processor_list) + string(REGEX MATCHALL "-mcpu=([^ \n]*)" processor_list "${processor_list}") + string(REGEX REPLACE "-mcpu=" "" processor_list "${processor_list}") + set(${out_var} "${processor_list}" PARENT_SCOPE) +endfunction() + +# check processor is in list +function(__armclang_check_processor processor list out_var) + string(TOLOWER "${processor}" processor) + if(processor IN_LIST list) + set(${out_var} TRUE PARENT_SCOPE) + else() + set(${out_var} FALSE PARENT_SCOPE) + endif() +endfunction() + +macro(__compiler_armclang lang) + if(NOT CMAKE_${lang}_COMPILER_TARGET) + set(CMAKE_${lang}_COMPILER_TARGET arm-arm-none-eabi) + endif() + if(NOT CMAKE_${lang}_COMPILER_PROCESSOR_LIST) + __armclang_set_processor_list(${lang} CMAKE_${lang}_COMPILER_PROCESSOR_LIST) + endif() + if(NOT CMAKE_SYSTEM_PROCESSOR) + message(FATAL_ERROR " CMAKE_SYSTEM_PROCESSOR must be set for ARMClang\n" + " Supported processor: ${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}\n") + else() + __armclang_check_processor("${CMAKE_SYSTEM_PROCESSOR}" "${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}" _CMAKE_${lang}_CHECK_RESULT) + if(NOT _CMAKE_${lang}_CHECK_RESULT) + message(FATAL_ERROR " System processor '${CMAKE_SYSTEM_PROCESSOR}' not supported by ARMClang ${lang} compiler\n" + " Supported processor: ${CMAKE_${lang}_COMPILER_PROCESSOR_LIST}\n") + endif() + unset(_CMAKE_${lang}_CHECK_RESULT) + endif() + string(APPEND CMAKE_${lang}_FLAGS_INIT "-mcpu=${CMAKE_SYSTEM_PROCESSOR}") + string(APPEND CMAKE_${lang}_LINK_FLAGS "--cpu=${CMAKE_SYSTEM_PROCESSOR}") + + set(CMAKE_${lang}_LINK_EXECUTABLE " -o --list .map") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " --create -cr ") + set(CMAKE_${lang}_ARCHIVE_CREATE " --create -cr ") + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "--via=") + set(CMAKE_${lang}_OUTPUT_EXTENSION ".o") + set(CMAKE_${lang}_OUTPUT_EXTENSION_REPLACE 1) +endmacro() + +cmake_policy(POP) diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index a48adec92..2794f52bb 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 e5fd64721..3fa69904a 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") @@ -16,10 +17,12 @@ endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1) # AppleClang 5.0 knows this flag, but does not set a __cplusplus macro greater than 201103L 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 (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) @@ -27,4 +30,13 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1) set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") +endif() + __compiler_check_default_language_standard(CXX 4.0 98) diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index ad464c77c..96537f8dd 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 a07ae4019..0448965ee 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 e99011b3b..17f391746 100644 --- a/Modules/Compiler/Clang-CXX.cmake +++ b/Modules/Compiler/Clang-CXX.cmake @@ -1,7 +1,7 @@ include(Compiler/Clang) __compiler_clang(CXX) -if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden") endif() @@ -10,15 +10,18 @@ if(APPLE AND NOT appleClangPolicy STREQUAL NEW) return() endif() -if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + +if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1) set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98") set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98") endif() if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1) + 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") + set(CMAKE_CXX11_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") @@ -27,9 +30,11 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) 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() set(_clang_version_std17 5.0) @@ -52,6 +57,14 @@ if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") unset(_clang_version_std17) + if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC") + # This clang++ is missing some features because of MSVC compatibility. + unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT) + unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT) + endif() + __compiler_check_default_language_standard(CXX 2.1 98) elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9 AND CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0) @@ -59,6 +72,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 d34154c1f..93409489b 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 85a316793..38c8b1ee9 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/Cray-Fortran.cmake b/Modules/Compiler/Cray-Fortran.cmake index dbf28e3a4..ccb7c2ee5 100644 --- a/Modules/Compiler/Cray-Fortran.cmake +++ b/Modules/Compiler/Cray-Fortran.cmake @@ -4,6 +4,8 @@ include(Compiler/Cray) __compiler_cray(Fortran) +set(CMAKE_Fortran_SUBMODULE_SEP "") +set(CMAKE_Fortran_SUBMODULE_EXT ".mod") set(CMAKE_Fortran_MODOUT_FLAG -em) set(CMAKE_Fortran_MODDIR_FLAG -J) set(CMAKE_Fortran_MODDIR_DEFAULT .) diff --git a/Modules/Compiler/CrayPrgEnv.cmake b/Modules/Compiler/CrayPrgEnv.cmake index 6c1c77016..e55e5873a 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 f072c546a..ca286b397 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 00582236a..fcaaeab43 100644 --- a/Modules/Compiler/GNU-CXX.cmake +++ b/Modules/Compiler/GNU-CXX.cmake @@ -17,6 +17,7 @@ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) endif() if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) + 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") elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) @@ -25,6 +26,10 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14") @@ -33,6 +38,10 @@ elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) +endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") diff --git a/Modules/Compiler/GNU-FindBinUtils.cmake b/Modules/Compiler/GNU-FindBinUtils.cmake index 16b7bbda4..097fbf3ac 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 e12bfd18e..437678e19 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -3,21 +3,40 @@ include(Compiler/IAR) if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") -set(CMAKE_ASM_COMPILE_OBJECT " -S -o ") - __compiler_iar_ARM(ASM) + set(CMAKE_ASM_COMPILE_OBJECT " -S -o ") + __compiler_iar_ilink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) + +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX") + set(CMAKE_ASM_COMPILE_OBJECT " --silent -o ") + __compiler_iar_ilink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) + +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") + set(CMAKE_ASM_COMPILE_OBJECT " --silent -o ") + __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 "RL78") + set(CMAKE_ASM_COMPILE_OBJECT " --silent -o ") + __compiler_iar_ilink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) + +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISC-V") + set(CMAKE_ASM_COMPILE_OBJECT " --silent -o ") + __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 " -S -o ") - __compiler_iar_AVR(ASM) + __compiler_iar_xlink(ASM) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s90;asm;msa) +elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + set(CMAKE_ASM_COMPILE_OBJECT " -S -o ") + __compiler_iar_xlink(ASM) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s43;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 b5e61f070..18a4a7581 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -3,60 +3,63 @@ 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_C_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_C_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") + if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_LESS 7) + # IAR ARM 4.X uses xlink.exe, detection is not yet implemented + message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + endif() + __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() +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) - set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") + __compiler_iar_ilink(C) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 2.10 11) - 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 "RL78") + __compiler_iar_ilink(C) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 4.10 11) - __compiler_iar_AVR(C) +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") + __compiler_iar_ilink(C) + __compiler_check_default_language_standard(C 1.10 90 1.10 99 1.10 11) + +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") - if(NOT CMAKE_C_LINK_FLAGS) - set(CMAKE_C_LINK_FLAGS "-Fmotorola") - endif() - - set(CMAKE_C_LINK_EXECUTABLE " -o ") - set(CMAKE_C_CREATE_STATIC_LIBRARY " -o ") - - # 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" ) +elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + __compiler_iar_xlink(C) + __compiler_check_default_language_standard(C 1.10 90 5.10 99) + set(CMAKE_C_OUTPUT_EXTENSION ".r43") 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 b7076f5cc..e8f114205 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -3,76 +3,71 @@ 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_CXX_COMPILER_VERSION) + message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION not detected. This should be automatic.") +endif() + +if(NOT CMAKE_IAR_CXX_FLAG) + # The --c++ flag was introduced in platform version 9 for all architectures except ARM where it was introduced already in version 7 + if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 8 OR + (CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_GREATER 6 AND "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM") ) + 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") + if(CMAKE_CXX_COMPILER_VERSION_INTERNAL VERSION_LESS 7) + # IAR ARM 4.X uses xlink.exe, detection is not yet implemented + message(FATAL_ERROR "CMAKE_CXX_COMPILER_VERSION = ${CMAKE_C_COMPILER_VERSION} not supported by CMake.") + endif() + __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) +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850") + __compiler_iar_ilink(CXX) + __compiler_check_default_language_standard(CXX 1.10 98 2.10 14) - __compiler_iar_AVR(CXX) - __compiler_check_default_language_standard(CXX 7.10 98) +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78") + __compiler_iar_ilink(CXX) + __compiler_check_default_language_standard(CXX 1.10 98 4.10 14) - set(CMAKE_CXX_OUTPUT_EXTENSION ".r90") - if(NOT CMAKE_CXX_LINK_FLAGS) - set(CMAKE_CXX_LINK_FLAGS "-Fmotorola") - endif() +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") + __compiler_iar_ilink(CXX) + __compiler_check_default_language_standard(CXX 1.10 98 1.10 14) - set(CMAKE_CXX_LINK_EXECUTABLE " -o ") - set(CMAKE_CXX_CREATE_STATIC_LIBRARY " -o ") +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR") + __compiler_iar_xlink(CXX) + __compiler_check_default_language_standard(CXX 7.10 98) - # 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") +elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") + __compiler_iar_xlink(CXX) + __compiler_check_default_language_standard(CXX 5.10 98) + set(CMAKE_CXX_OUTPUT_EXTENSION ".r43") 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 43477acb1..57ca1c991 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__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__)) # 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 5fecb2662..b7d466405 100644 --- a/Modules/Compiler/IAR-FindBinUtils.cmake +++ b/Modules/Compiler/IAR-FindBinUtils.cmake @@ -2,7 +2,7 @@ if(NOT DEFINED _CMAKE_PROCESSING_LANGUAGE OR _CMAKE_PROCESSING_LANGUAGE STREQUAL message(FATAL_ERROR "Internal error: _CMAKE_PROCESSING_LANGUAGE is not set") endif() -# Try to find tools in the same directory as Clang itself +# Try to find tools in the same directory as the compiler itself get_filename_component(__iar_hint_1 "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER}" REALPATH) get_filename_component(__iar_hint_1 "${__iar_hint_1}" DIRECTORY) @@ -10,40 +10,47 @@ 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") - find_program(CMAKE_IAR_ARCHIVE iarchive.exe HINTS ${__iar_hints} +if("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "ARM" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RX" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RH850" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RL78" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "RISCV") + + string(TOLOWER "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" _archid_lower) + + # Find linker + find_program(CMAKE_IAR_LINKER ilink${_archid_lower} HINTS ${__iar_hints} + DOC "The IAR ILINK linker") + find_program(CMAKE_IAR_ARCHIVE iarchive HINTS ${__iar_hints} DOC "The IAR archiver") - # find auxiliary tools - find_program(CMAKE_IAR_ELFTOOL ielftool.exe HINTS ${__iar_hints} + # Find utility tools + find_program(CMAKE_IAR_ELFTOOL ielftool HINTS ${__iar_hints} DOC "The IAR ELF Tool") - find_program(CMAKE_IAR_ELFDUMP ielfdumparm.exe HINTS ${__iar_hints} + find_program(CMAKE_IAR_ELFDUMP ielfdump${_archid_lower} HINTS ${__iar_hints} DOC "The IAR ELF Dumper") - find_program(CMAKE_IAR_OBJMANIP iobjmanip.exe HINTS ${__iar_hints} + find_program(CMAKE_IAR_OBJMANIP iobjmanip HINTS ${__iar_hints} DOC "The IAR ELF Object Tool") - find_program(CMAKE_IAR_SYMEXPORT isymexport.exe HINTS ${__iar_hints} + find_program(CMAKE_IAR_SYMEXPORT isymexport 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" OR + "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430") -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") - find_program(CMAKE_IAR_AR xar.exe HINTS ${__iar_hints} + # Find the "xlink" linker and "xar" archiver: + find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints} + DOC "The IAR XLINK linker") + find_program(CMAKE_IAR_AR xar 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 bbcdea235..8e75caafe 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_IAR_${lang}_FLAG} --silent -o ") set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " ${CMAKE_IAR_${lang}_FLAG} --silent --preprocess=cnl ") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " ${CMAKE_IAR_${lang}_FLAG} --silent -lAH -o .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 -o ") + 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 -o ") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_ARCHIVE}\" --create ") set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_ARCHIVE}\" --create ") set(CMAKE_${lang}_ARCHIVE_APPEND "\"${CMAKE_IAR_ARCHIVE}\" --replace ") 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 -o ") set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "\"${CMAKE_IAR_AR}\" ") set(CMAKE_${lang}_ARCHIVE_CREATE "\"${CMAKE_IAR_AR}\" ") diff --git a/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake b/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake index e5b97412e..899e284ad 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 63c3e32d6..73aa2b4f9 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 4e4af2956..e9e59a20c 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-FeatureTests.cmake b/Modules/Compiler/Intel-CXX-FeatureTests.cmake index aa35b977e..bbefe15de 100644 --- a/Modules/Compiler/Intel-CXX-FeatureTests.cmake +++ b/Modules/Compiler/Intel-CXX-FeatureTests.cmake @@ -24,7 +24,7 @@ set(DETECT_CXX14 "((__cplusplus >= 201300L) || ((__cplusplus == 201103L) && !def unset(DETECT_BUGGY_ICC15) set(Intel17_CXX14 "__INTEL_COMPILER >= 1700 && ${DETECT_CXX14}") -set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !(__INTEL_COMPILER == 1800 && __INTEL_COMPILER_UPDATE < 5) && !defined(_MSC_VER))") +set(_cmake_feature_test_cxx_relaxed_constexpr "__cpp_constexpr >= 201304 || (${Intel17_CXX14} && !defined(_MSC_VER))") set(Intel16_CXX14 "__INTEL_COMPILER >= 1600 && ${DETECT_CXX14}") set(_cmake_feature_test_cxx_aggregate_default_initializers "${Intel16_CXX14}") diff --git a/Modules/Compiler/Intel-CXX.cmake b/Modules/Compiler/Intel-CXX.cmake index c115b6ade..b630a6bc4 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() @@ -39,6 +40,10 @@ else() set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17") endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.0) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.2) set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14") elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0.0) @@ -53,6 +58,10 @@ else() set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y") endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15.0) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + endif() + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11") set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11") @@ -64,6 +73,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 d7e453211..c31aa7752 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 675560c2a..000000000 --- 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 9fb191c75..000000000 --- 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 9e485532b..000000000 --- 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 ffceea80d..000000000 --- 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 22c34f80c..20787a399 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,19 @@ 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() + +# /JMC "Just My Code" is only supported by MSVC 19.05 onward. +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + set(CMAKE_C_COMPILE_OPTIONS_JMC "-JMC") +endif() diff --git a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake index 9c604f202..125974a8d 100644 --- a/Modules/Compiler/MSVC-CXX-FeatureTests.cmake +++ b/Modules/Compiler/MSVC-CXX-FeatureTests.cmake @@ -9,10 +9,8 @@ set(_cmake_oldestSupported "_MSC_VER >= 1600") # https://docs.microsoft.com/en-us/cpp/cpp-conformance-improvements-2017#update_153 set(_cmake_feature_test_cxx_decltype_incomplete_return_types "_MSC_VER >= 1911") -set(MSVC_2017 "_MSC_VER >= 1910") -# VS 2017 introduces support for "N3652 Extended constexpr" -# but as of v15.6 there are still bugs in the implementation -#set(_cmake_feature_test_cxx_relaxed_constexpr "${MSVC_2017}") +# VS 2017 v15.3 fixes support for "N3652 Extended constexpr" +set(_cmake_feature_test_cxx_relaxed_constexpr "_MSC_VER >= 1911") # VS 2017 Preview introduces support for aggregate initializers. set(_cmake_feature_test_cxx_aggregate_default_initializers "_MSC_FULL_VER >= 190024406") diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index be259ff6f..915295d38 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -11,11 +11,14 @@ 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") set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std:c++14") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.11.25505) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++17") set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++17") else() @@ -29,21 +32,6 @@ if ((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.0.24215.1 AND __compiler_check_default_language_standard(CXX 19.0 14) - # All features that we define are available in the base mode, except - # for meta-features for C++14 and above. Override the default macro - # to avoid doing unnecessary work. - macro(cmake_record_cxx_compile_features) - if (DEFINED CMAKE_CXX20_STANDARD_COMPILE_OPTION) - list(APPEND CMAKE_CXX20_COMPILE_FEATURES cxx_std_20) - endif() - # The main cmake_record_cxx_compile_features macro makes all - # these conditional on CMAKE_CXX##_STANDARD_COMPILE_OPTION, - # but we can skip the conditions because we set them above. - list(APPEND CMAKE_CXX17_COMPILE_FEATURES cxx_std_17) - list(APPEND CMAKE_CXX14_COMPILE_FEATURES cxx_std_14) - list(APPEND CMAKE_CXX98_COMPILE_FEATURES cxx_std_11) # no flag needed for 11 - _record_compiler_features_cxx(98) - endmacro() elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) # MSVC has no specific options to set language standards, but set them as # empty strings anyways so the feature test infrastructure can at least check @@ -77,3 +65,8 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() endif() + +# /JMC "Just My Code" is only supported by MSVC 19.05 onward. +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) + set(CMAKE_CXX_COMPILE_OPTIONS_JMC "-JMC") +endif() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index de9dd99ba..c0ccb7147 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -40,3 +40,8 @@ endif() set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0) set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0) set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0) + +if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "9.0") + set(CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG "--options-file ") + set(CMAKE_CUDA_RESPONSE_FILE_FLAG "--options-file ") +endif() diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index 3b3848a2c..c39dbe517 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 35076bb38..c77de3605 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 c4aba8eca..7e962b8ee 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 279d87538..e7133c153 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 5ce58b221..c946c6436 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 484811efe..3f4e05c55 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 5dc8bc17f..2077bdabd 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 2bf1ec69c..dffa4bc21 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 b87e9238b..303785112 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 68dc28a92..a9cec113f 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 " -S -o ") set(CMAKE_DEPFILE_FLAGS_${lang} "-MF -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} /objects.exp " - " -Wl,-bE:/objects.exp -o " - ) - endif() endmacro() diff --git a/Modules/Compiler/XLClang-C-DetermineCompiler.cmake b/Modules/Compiler/XLClang-C-DetermineCompiler.cmake new file mode 100644 index 000000000..4d899213a --- /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 000000000..54c18a668 --- /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 000000000..4d899213a --- /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 000000000..9ea3d7cac --- /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 + " -x c++ -o -c ") diff --git a/Modules/Compiler/XLClang.cmake b/Modules/Compiler/XLClang.cmake new file mode 100644 index 000000000..cdf0fdca1 --- /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 22e052334..20b37d222 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -202,23 +202,24 @@ External Project Definition :command:`file(DOWNLOAD)`) ``NETRC `` - 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 `` - 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 `` 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 `` 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 --` 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 "/${name}-cache-$.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 "/${name}-cache-$.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 "") endif() diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index f27d7fe97..88e2681eb 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 c12512f15..96554405d 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 ce76c99df..c4e55ce57 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 c6c8de0d5..6b5828eef 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__DEFINED`` - true is the macro ran successfully + ``True`` is the macro ran successfully ``BISON__INPUT`` The input source file, an alias for diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 0aa4f5035..77f9d0e40 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) @@ -145,7 +152,9 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) - + if(NOT "${_thread}" STREQUAL "") + set(_combined_name ${_combined_name}_thread) + endif() if(_libraries_work) if (BLA_STATIC) if (WIN32) @@ -232,7 +241,8 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") set(BLAS_mkl_DLL_SUFFIX "_dll") endif() else() - if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + # Switch to GNU Fortran support layer if needed (but not on Apple, where MKL does not provide it) + if(CMAKE_Fortran_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) set(BLAS_mkl_INTFACE "gf") set(BLAS_mkl_THREADING "gnu") set(BLAS_mkl_OMP "gomp") @@ -394,6 +404,23 @@ if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All") endif () endif () + if (DEFINED ENV{MKLROOT}) + if (BLA_VENDOR STREQUAL "Intel10_32") + set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/ia32") + elseif (BLA_VENDOR MATCHES "^Intel10_64i?lp$" OR BLA_VENDOR MATCHES "^Intel10_64i?lp_seq$") + set(_BLAS_MKLROOT_LIB_DIR "$ENV{MKLROOT}/lib/intel64") + endif () + endif () + if (_BLAS_MKLROOT_LIB_DIR) + if (WIN32) + string(APPEND _BLAS_MKLROOT_LIB_DIR "_win") + elseif (APPLE) + string(APPEND _BLAS_MKLROOT_LIB_DIR "_mac") + else () + string(APPEND _BLAS_MKLROOT_LIB_DIR "_lin") + endif () + endif () + foreach (IT ${BLAS_SEARCH_LIBS}) string(REPLACE " " ";" SEARCH_LIBS ${IT}) if (NOT ${_LIBRARIES}) @@ -404,6 +431,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 () @@ -453,6 +481,18 @@ if (BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") "" ) endif() + if(NOT BLAS_LIBRARIES) + find_package(Threads) + # OpenBLAS (http://www.openblas.net) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "openblas" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif() endif () if (BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All") diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 249514864..309b97145 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -65,40 +65,40 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 VERSION_VAR BZIP2_VERSION_STRING) if (BZIP2_FOUND) - set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR}) - include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake) - include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) - cmake_push_check_state() - set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY}) - set(CMAKE_REQUIRED_INCLUDES ${BZIP2_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES}) - CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX) - cmake_pop_check_state() - - if(NOT TARGET BZip2::BZip2) - add_library(BZip2::BZip2 UNKNOWN IMPORTED) + set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR}) + include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY}) + set(CMAKE_REQUIRED_INCLUDES ${BZIP2_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES}) + CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX) + cmake_pop_check_state() + + if(NOT TARGET BZip2::BZip2) + add_library(BZip2::BZip2 UNKNOWN IMPORTED) + set_target_properties(BZip2::BZip2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") + + if(BZIP2_LIBRARY_RELEASE) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) set_target_properties(BZip2::BZip2 PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") - - if(BZIP2_LIBRARY_RELEASE) - set_property(TARGET BZip2::BZip2 APPEND PROPERTY - IMPORTED_CONFIGURATIONS RELEASE) - set_target_properties(BZip2::BZip2 PROPERTIES - IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}") - endif() - - if(BZIP2_LIBRARY_DEBUG) - set_property(TARGET BZip2::BZip2 APPEND PROPERTY - IMPORTED_CONFIGURATIONS DEBUG) - set_target_properties(BZip2::BZip2 PROPERTIES - IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}") - endif() - - if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG) - set_property(TARGET BZip2::BZip2 APPEND PROPERTY - IMPORTED_LOCATION "${BZIP2_LIBRARY}") - endif() + IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}") endif() + + if(BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(BZip2::BZip2 PROPERTIES + IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}") + endif() + + if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_LOCATION "${BZIP2_LIBRARY}") + endif() + endif() endif () mark_as_advanced(BZIP2_INCLUDE_DIR) diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake index e1f45f7d4..cf1632a57 100644 --- a/Modules/FindBacktrace.cmake +++ b/Modules/FindBacktrace.cmake @@ -5,30 +5,30 @@ FindBacktrace ------------- -Find provider for backtrace(3). +Find provider for `backtrace(3) `__. -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 6a59dffc8..25dd397cf 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -30,12 +30,18 @@ case results are reported in variables:: Boost__FOUND - True if component was found ( is upper-case) Boost__LIBRARY - Libraries to link for component (may include target_link_libraries debug/optimized keywords) - Boost_VERSION - BOOST_VERSION value from boost/version.hpp - Boost_LIB_VERSION - Version string appended to library filenames - Boost_MAJOR_VERSION - Boost major version number (X in X.y.z) - Boost_MINOR_VERSION - Boost minor version number (Y in x.Y.z) - Boost_SUBMINOR_VERSION - Boost subminor version number (Z in x.y.Z) + Boost_VERSION_MACRO - BOOST_VERSION value from boost/version.hpp Boost_VERSION_STRING - Boost version number in x.y.z format + Boost_VERSION - if CMP0093 NEW => same as Boost_VERSION_STRING + if CMP0093 OLD or unset => same as Boost_VERSION_MACRO + Boost_LIB_VERSION - Version string appended to library filenames + Boost_VERSION_MAJOR - Boost major version number (X in X.y.z) + alias: Boost_MAJOR_VERSION + Boost_VERSION_MINOR - Boost minor version number (Y in x.Y.z) + alias: Boost_MINOR_VERSION + Boost_VERSION_PATCH - Boost subminor version number (Z in x.y.Z) + alias: Boost_SUBMINOR_VERSION + Boost_VERSION_COUNT - Amount of version components (3) Boost_LIB_DIAGNOSTIC_DEFINITIONS (Windows) - Pass to add_definitions() to have diagnostic information about Boost's automatic linking @@ -72,8 +78,9 @@ and saves search results persistently in CMake cache entries:: The following :prop_tgt:`IMPORTED` targets are also defined:: - Boost::boost - Target for header-only dependencies + Boost::headers - Target for header-only dependencies (Boost include directory) + alias: Boost::boost Boost:: - Target for specific component dependency (shared or static library); is lower- case @@ -85,33 +92,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__LIBRARY_DEBUG and Boost__LIBRARY_RELEASE. +library directories in ``Boost_LIBRARY_DIR_DEBUG`` and +``Boost_LIBRARY_DIR_RELEASE`` and individual library +locations in ``Boost__LIBRARY_DEBUG`` and ``Boost__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. @@ -162,10 +169,6 @@ Other variables one may set to control this module are:: Boost_DEBUG - Set to ON to enable debug output from FindBoost. Please enable this before filing any bug report. - Boost_DETAILED_FAILURE_MSG - - Set to ON to add detailed information to the - failure message even when the REQUIRED option - is not given to the find_package call. Boost_REALPATH - Set to ON to resolve symlinks for discovered libraries to assist with packaging. For example, the "system" component library may be resolved to @@ -179,9 +182,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}) @@ -227,24 +230,177 @@ Example to find Boost headers and some *static* (release only) libraries:: 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 +If Boost was built using the boost-cmake project or from Boost 1.70.0 on +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 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. #]=======================================================================] +# The FPHSA helper provides standard way of reporting final search results to +# the user including the version and component checks. +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + # Save project's policies cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST +function(_boost_get_existing_target component target_var) + set(names "${component}") + if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") + # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. + list(APPEND names + "${CMAKE_MATCH_1}${CMAKE_MATCH_2}" # python + "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}" # pythonX + "${CMAKE_MATCH_1}${CMAKE_MATCH_2}${CMAKE_MATCH_3}${CMAKE_MATCH_4}" #pythonXY + ) + endif() + # https://github.com/boost-cmake/boost-cmake uses boost::file_system etc. + # So handle similar constructions of target names + string(TOLOWER "${component}" lower_component) + list(APPEND names "${lower_component}") + foreach(prefix Boost boost) + foreach(name IN LISTS names) + if(TARGET "${prefix}::${name}") + set(${target_var} "${prefix}::${name}" PARENT_SCOPE) + return() + endif() + endforeach() + endforeach() + set(${target_var} "" PARENT_SCOPE) +endfunction() + +function(_boost_get_canonical_target_name component target_var) + string(TOLOWER "${component}" component) + if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$") + # handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc. + set(${target_var} "Boost::${CMAKE_MATCH_1}${CMAKE_MATCH_2}" PARENT_SCOPE) + else() + set(${target_var} "Boost::${component}" PARENT_SCOPE) + endif() +endfunction() + +macro(_boost_set_in_parent_scope name value) + # Set a variable in parent scope and make it visibile in current scope + set(${name} "${value}" PARENT_SCOPE) + set(${name} "${value}") +endmacro() + +macro(_boost_set_if_unset name value) + if(NOT ${name}) + _boost_set_in_parent_scope(${name} "${value}") + endif() +endmacro() + +macro(_boost_set_cache_if_unset name value) + if(NOT ${name}) + set(${name} "${value}" CACHE STRING "" FORCE) + endif() +endmacro() + +macro(_boost_append_include_dir target) + get_target_property(inc "${target}" INTERFACE_INCLUDE_DIRECTORIES) + if(inc) + list(APPEND include_dirs "${inc}") + endif() +endmacro() + +function(_boost_set_legacy_variables_from_config) + # Set legacy variables for compatibility if not set + set(include_dirs "") + set(library_dirs "") + set(libraries "") + # Header targets Boost::headers or Boost::boost + foreach(comp headers boost) + _boost_get_existing_target(${comp} target) + if(target) + _boost_append_include_dir("${target}") + endif() + endforeach() + # Library targets + foreach(comp IN LISTS Boost_FIND_COMPONENTS) + string(TOUPPER ${comp} uppercomp) + # Overwrite if set + _boost_set_in_parent_scope(Boost_${uppercomp}_FOUND "${Boost_${comp}_FOUND}") + if(Boost_${comp}_FOUND) + _boost_get_existing_target(${comp} target) + if(NOT target) + if(Boost_DEBUG OR Boost_VERBOSE) + message(WARNING "Could not find imported target for required component '${comp}'. Standard variables for this component might be missing. Refer to the documentation of your Boost installation for help on variables to use.") + endif() + continue() + endif() + _boost_append_include_dir("${target}") + _boost_set_if_unset(Boost_${uppercomp}_LIBRARY "${target}") + _boost_set_if_unset(Boost_${uppercomp}_LIBRARIES "${target}") # Very old legacy variable + list(APPEND libraries "${target}") + foreach(cfg RELEASE DEBUG) + get_target_property(lib ${target} IMPORTED_LOCATION_${cfg}) + if(lib) + get_filename_component(lib_dir "${lib}" DIRECTORY) + list(APPEND library_dirs ${lib_dir}) + _boost_set_cache_if_unset(Boost_${uppercomp}_LIBRARY_${cfg} "${lib}") + endif() + endforeach() + _boost_get_canonical_target_name("${comp}" canonical_target) + if(NOT TARGET "${canonical_target}") + add_library("${canonical_target}" INTERFACE IMPORTED) + target_link_libraries("${canonical_target}" INTERFACE "${target}") + endif() + endif() + endforeach() + list(REMOVE_DUPLICATES include_dirs) + list(REMOVE_DUPLICATES library_dirs) + _boost_set_if_unset(Boost_INCLUDE_DIRS "${include_dirs}") + _boost_set_if_unset(Boost_LIBRARY_DIRS "${library_dirs}") + _boost_set_if_unset(Boost_LIBRARIES "${libraries}") + _boost_set_if_unset(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}") + find_path(Boost_INCLUDE_DIR + NAMES boost/version.hpp boost/config.hpp + HINTS ${Boost_INCLUDE_DIRS} + NO_DEFAULT_PATH + ) + if(NOT Boost_VERSION_MACRO OR NOT Boost_LIB_VERSION) + set(version_file ${Boost_INCLUDE_DIR}/boost/version.hpp) + if(EXISTS "${version_file}") + file(STRINGS "${version_file}" contents REGEX "#define BOOST_(LIB_)?VERSION ") + if(contents MATCHES "#define BOOST_VERSION ([0-9]+)") + _boost_set_if_unset(Boost_VERSION_MACRO "${CMAKE_MATCH_1}") + endif() + if(contents MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") + _boost_set_if_unset(Boost_LIB_VERSION "${CMAKE_MATCH_1}") + endif() + endif() + endif() + _boost_set_if_unset(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR}) + _boost_set_if_unset(Boost_MINOR_VERSION ${Boost_VERSION_MINOR}) + _boost_set_if_unset(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH}) + if(WIN32) + _boost_set_if_unset(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC") + endif() + if(NOT TARGET Boost::headers) + add_library(Boost::headers INTERFACE IMPORTED) + target_include_directories(Boost::headers INTERFACE ${Boost_INCLUDE_DIRS}) + endif() + # Legacy targets w/o functionality as all handled by defined targets + foreach(lib diagnostic_definitions disable_autolinking dynamic_linking) + if(NOT TARGET Boost::${lib}) + add_library(Boost::${lib} INTERFACE IMPORTED) + endif() + endforeach() + if(NOT TARGET Boost::boost) + add_library(Boost::boost INTERFACE IMPORTED) + target_link_libraries(Boost::boost INTERFACE Boost::headers) + endif() +endfunction() + #------------------------------------------------------------------------------- -# Before we go searching, check whether boost-cmake is available, unless the -# user specifically asked NOT to search for boost-cmake. +# Before we go searching, check whether a boost cmake package is available, unless +# the user specifically asked NOT to search for one. # # If Boost_DIR is set, this behaves as any find_package call would. If not, # it looks at BOOST_ROOT and BOOSTROOT to find Boost. @@ -266,13 +422,28 @@ if (NOT Boost_NO_BOOST_CMAKE) find_package(Boost QUIET NO_MODULE) mark_as_advanced(Boost_DIR) - # If we found boost-cmake, then we're done. Print out what we found. + # If we found a boost cmake package, then we're done. Print out what we found. # Otherwise let the rest of the module try to find it. - if (Boost_FOUND) - message(STATUS "Boost ${Boost_FIND_VERSION} found.") - if (Boost_FIND_COMPONENTS) - message(STATUS "Found Boost components:\n ${Boost_FIND_COMPONENTS}") + if(Boost_FOUND) + # Convert component found variables to standard variables if required + # Necessary for legacy boost-cmake and 1.70 builtin BoostConfig + if(Boost_FIND_COMPONENTS) + foreach(_comp IN LISTS Boost_FIND_COMPONENTS) + if(DEFINED Boost_${_comp}_FOUND) + continue() + endif() + string(TOUPPER ${_comp} _uppercomp) + if(DEFINED Boost${_comp}_FOUND) # legacy boost-cmake project + set(Boost_${_comp}_FOUND ${Boost${_comp}_FOUND}) + elseif(DEFINED Boost_${_uppercomp}_FOUND) # Boost 1.70 + set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND}) + endif() + endforeach() endif() + + find_package_handle_standard_args(Boost HANDLE_COMPONENTS CONFIG_MODE) + _boost_set_legacy_variables_from_config() + # Restore project's policies cmake_policy(POP) return() @@ -284,6 +455,56 @@ endif() # FindBoost functions & macros # +# +# Print debug text if Boost_DEBUG is set. +# Call example: +# _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "debug message") +# +function(_Boost_DEBUG_PRINT file line text) + if(Boost_DEBUG) + message(STATUS "[ ${file}:${line} ] ${text}") + endif() +endfunction() + +# +# _Boost_DEBUG_PRINT_VAR(file line variable_name [ENVIRONMENT] +# [SOURCE "short explanation of origin of var value"]) +# +# ENVIRONMENT - look up environment variable instead of CMake variable +# +# Print variable name and its value if Boost_DEBUG is set. +# Call example: +# _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" BOOST_ROOT) +# +function(_Boost_DEBUG_PRINT_VAR file line name) + if(Boost_DEBUG) + cmake_parse_arguments(_args "ENVIRONMENT" "SOURCE" "" ${ARGN}) + + unset(source) + if(_args_SOURCE) + set(source " (${_args_SOURCE})") + endif() + + if(_args_ENVIRONMENT) + if(DEFINED ENV{${name}}) + set(value "\"$ENV{${name}}\"") + else() + set(value "") + endif() + set(_name "ENV{${name}}") + else() + if(DEFINED "${name}") + set(value "\"${${name}}\"") + else() + set(value "") + endif() + set(_name "${name}") + endif() + + _Boost_DEBUG_PRINT("${file}" "${line}" "${_name} = ${value}${source}") + endif() +endfunction() + ############################################ # # Check the existence of the libraries. @@ -401,11 +622,10 @@ macro(_Boost_FIND_LIBRARY var build_type) # If Boost_LIBRARY_DIR_[RELEASE,DEBUG] is known then search only there. if(Boost_LIBRARY_DIR_${build_type}) set(_boost_LIBRARY_SEARCH_DIRS_${build_type} ${Boost_LIBRARY_DIR_${build_type}} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " Boost_LIBRARY_DIR_${build_type} = ${Boost_LIBRARY_DIR_${build_type}}" - " _boost_LIBRARY_SEARCH_DIRS_${build_type} = ${_boost_LIBRARY_SEARCH_DIRS_${build_type}}") - endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "Boost_LIBRARY_DIR_${build_type}") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "_boost_LIBRARY_SEARCH_DIRS_${build_type}") endif() endmacro() @@ -465,7 +685,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 +706,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") @@ -493,7 +719,7 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "XL") set(_boost_COMPILER "-xlc") elseif (MINGW) - if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) + if(Boost_VERSION_STRING VERSION_LESS 1.34) set(_boost_COMPILER "-mgw") # no GCC version encoding prior to 1.34 else() _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) @@ -501,7 +727,7 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) endif() elseif (UNIX) _Boost_COMPILER_DUMPVERSION(_boost_COMPILER_VERSION _boost_COMPILER_VERSION_MAJOR _boost_COMPILER_VERSION_MINOR) - if(NOT Boost_VERSION VERSION_LESS 106900) + if(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0) # From GCC 5 and clang 4, versioning changes and minor becomes patch. # For those compilers, patch is exclude from compiler tag in Boost 1.69+ library naming. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND _boost_COMPILER_VERSION_MAJOR VERSION_GREATER 4) @@ -512,25 +738,19 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.34) + if(Boost_VERSION_STRING VERSION_LESS 1.34) set(_boost_COMPILER "-gcc") # no GCC version encoding prior to 1.34 else() # Determine which version of GCC we have. if(APPLE) - if(Boost_MINOR_VERSION) - if(${Boost_MINOR_VERSION} GREATER 35) - # In Boost 1.36.0 and newer, the mangled compiler name used - # on macOS/Darwin is "xgcc". - set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") - else() - # In Boost <= 1.35.0, there is no mangled compiler name for - # the macOS/Darwin version of GCC. - set(_boost_COMPILER "") - endif() - else() - # We don't know the Boost version, so assume it's - # pre-1.36.0. + if(Boost_VERSION_STRING VERSION_LESS 1.36.0) + # In Boost <= 1.35.0, there is no mangled compiler name for + # the macOS/Darwin version of GCC. set(_boost_COMPILER "") + else() + # In Boost 1.36.0 and newer, the mangled compiler name used + # on macOS/Darwin is "xgcc". + set(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") endif() else() set(_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") @@ -541,9 +761,10 @@ function(_Boost_GUESS_COMPILER_PREFIX _ret) set(_boost_COMPILER "-clang${_boost_COMPILER_VERSION}") endif() else() - # TODO at least Boost_DEBUG here? set(_boost_COMPILER "") endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "_boost_COMPILER" SOURCE "guessed") set(${_ret} ${_boost_COMPILER} PARENT_SCOPE) endfunction() @@ -581,15 +802,14 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) # - Indent # s;^set(; set(;; # - Add conditionals - # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION VERSION_LESS \10\20\3 AND Boost_VERSION VERSION_LESS xxxx); + # s;Scanning /path/to/boost/sources/boost_\(.*\)_\(.*\)_\(.*); elseif(NOT Boost_VERSION_STRING VERSION_LESS \1\.\2\.\3 AND Boost_VERSION_STRING VERSION_LESS xxxx); # # This results in the logic seen below, but will require the xxxx # replacing with the following Boost release version (or the next # minor version to be released, e.g. 1.59 was the latest at the time - # of writing, making 1.60 the next, so 106000 is the needed version - # number). Identical consecutive releases were then merged together - # by updating the end range of the first block and removing the - # following redundant blocks. + # of writing, making 1.60 the next. Identical consecutive releases + # were then merged together by updating the end range of the first + # block and removing the following redundant blocks. # # Running the script against all historical releases should be # required only if the BoostScanDeps.cmake script logic is changed. @@ -603,22 +823,22 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) endif() set(_Boost_IMPORTED_TARGETS TRUE) - if(Boost_VERSION AND Boost_VERSION VERSION_LESS 103300) - message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION} (all versions older than 1.33)") + if(Boost_VERSION_STRING AND Boost_VERSION_STRING VERSION_LESS 1.33.0) + message(WARNING "Imported targets and dependency information not available for Boost version ${Boost_VERSION_STRING} (all versions older than 1.33)") set(_Boost_IMPORTED_TARGETS FALSE) - elseif(NOT Boost_VERSION VERSION_LESS 103300 AND Boost_VERSION VERSION_LESS 103500) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.33.0 AND Boost_VERSION_STRING VERSION_LESS 1.35.0) set(_Boost_IOSTREAMS_DEPENDENCIES regex thread) set(_Boost_REGEX_DEPENDENCIES thread) set(_Boost_WAVE_DEPENDENCIES filesystem thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 103500 AND Boost_VERSION VERSION_LESS 103600) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.35.0 AND Boost_VERSION_STRING VERSION_LESS 1.36.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MPI_DEPENDENCIES serialization) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 103600 AND Boost_VERSION VERSION_LESS 103800) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.36.0 AND Boost_VERSION_STRING VERSION_LESS 1.38.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) @@ -626,7 +846,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization) set(_Boost_WAVE_DEPENDENCIES filesystem system thread) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 103800 AND Boost_VERSION VERSION_LESS 104300) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.38.0 AND Boost_VERSION_STRING VERSION_LESS 1.43.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l) @@ -635,7 +855,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 104300 AND Boost_VERSION VERSION_LESS 104400) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.43.0 AND Boost_VERSION_STRING VERSION_LESS 1.44.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) @@ -644,7 +864,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 104400 AND Boost_VERSION VERSION_LESS 104500) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.44.0 AND Boost_VERSION_STRING VERSION_LESS 1.45.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random serialization) @@ -653,7 +873,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES serialization filesystem system thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 104500 AND Boost_VERSION VERSION_LESS 104700) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.45.0 AND Boost_VERSION_STRING VERSION_LESS 1.47.0) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l random) @@ -662,7 +882,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 104700 AND Boost_VERSION VERSION_LESS 104800) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.47.0 AND Boost_VERSION_STRING VERSION_LESS 1.48.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) @@ -672,7 +892,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES date_time) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 104800 AND Boost_VERSION VERSION_LESS 105000) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.48.0 AND Boost_VERSION_STRING VERSION_LESS 1.50.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) @@ -683,7 +903,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105000 AND Boost_VERSION VERSION_LESS 105300) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.50.0 AND Boost_VERSION_STRING VERSION_LESS 1.53.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) set(_Boost_IOSTREAMS_DEPENDENCIES regex) @@ -694,7 +914,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105300 AND Boost_VERSION VERSION_LESS 105400) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.53.0 AND Boost_VERSION_STRING VERSION_LESS 1.54.0) set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -706,7 +926,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105400 AND Boost_VERSION VERSION_LESS 105500) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.54.0 AND Boost_VERSION_STRING VERSION_LESS 1.55.0) set(_Boost_ATOMIC_DEPENDENCIES thread chrono system date_time) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -719,7 +939,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105500 AND Boost_VERSION VERSION_LESS 105600) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.55.0 AND Boost_VERSION_STRING VERSION_LESS 1.56.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -732,7 +952,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105600 AND Boost_VERSION VERSION_LESS 105900) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.56.0 AND Boost_VERSION_STRING VERSION_LESS 1.59.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -746,7 +966,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 105900 AND Boost_VERSION VERSION_LESS 106000) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.59.0 AND Boost_VERSION_STRING VERSION_LESS 1.60.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -760,7 +980,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106000 AND Boost_VERSION VERSION_LESS 106100) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.60.0 AND Boost_VERSION_STRING VERSION_LESS 1.61.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_COROUTINE_DEPENDENCIES context system) set(_Boost_FILESYSTEM_DEPENDENCIES system) @@ -774,7 +994,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106100 AND Boost_VERSION VERSION_LESS 106200) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.61.0 AND Boost_VERSION_STRING VERSION_LESS 1.62.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) @@ -788,7 +1008,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106200 AND Boost_VERSION VERSION_LESS 106300) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.62.0 AND Boost_VERSION_STRING VERSION_LESS 1.63.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) @@ -803,7 +1023,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106300 AND Boost_VERSION VERSION_LESS 106500) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.63.0 AND Boost_VERSION_STRING VERSION_LESS 1.65.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) @@ -819,7 +1039,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono system date_time atomic) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106500 AND Boost_VERSION VERSION_LESS 106700) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.65.0 AND Boost_VERSION_STRING VERSION_LESS 1.67.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) @@ -836,7 +1056,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106700 AND Boost_VERSION VERSION_LESS 106800) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.67.0 AND Boost_VERSION_STRING VERSION_LESS 1.68.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_COROUTINE_DEPENDENCIES context system) @@ -853,7 +1073,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106800 AND Boost_VERSION VERSION_LESS 106900) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.68.0 AND Boost_VERSION_STRING VERSION_LESS 1.69.0) set(_Boost_CHRONO_DEPENDENCIES system) set(_Boost_CONTEXT_DEPENDENCIES thread chrono system date_time) set(_Boost_CONTRACT_DEPENDENCIES thread chrono system date_time) @@ -871,7 +1091,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_TIMER_DEPENDENCIES chrono system) set(_Boost_WAVE_DEPENDENCIES filesystem system serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - elseif(NOT Boost_VERSION VERSION_LESS 106900 AND Boost_VERSION VERSION_LESS 107000) + elseif(NOT Boost_VERSION_STRING VERSION_LESS 1.69.0 AND Boost_VERSION_STRING VERSION_LESS 1.70.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) @@ -886,7 +1106,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) else() - if(NOT Boost_VERSION VERSION_LESS 107000) + if(NOT Boost_VERSION_STRING VERSION_LESS 1.70.0) set(_Boost_CONTRACT_DEPENDENCIES thread chrono date_time) set(_Boost_COROUTINE_DEPENDENCIES context) set(_Boost_FIBER_DEPENDENCIES context) @@ -901,7 +1121,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) endif() - if(NOT Boost_VERSION VERSION_LESS 107100) + if(NOT Boost_VERSION_STRING VERSION_LESS 1.71.0) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -939,7 +1159,7 @@ function(_Boost_COMPONENT_HEADERS component _hdrs) set(_Boost_CHRONO_HEADERS "boost/chrono.hpp") set(_Boost_CONTAINER_HEADERS "boost/container/container_fwd.hpp") set(_Boost_CONTRACT_HEADERS "boost/contract.hpp") - if(Boost_VERSION VERSION_LESS 106100) + if(Boost_VERSION_STRING VERSION_LESS 1.61.0) set(_Boost_CONTEXT_HEADERS "boost/context/all.hpp") else() set(_Boost_CONTEXT_HEADERS "boost/context/detail/fcontext.hpp") @@ -1058,7 +1278,7 @@ endfunction() # function(_Boost_COMPILER_FEATURES component _ret) # Boost >= 1.62 - if(NOT Boost_VERSION VERSION_LESS 106200) + if(NOT Boost_VERSION_STRING VERSION_LESS 1.62.0) set(_Boost_FIBER_COMPILER_FEATURES cxx_alias_templates cxx_auto_type @@ -1204,26 +1424,12 @@ else() endif() endif() -# The reason that we failed to find Boost. This will be set to a -# user-friendly message when we fail to find some necessary piece of -# Boost. -set(Boost_ERROR_REASON) - -if(Boost_DEBUG) - # Output some of their choices - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_TEST_VERSIONS") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_MULTITHREADED") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_LIBS") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_USE_STATIC_RUNTIME") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_ADDITIONAL_VERSIONS") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NO_SYSTEM_PATHS") # Supply Boost_LIB_DIAGNOSTIC_DEFINITIONS as a convenience target. It # will only contain any interface definitions on WIN32, but is created @@ -1234,6 +1440,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 @@ -1258,11 +1466,13 @@ 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) +cmake_policy(GET CMP0074 _Boost_CMP0074) +if(NOT "x${_Boost_CMP0074}x" STREQUAL "xNEWx") + _Boost_CHECK_SPELLING(Boost_ROOT) +endif() +unset(_Boost_CMP0074) _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) @@ -1288,18 +1498,12 @@ set(_Boost_VARS_DIR Boost_NO_SYSTEM_PATHS ) -if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Declared as CMake or Environmental Variables:") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_ROOT = ${BOOST_ROOT}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_INCLUDEDIR = ${BOOST_INCLUDEDIR}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " BOOST_LIBRARYDIR = ${BOOST_LIBRARYDIR}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_ROOT" ENVIRONMENT) +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_INCLUDEDIR" ENVIRONMENT) +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "BOOST_LIBRARYDIR" ENVIRONMENT) # ------------------------------------------------------------------------ # Search for Boost include DIR @@ -1371,14 +1575,8 @@ if(NOT Boost_INCLUDE_DIR) endforeach() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Include debugging info:") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " _boost_INCLUDE_SEARCH_DIRS = ${_boost_INCLUDE_SEARCH_DIRS}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - " _boost_PATH_SUFFIXES = ${_boost_PATH_SUFFIXES}") - endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_INCLUDE_SEARCH_DIRS") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_PATH_SUFFIXES") # Look for a standard boost header file. find_path(Boost_INCLUDE_DIR @@ -1392,74 +1590,54 @@ endif() # Extract version information from version.hpp # ------------------------------------------------------------------------ -# Set Boost_FOUND based only on header location and version. -# It will be updated below for component libraries. if(Boost_INCLUDE_DIR) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") - endif() + _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "location of version.hpp: ${Boost_INCLUDE_DIR}/boost/version.hpp") - # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp - set(Boost_VERSION 0) + # Extract Boost_VERSION_MACRO and Boost_LIB_VERSION from version.hpp + set(Boost_VERSION_MACRO 0) set(Boost_LIB_VERSION "") file(STRINGS "${Boost_INCLUDE_DIR}/boost/version.hpp" _boost_VERSION_HPP_CONTENTS REGEX "#define BOOST_(LIB_)?VERSION ") - set(_Boost_VERSION_REGEX "([0-9]+)") - set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"") - foreach(v VERSION LIB_VERSION) - if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}") - set(Boost_${v} "${CMAKE_MATCH_1}") - endif() - endforeach() + if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_VERSION ([0-9]+)") + set(Boost_VERSION_MACRO "${CMAKE_MATCH_1}") + endif() + if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_LIB_VERSION \"([0-9_]+)\"") + set(Boost_LIB_VERSION "${CMAKE_MATCH_1}") + endif() unset(_boost_VERSION_HPP_CONTENTS) - math(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") - math(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") - math(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - set(Boost_VERSION_STRING "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + # Calculate version components + math(EXPR Boost_VERSION_MAJOR "${Boost_VERSION_MACRO} / 100000") + math(EXPR Boost_VERSION_MINOR "${Boost_VERSION_MACRO} / 100 % 1000") + math(EXPR Boost_VERSION_PATCH "${Boost_VERSION_MACRO} % 100") + set(Boost_VERSION_COUNT 3) - string(APPEND Boost_ERROR_REASON - "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "version.hpp reveals boost " - "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - endif() + # Define alias variables for backwards compat. + set(Boost_MAJOR_VERSION ${Boost_VERSION_MAJOR}) + set(Boost_MINOR_VERSION ${Boost_VERSION_MINOR}) + set(Boost_SUBMINOR_VERSION ${Boost_VERSION_PATCH}) - if(Boost_FIND_VERSION) - # Set Boost_FOUND based on requested version. - set(_Boost_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - if("${_Boost_VERSION}" VERSION_LESS "${Boost_FIND_VERSION}") - set(Boost_FOUND 0) - set(_Boost_VERSION_AGE "old") - elseif(Boost_FIND_VERSION_EXACT AND - NOT "${_Boost_VERSION}" VERSION_EQUAL "${Boost_FIND_VERSION}") - set(Boost_FOUND 0) - set(_Boost_VERSION_AGE "new") - else() - set(Boost_FOUND 1) - endif() - if(NOT Boost_FOUND) - # State that we found a version of Boost that is too new or too old. - string(APPEND Boost_ERROR_REASON - "\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") - if (Boost_FIND_VERSION_PATCH) - string(APPEND Boost_ERROR_REASON - ".${Boost_FIND_VERSION_PATCH}") - endif () - if (NOT Boost_FIND_VERSION_EXACT) - string(APPEND Boost_ERROR_REASON " (or newer)") - endif () - string(APPEND Boost_ERROR_REASON ".") - endif () + # Define Boost version in x.y.z format + set(Boost_VERSION_STRING "${Boost_VERSION_MAJOR}.${Boost_VERSION_MINOR}.${Boost_VERSION_PATCH}") + + # Define final Boost_VERSION + cmake_policy(GET CMP0093 _Boost_CMP0093 + PARENT_SCOPE # undocumented, do not use outside of CMake + ) + if("x${_Boost_CMP0093}x" STREQUAL "xNEWx") + set(Boost_VERSION ${Boost_VERSION_STRING}) else() - # Caller will accept any Boost version. - set(Boost_FOUND 1) + set(Boost_VERSION ${Boost_VERSION_MACRO}) endif() -else() - set(Boost_FOUND 0) - string(APPEND Boost_ERROR_REASON - "Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") + unset(_Boost_CMP0093) + + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_STRING") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MACRO") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MAJOR") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_MINOR") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_PATCH") + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_VERSION_COUNT") endif() # ------------------------------------------------------------------------ @@ -1476,12 +1654,8 @@ if ( NOT Boost_NAMESPACE ) set(Boost_NAMESPACE "boost") endif() -if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_LIB_PREFIX = ${Boost_LIB_PREFIX}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Boost_NAMESPACE = ${Boost_NAMESPACE}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_LIB_PREFIX") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "Boost_NAMESPACE") # ------------------------------------------------------------------------ # Suffix initialization and compiler suffix detection. @@ -1503,30 +1677,21 @@ _Boost_CHANGE_DETECT(_Boost_CHANGE_LIBNAME ${_Boost_VARS_NAME}) # Setting some more suffixes for the library if (Boost_COMPILER) set(_boost_COMPILER ${Boost_COMPILER}) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "using user-specified Boost_COMPILER = ${_boost_COMPILER}") - endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "_boost_COMPILER" SOURCE "user-specified via Boost_COMPILER") else() # Attempt to guess the compiler suffix # NOTE: this is not perfect yet, if you experience any issues # please report them and use the Boost_COMPILER variable # to work around the problems. _Boost_GUESS_COMPILER_PREFIX(_boost_COMPILER) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "guessed _boost_COMPILER = ${_boost_COMPILER}") - endif() endif() set (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() -if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_MULTITHREADED") #====================== # Systematically build up the Boost ABI tag for the 'tagged' and 'versioned' layouts @@ -1577,14 +1742,12 @@ endif() # Only used in 'versioned' layout, added in Boost 1.66.0 if(DEFINED Boost_ARCHITECTURE) set(_boost_ARCHITECTURE_TAG "${Boost_ARCHITECTURE}") - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "using user-specified Boost_ARCHITECTURE = ${_boost_ARCHITECTURE_TAG}") - endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "_boost_ARCHITECTURE_TAG" SOURCE "user-specified via Boost_ARCHITECTURE") else() set(_boost_ARCHITECTURE_TAG "") # {CMAKE_CXX_COMPILER_ARCHITECTURE_ID} is not currently set for all compilers - if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION VERSION_LESS 106600) + if(NOT "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x" AND NOT Boost_VERSION_STRING VERSION_LESS 1.66.0) string(APPEND _boost_ARCHITECTURE_TAG "-") # This needs to be kept in-sync with the section of CMakePlatformId.h.in # inside 'defined(_WIN32) && defined(_MSC_VER)' @@ -1605,14 +1768,12 @@ else() string(APPEND _boost_ARCHITECTURE_TAG "32") endif() endif() + _Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "_boost_ARCHITECTURE_TAG" SOURCE "detected") endif() -if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_RELEASE_ABI_TAG") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_DEBUG_ABI_TAG") # ------------------------------------------------------------------------ # Begin finding boost libraries @@ -1672,11 +1833,8 @@ foreach(c DEBUG RELEASE) endif() endforeach() -if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_LIBRARY_SEARCH_DIRS_RELEASE = ${_boost_LIBRARY_SEARCH_DIRS_RELEASE}" - "_boost_LIBRARY_SEARCH_DIRS_DEBUG = ${_boost_LIBRARY_SEARCH_DIRS_DEBUG}") -endif() +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_RELEASE") +_Boost_DEBUG_PRINT_VAR("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" "_boost_LIBRARY_SEARCH_DIRS_DEBUG") # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES if( Boost_USE_STATIC_LIBS ) @@ -1716,10 +1874,10 @@ endif() # On versions < 1.35, remove the System library from the considered list # since it wasn't added until 1.35. -if(Boost_VERSION AND Boost_FIND_COMPONENTS) - if(Boost_VERSION LESS 103500) - list(REMOVE_ITEM Boost_FIND_COMPONENTS system) - endif() +if(Boost_VERSION_STRING AND Boost_FIND_COMPONENTS) + if(Boost_VERSION_STRING VERSION_LESS 1.35.0) + list(REMOVE_ITEM Boost_FIND_COMPONENTS system) + endif() endif() # Additional components may be required via component dependencies. @@ -1801,19 +1959,13 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) # Consolidate and report component-specific hints. if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME) list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Component-specific library search names for ${COMPONENT_NAME}: " - "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME}") - endif() + _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "Component-specific library search names for ${COMPONENT_NAME}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT_NAME}") endif() if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT) list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT) - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Component-specific library search paths for ${COMPONENT}: " - "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}") - endif() + _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "Component-specific library search paths for ${COMPONENT}: ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}") endif() # @@ -1866,10 +2018,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") - endif() + _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") # if Boost_LIBRARY_DIR_RELEASE is not defined, # but Boost_LIBRARY_DIR_DEBUG is, look there first for RELEASE libs @@ -1923,10 +2073,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) endif() - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") - endif() + _Boost_DEBUG_PRINT("${CMAKE_CURRENT_LIST_FILE}" "${CMAKE_CURRENT_LIST_LINE}" + "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") # if Boost_LIBRARY_DIR_DEBUG is not defined, # but Boost_LIBRARY_DIR_RELEASE is, look there first for DEBUG libs @@ -1979,57 +2127,25 @@ if(Boost_LIBRARY_DIRS) list(REMOVE_DUPLICATES Boost_LIBRARY_DIRS) endif() -# The above setting of Boost_FOUND was based only on the header files. -# Update it for the requested component libraries. -if(Boost_FOUND) - # The headers were found. Check for requested component libs. - set(_boost_CHECKED_COMPONENT FALSE) - set(_Boost_MISSING_COMPONENTS "") - foreach(COMPONENT ${Boost_FIND_COMPONENTS}) - string(TOUPPER ${COMPONENT} UPPERCOMPONENT) - set(_boost_CHECKED_COMPONENT TRUE) - if(NOT Boost_${UPPERCOMPONENT}_FOUND AND Boost_FIND_REQUIRED_${COMPONENT}) - list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) - endif() - endforeach() - if(_Boost_MISSING_COMPONENTS AND _Boost_EXTRA_FIND_COMPONENTS) - # Optional indirect dependencies are not counted as missing. - list(REMOVE_ITEM _Boost_MISSING_COMPONENTS ${_Boost_EXTRA_FIND_COMPONENTS}) - endif() +# ------------------------------------------------------------------------ +# Call FPHSA helper, see https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html +# ------------------------------------------------------------------------ - if(Boost_DEBUG) - message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] Boost_FOUND = ${Boost_FOUND}") +# Define aliases as needed by the component handler in the FPHSA helper below +foreach(_comp IN LISTS Boost_FIND_COMPONENTS) + string(TOUPPER ${_comp} _uppercomp) + if(DEFINED Boost_${_uppercomp}_FOUND) + set(Boost_${_comp}_FOUND ${Boost_${_uppercomp}_FOUND}) endif() +endforeach() - if (_Boost_MISSING_COMPONENTS) - set(Boost_FOUND 0) - # We were unable to find some libraries, so generate a sensible - # error message that lists the libraries we were unable to find. - string(APPEND Boost_ERROR_REASON - "\nCould not find the following") - if(Boost_USE_STATIC_LIBS) - string(APPEND Boost_ERROR_REASON " static") - endif() - string(APPEND Boost_ERROR_REASON - " Boost libraries:\n") - foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) - string(TOUPPER ${COMPONENT} UPPERCOMPONENT) - string(APPEND Boost_ERROR_REASON - " ${Boost_NAMESPACE}_${COMPONENT}${Boost_ERROR_REASON_${UPPERCOMPONENT}}\n") - endforeach() - - list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) - list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) - if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) - string(APPEND Boost_ERROR_REASON - "No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") - else () - string(APPEND Boost_ERROR_REASON - "Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") - endif () - endif () +find_package_handle_standard_args(Boost + REQUIRED_VARS Boost_INCLUDE_DIR + VERSION_VAR Boost_VERSION_STRING + HANDLE_COMPONENTS) - if( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) +if(Boost_FOUND) + if( NOT Boost_LIBRARY_DIRS ) # Compatibility Code for backwards compatibility with CMake # 2.4's FindBoost module. @@ -2073,15 +2189,24 @@ endif() # ------------------------------------------------------------------------ if(Boost_FOUND) - # For header-only libraries - if(NOT TARGET Boost::boost) - add_library(Boost::boost INTERFACE IMPORTED) + # The builtin CMake package in Boost 1.70+ introduces a new name + # for the header-only lib, let's provide the same UI in module mode + if(NOT TARGET Boost::headers) + add_library(Boost::headers INTERFACE IMPORTED) if(Boost_INCLUDE_DIRS) - set_target_properties(Boost::boost PROPERTIES + set_target_properties(Boost::headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}") endif() endif() + # Define the old target name for header-only libraries for backwards + # compat. + if(NOT TARGET Boost::boost) + add_library(Boost::boost INTERFACE IMPORTED) + set_target_properties(Boost::boost + PROPERTIES INTERFACE_LINK_LIBRARIES Boost::headers) + endif() + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) if(_Boost_IMPORTED_TARGETS AND NOT TARGET Boost::${COMPONENT}) string(TOUPPER ${COMPONENT} UPPERCOMPONENT) @@ -2137,46 +2262,20 @@ if(Boost_FOUND) endif() # ------------------------------------------------------------------------ -# Notification to end user about what was found +# Finalize # ------------------------------------------------------------------------ +# Report Boost_LIBRARIES set(Boost_LIBRARIES "") -if(Boost_FOUND) - if(NOT Boost_FIND_QUIETLY) - message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - if(Boost_FIND_COMPONENTS) - message(STATUS "Found the following Boost libraries:") - endif() - endif() - foreach( COMPONENT ${Boost_FIND_COMPONENTS} ) - string( TOUPPER ${COMPONENT} UPPERCOMPONENT ) - if( Boost_${UPPERCOMPONENT}_FOUND ) - if(NOT Boost_FIND_QUIETLY) - message (STATUS " ${COMPONENT}") - endif() - list(APPEND Boost_LIBRARIES ${Boost_${UPPERCOMPONENT}_LIBRARY}) - if(COMPONENT STREQUAL "thread") - list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) - endif() - endif() - endforeach() -else() - if(Boost_FIND_REQUIRED) - message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") - else() - if(NOT Boost_FIND_QUIETLY) - # we opt not to automatically output Boost_ERROR_REASON here as - # it could be quite lengthy and somewhat imposing in its requests - # Since Boost is not always a required dependency we'll leave this - # up to the end-user. - if(Boost_DEBUG OR Boost_DETAILED_FAILURE_MSG) - message(STATUS "Could NOT find Boost\n${Boost_ERROR_REASON}") - else() - message(STATUS "Could NOT find Boost") - endif() +foreach(_comp IN LISTS Boost_FIND_COMPONENTS) + string(TOUPPER ${_comp} _uppercomp) + if(Boost_${_uppercomp}_FOUND) + list(APPEND Boost_LIBRARIES ${Boost_${_uppercomp}_LIBRARY}) + if(_comp STREQUAL "thread") + list(APPEND Boost_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) endif() endif() -endif() +endforeach() # Configure display of cache entries in GUI. foreach(v BOOSTROOT BOOST_ROOT ${_Boost_VARS_INC} ${_Boost_VARS_LIB}) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index a3c9fc6d1..6d6418521 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -52,12 +52,12 @@ macro(_FIND_BULLET_LIBRARY _var) endmacro() macro(_BULLET_APPEND_LIBRARIES _list _release) - set(_debug ${_release}_DEBUG) - if(${_debug}) - set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) - else() - set(${_list} ${${_list}} ${${_release}}) - endif() + set(_debug ${_release}_DEBUG) + if(${_debug}) + set(${_list} ${${_list}} optimized ${${_release}} debug ${${_debug}}) + else() + set(${_list} ${${_list}} ${${_release}}) + endif() endmacro() find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 228eed4f7..33155059a 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -538,7 +538,7 @@ if(DEFINED ENV{CUDAHOSTCXX}) elseif(CMAKE_GENERATOR MATCHES "Visual Studio") set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)") if(MSVC_VERSION LESS 1910) - set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") + set(_CUDA_MSVC_HOST_COMPILER "$(VCInstallDir)bin") endif() set(CUDA_HOST_COMPILER "${_CUDA_MSVC_HOST_COMPILER}" CACHE FILEPATH "Host side compiler used by NVCC") diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index b1989b10e..aeebc842e 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 89dbc0e10..f81980039 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 10ce22968..4e8232d07 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/FindCurses.cmake b/Modules/FindCurses.cmake index c22584782..b3cd8fa49 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -141,7 +141,7 @@ if(CURSES_USE_NCURSES) NAMES ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h HINTS "${_cursesParentDir}/include" ) - endif() + endif() # Previous versions of FindCurses provided these values. if(NOT DEFINED CURSES_LIBRARY) diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 4eec5fcec..3fc0e938a 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 @@ -194,7 +194,7 @@ endmacro() # main() #============================================================= if(NOT DEFINED CXXTEST_TESTGEN_ARGS) - set(CXXTEST_TESTGEN_ARGS --error-printer) + set(CXXTEST_TESTGEN_ARGS --error-printer) endif() find_package(Python QUIET) @@ -208,40 +208,40 @@ find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl PATHS ${CXXTEST_INCLUDE_DIR}) if(PYTHON_FOUND OR PERL_FOUND) - include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) - - if(PYTHON_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND OR NOT DEFINED CXXTEST_USE_PYTHON)) - set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE}) - execute_process(COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --version - OUTPUT_VARIABLE _CXXTEST_OUT ERROR_VARIABLE _CXXTEST_OUT RESULT_VARIABLE _CXXTEST_RESULT) - if(_CXXTEST_RESULT EQUAL 0) - set(CXXTEST_TESTGEN_INTERPRETER "") - else() - set(CXXTEST_TESTGEN_INTERPRETER ${Python_EXECUTABLE}) - endif() - FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG - CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE) - - elseif(PERL_FOUND) - set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PERL_TESTGEN_EXECUTABLE}) - set(CXXTEST_TESTGEN_INTERPRETER ${PERL_EXECUTABLE}) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG - CXXTEST_INCLUDE_DIR CXXTEST_PERL_TESTGEN_EXECUTABLE) - endif() - - if(CXXTEST_FOUND) - set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR}) - endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + + if(PYTHON_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND OR NOT DEFINED CXXTEST_USE_PYTHON)) + set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE}) + execute_process(COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --version + OUTPUT_VARIABLE _CXXTEST_OUT ERROR_VARIABLE _CXXTEST_OUT RESULT_VARIABLE _CXXTEST_RESULT) + if(_CXXTEST_RESULT EQUAL 0) + set(CXXTEST_TESTGEN_INTERPRETER "") + else() + set(CXXTEST_TESTGEN_INTERPRETER ${Python_EXECUTABLE}) + endif() + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG + CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE) + + elseif(PERL_FOUND) + set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PERL_TESTGEN_EXECUTABLE}) + set(CXXTEST_TESTGEN_INTERPRETER ${PERL_EXECUTABLE}) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG + CXXTEST_INCLUDE_DIR CXXTEST_PERL_TESTGEN_EXECUTABLE) + endif() + + if(CXXTEST_FOUND) + set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR}) + endif() else() - set(CXXTEST_FOUND false) - if(NOT CxxTest_FIND_QUIETLY) - if(CxxTest_FIND_REQUIRED) - message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!") - else() - message(STATUS "Neither Python nor Perl found, CxxTest will not be used.") - endif() - endif() + set(CXXTEST_FOUND false) + if(NOT CxxTest_FIND_QUIETLY) + if(CxxTest_FIND_REQUIRED) + message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!") + else() + message(STATUS "Neither Python nor Perl found, CxxTest will not be used.") + endif() + endif() endif() diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake index 8811623a2..5bbc802a0 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 111e0ff2f..d48de0896 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/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 32b4aa2c8..ebd0b24ab 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -974,7 +974,7 @@ doxygen_add_docs() for target ${targetName}") "${DOXYGEN_OUTPUT_DIRECTORY}/${DOXYGEN_HTML_OUTPUT}") endif() set_property(DIRECTORY APPEND PROPERTY - ADDITIONAL_MAKE_CLEAN_FILES "${_args_clean_html_dir}") + ADDITIONAL_CLEAN_FILES "${_args_clean_html_dir}") endif() # Build up a list of files we can identify from the inputs so we can list diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 58e08418c..15b419a61 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 000000000..4dd5116cd --- /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 -S``). It can +also be used in a :ref:`CMake Script