diff options
Diffstat (limited to 'Modules')
41 files changed, 931 insertions, 441 deletions
diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index b8e09fe..858c053 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -10,6 +10,7 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1) set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_VERSION "@_CMAKE_ASM_COMPILER_VERSION@") set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@") +@_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH@ @_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID@ set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 4a615a3..14a39a9 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -54,4 +54,5 @@ set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@ set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_LINKER "@CMAKE_LINKER@") +set(CMAKE_AR "@CMAKE_AR@") set(CMAKE_MT "@CMAKE_MT@") diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 974f5fa..f31713e 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -138,24 +138,24 @@ endif() #Specify how to compile when ptx has been requested if(NOT CMAKE_CUDA_COMPILE_PTX_COMPILATION) set(CMAKE_CUDA_COMPILE_PTX_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -ptx <SOURCE> -o <OBJECT>") endif() #Specify how to compile when separable compilation has been requested if(NOT CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION) set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -dc <SOURCE> -o <OBJECT>") endif() #Specify how to compile when whole compilation has been requested if(NOT CMAKE_CUDA_COMPILE_WHOLE_COMPILATION) set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT>") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -c <SOURCE> -o <OBJECT>") endif() -if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_DEPFILE_FLAGS_CUDA ) +if(CMAKE_GENERATOR STREQUAL "Ninja" AND NOT CMAKE_DEPFILE_FLAGS_CUDA) set(CMAKE_CUDA_COMPILE_DEPENDENCY_DETECTION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -M <SOURCE> -MT <OBJECT> -o $DEP_FILE") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -M <SOURCE> -MT <OBJECT> -o $DEP_FILE") #The Ninja generator uses the make file dependency files to determine what #files need to be recompiled. Unfortunately, nvcc < 10.2 doesn't support building #a source file and generating the dependencies of said file in a single diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index e47f3a4..86fb057 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -211,6 +211,13 @@ foreach(_var set(_CMAKE_ASM_${_var} "${CMAKE_ASM${ASM_DIALECT}_${_var}}") endforeach() +if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH) + set(_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH + "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH [==[${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH}]==])") +else() + set(_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH "") +endif() + if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID) set(_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID})") diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 7d7fb9a..62ea686 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -86,7 +86,7 @@ if(${CMAKE_GENERATOR} MATCHES "Visual Studio") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES "") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES "") set(CMAKE_CUDA_HOST_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") -elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA) +elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") set(_nvcc_log "") string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") if(_nvcc_output_orig MATCHES "#\\\$ +PATH= *([^\n]*)\n") @@ -188,30 +188,33 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL NVIDIA) endif() endif() -set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES ) -string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") -if(_nvcc_output_orig MATCHES "#\\\$ +INCLUDES= *([^\n]*)\n") - set(_nvcc_includes "${CMAKE_MATCH_1}") - string(APPEND _nvcc_log " found 'INCLUDES=' string: [${_nvcc_includes}]\n") -else() - set(_nvcc_includes "") - string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}") - string(APPEND _nvcc_log " no 'INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n") -endif() -if(_nvcc_includes) - # across all operating system each include directory is prefixed with -I - separate_arguments(_nvcc_output NATIVE_COMMAND "${_nvcc_includes}") - foreach(line IN LISTS _nvcc_output) - string(REGEX REPLACE "^-I" "" line "${line}") - get_filename_component(line "${line}" ABSOLUTE) - list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}") - endforeach() - - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n") -else() - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n") +# Determine CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES +if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES) + string(REPLACE "\r" "" _nvcc_output_orig "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") + if(_nvcc_output_orig MATCHES "#\\\$ +INCLUDES= *([^\n]*)\n") + set(_nvcc_includes "${CMAKE_MATCH_1}") + string(APPEND _nvcc_log " found 'INCLUDES=' string: [${_nvcc_includes}]\n") + else() + set(_nvcc_includes "") + string(REPLACE "\n" "\n " _nvcc_output_log "\n${_nvcc_output_orig}") + string(APPEND _nvcc_log " no 'INCLUDES=' string found in nvcc output:${_nvcc_output_log}\n") + endif() + if(_nvcc_includes) + # across all operating system each include directory is prefixed with -I + separate_arguments(_nvcc_output NATIVE_COMMAND "${_nvcc_includes}") + foreach(line IN LISTS _nvcc_output) + string(REGEX REPLACE "^-I" "" line "${line}") + get_filename_component(line "${line}" ABSOLUTE) + list(APPEND CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "${line}") + endforeach() + + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Parsed CUDA nvcc include information from above output:\n${_nvcc_log}\n${log}\n\n") + else() + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n") + endif() endif() # configure all variables set in this file diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d125791..812f032 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -868,6 +868,14 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags) file(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) endif() + # Save the current LC_ALL, LC_MESSAGES, and LANG environment variables + # and set them to "C" so we get the expected output to match. + set(_orig_lc_all $ENV{LC_ALL}) + set(_orig_lc_messages $ENV{LC_MESSAGES}) + set(_orig_lang $ENV{LANG}) + set(ENV{LC_ALL} C) + set(ENV{LC_MESSAGES} C) + set(ENV{LANG} C) foreach(vendor ${CMAKE_${lang}_COMPILER_ID_VENDORS}) set(flags ${CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor}}) @@ -889,6 +897,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags) "matched \"${regex}\":\n${output}") set(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_ID_OUTPUT "${output}" PARENT_SCOPE) + set(CMAKE_${lang}_COMPILER_ID_VENDOR_MATCH "${CMAKE_MATCH_1}" PARENT_SCOPE) break() else() if("${result}" MATCHES "timeout") @@ -902,6 +911,11 @@ function(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang userflags) endif() endif() endforeach() + + # Restore original LC_ALL, LC_MESSAGES, and LANG + set(ENV{LC_ALL} ${_orig_lc_all}) + set(ENV{LC_MESSAGES} ${_orig_lc_messages}) + set(ENV{LANG} ${_orig_lang}) endfunction() function(CMAKE_DETERMINE_MSVC_SHOWINCLUDES_PREFIX lang userflags) diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index c23e447..de9ef9a 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -75,6 +75,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND endif() find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_AR NAMES lib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS LINKER MT) diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake index 06c05fb..8906f48 100644 --- a/Modules/CMakeFindFrameworks.cmake +++ b/Modules/CMakeFindFrameworks.cmake @@ -17,13 +17,25 @@ if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) macro(CMAKE_FIND_FRAMEWORKS fwk) set(${fwk}_FRAMEWORKS) if(APPLE) - foreach(dir - ~/Library/Frameworks/${fwk}.framework - /usr/local/Frameworks/${fwk}.framework - /Library/Frameworks/${fwk}.framework - /System/Library/Frameworks/${fwk}.framework - /Network/Library/Frameworks/${fwk}.framework - ${CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS}) + file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _cmff_CMAKE_FRAMEWORK_PATH) + set(_cmff_search_paths + ${CMAKE_FRAMEWORK_PATH} + ${_cmff_CMAKE_FRAMEWORK_PATH} + ~/Library/Frameworks + /usr/local/Frameworks + /Library/Frameworks + /System/Library/Frameworks + /Network/Library/Frameworks + ${CMAKE_SYSTEM_FRAMEWORK_PATH}) + + # For backwards compatibility reasons, + # CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS includes ${fwk}.framework + list(TRANSFORM _cmff_search_paths APPEND /${fwk}.framework) + list(APPEND _cmff_search_paths ${CMAKE_FIND_FRAMEWORK_EXTRA_LOCATIONS}) + + list(REMOVE_DUPLICATES _cmff_search_paths) + + foreach(dir IN LISTS _cmff_search_paths) if(EXISTS ${dir}) set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir}) endif() diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index baf7e47..6234b9d 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -5,7 +5,7 @@ CPack ----- -Configure the binary and source package installers. +Configure generators for binary installers and source packages. Introduction ^^^^^^^^^^^^ @@ -19,13 +19,17 @@ Depending on the CMake generator, the CPack module may also add two new build targets, ``package`` and ``package_source``. See the `packaging targets`_ section below for details. -The generated binary installers contain everything installed via CMake's -:command:`install` command (and the deprecated commands :command:`install_files`, -:command:`install_programs`, and :command:`install_targets`). -For certain kinds of binary installers (including the graphical -installers on macOS and Windows), CPack generates installers that -allow users to select individual application components to install. -See :module:`CPackComponent` module for further details. +The generated binary installers will contain all files that have been installed +via CMake's :command:`install` command (and the deprecated commands +:command:`install_files`, :command:`install_programs`, and +:command:`install_targets`). Certain kinds of binary installers can be +configured such that users can select individual application components to +install. See the :module:`CPackComponent` module for further details. + +Source packages (configured through ``CPackSourceConfig.cmake`` and generated +by the :cpack_gen:`CPack Archive Generator`) will contain all source files in +the project directory except those specified in +:variable:`CPACK_SOURCE_IGNORE_FILES`. CPack Generators ^^^^^^^^^^^^^^^^ @@ -38,10 +42,6 @@ generator. In a :variable:`CPACK_PROJECT_CONFIG_FILE`, :variable:`CPACK_GENERATOR` is a *string naming a single generator*. If you need per-cpack-generator logic to control *other* cpack settings, then you need a :variable:`CPACK_PROJECT_CONFIG_FILE`. - -The CMake source tree itself contains a :variable:`CPACK_PROJECT_CONFIG_FILE`. -See the top level file ``CMakeCPackOptions.cmake.in`` for an example. - If set, the :variable:`CPACK_PROJECT_CONFIG_FILE` is included automatically on a per-generator basis. It only need contain overrides. diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake index 211d767..1f8c38c 100644 --- a/Modules/CPackComponent.cmake +++ b/Modules/CPackComponent.cmake @@ -5,29 +5,34 @@ CPackComponent -------------- -Build binary and source package installers +Configure components for binary installers and source packages. -Variables concerning CPack Components -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. only:: html -The CPackComponent module is the module which handles the component -part of CPack. See CPack module for general information about CPack. + .. contents:: -For certain kinds of binary installers (including the graphical -installers on macOS and Windows), CPack generates installers that -allow users to select individual application components to install. -The contents of each of the components are identified by the COMPONENT -argument of CMake's INSTALL command. These components can be +Introduction +^^^^^^^^^^^^ + +This module is automatically included by :module:`CPack`. + +Certain binary installers (especially the graphical installers) generated +by CPack allow users to select individual application *components* to install. +This module allows developers to configure the packaging of such components. + +Contents is assigned to components by the ``COMPONENT`` +argument of CMake's :command:`install` command. Components can be annotated with user-friendly names and descriptions, inter-component dependencies, etc., and grouped in various ways to customize the -resulting installer. See the cpack_add_* commands, described below, -for more information about component-specific installations. +resulting installer, using the commands described below. + +To specify different groupings for different CPack generators use +a CPACK_PROJECT_CONFIG_FILE. -Component-specific installation allows users to select specific sets -of components to install during the install process. Installation -components are identified by the COMPONENT argument of CMake's INSTALL -commands, and should be further described by the following CPack -commands: +Variables +^^^^^^^^^ + +The following variables influence the component-specific packaging: .. variable:: CPACK_COMPONENTS_ALL @@ -61,16 +66,14 @@ commands: Specify how components are grouped for multi-package component-aware CPack generators. - Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates - several packages files when asked for component packaging. They group - the component differently depending on the value of this variable: - - * ONE_PER_GROUP (default): creates one package file per component group - * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components - * IGNORE : creates one package per component, i.e. IGNORE component group + Some generators like RPM or ARCHIVE (TGZ, ZIP, ...) may generate + several packages files when there are components, depending + on the value of this variable: - One can specify different grouping for different CPack generator by - using a CPACK_PROJECT_CONFIG_FILE. + * ONE_PER_GROUP (default): create one package per component group + * IGNORE : create one package per component (ignore the groups) + * ALL_COMPONENTS_IN_ONE : create a single package with all requested + components .. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME @@ -100,10 +103,15 @@ commands: True if this component is not selected to be installed by default. +Commands +^^^^^^^^ + +Add component +""""""""""""" + .. command:: cpack_add_component -Describes a CPack installation -component named by the COMPONENT argument to a CMake INSTALL command. +Describe an installation component. :: @@ -118,13 +126,11 @@ component named by the COMPONENT argument to a CMake INSTALL command. [ARCHIVE_FILE filename] [PLIST filename]) - - -The cmake_add_component command describes an installation component, -which the user can opt to install or remove as part of the graphical -installation process. compname is the name of the component, as -provided to the COMPONENT argument of one or more CMake INSTALL -commands. +``compname`` is the name of an installation component, as defined by the +``COMPONENT`` argument of one or more CMake :command:`install` commands. +With the ``cpack_add_component`` command one can set a name, a description, +and other attributes of an installation component. +One can also assign a component to a component group. DISPLAY_NAME is the displayed name of the component, used in graphical installers to display the component name. This value can be any @@ -177,6 +183,9 @@ the component. See cpack_configure_downloads for more information. PLIST gives a filename that is passed to pkgbuild with the ``--component-plist`` argument when using the productbuild generator. +Add component group +""""""""""""""""""" + .. command:: cpack_add_component_group Describes a group of related CPack installation components. @@ -225,6 +234,9 @@ single entry. BOLD_TITLE indicates that the group title should appear in bold, to call the user's attention to the group. +Add installation type +""""""""""""""""""""" + .. command:: cpack_add_install_type Add a new installation type containing @@ -249,6 +261,9 @@ DISPLAY_NAME is the displayed name of the install type, which will typically show up in a drop-down box within a graphical installer. This value can be any string. +Configure downloads +""""""""""""""""""" + .. command:: cpack_configure_downloads Configure CPack to download @@ -281,8 +296,6 @@ requires the ZipDLL plug-in for NSIS, available at: http://nsis.sourceforge.net/ZipDLL_plug-in - - On macOS, installers that download components on-the-fly can only be built and installed on system using macOS 10.5 or later. diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake index f0fde8d..3354bfb 100644 --- a/Modules/CheckFortranSourceCompiles.cmake +++ b/Modules/CheckFortranSourceCompiles.cmake @@ -103,8 +103,6 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) if(NOT _SRC_EXT) set(_SRC_EXT F) endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) @@ -132,10 +130,10 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR) try_compile(${VAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS} "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}" OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake index a3e5d5d..f858b84 100644 --- a/Modules/CheckFortranSourceRuns.cmake +++ b/Modules/CheckFortranSourceRuns.cmake @@ -98,8 +98,6 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) if(NOT _SRC_EXT) set(_SRC_EXT F90) endif() - set(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) @@ -127,10 +125,10 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR) try_run(${VAR}_EXITCODE ${VAR}_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS} -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} "${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}" COMPILE_OUTPUT_VARIABLE OUTPUT diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in index 82035a3..fb93073 100644 --- a/Modules/CheckTypeSize.c.in +++ b/Modules/CheckTypeSize.c.in @@ -5,10 +5,14 @@ # define KEY '_','_','i','3','8','6' #elif defined(__x86_64) # define KEY '_','_','x','8','6','_','6','4' -#elif defined(__ppc__) -# define KEY '_','_','p','p','c','_','_' +#elif defined(__PPC64__) +# define KEY '_','_','P','P','C','6','4','_','_' #elif defined(__ppc64__) # define KEY '_','_','p','p','c','6','4','_','_' +#elif defined(__PPC__) +# define KEY '_','_','P','P','C','_','_' +#elif defined(__ppc__) +# define KEY '_','_','p','p','c','_','_' #elif defined(__aarch64__) # define KEY '_','_','a','a','r','c','h','6','4','_','_' #elif defined(__ARM_ARCH_7A__) diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake index e07401d..4aa680f 100644 --- a/Modules/Compiler/GNU-ASM.cmake +++ b/Modules/Compiler/GNU-ASM.cmake @@ -4,3 +4,9 @@ include(Compiler/GNU) set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) __compiler_gnu(ASM) + +if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH STREQUAL "GNU assembler") + set(CMAKE_DEPFILE_FLAGS_ASM${ASM_DIALECT} "--MD <DEPFILE>") + set(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE + "<CMAKE_LINKER> <FLAGS> <CMAKE_ASM${ASM_DIALECT}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") +endif() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index 1f4d54d..2a2564e 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -4,6 +4,8 @@ set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True) set(CMAKE_CUDA_VERBOSE_FLAG "-v") set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") +set(_CMAKE_COMPILE_AS_CUDA_FLAG "-x cu") + if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) # The -forward-unknown-to-host-compiler flag was only # added to nvcc in 10.2 so before that we had no good diff --git a/Modules/Compiler/TI-C.cmake b/Modules/Compiler/TI-C.cmake index 1c0f4bc..b060ee9 100644 --- a/Modules/Compiler/TI-C.cmake +++ b/Modules/Compiler/TI-C.cmake @@ -14,5 +14,9 @@ set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> --compile_only --skip_ass set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> --preproc_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<PREPROCESSED_SOURCE>") set(CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> --compile_only --c_file=<SOURCE> <DEFINES> <INCLUDES> <FLAGS> --output_file=<OBJECT>") -set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -r <TARGET> <OBJECTS>") -set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>") +set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qr <TARGET> <OBJECTS>") +set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qa <TARGET> <OBJECTS>") +set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker --output_file=<TARGET> --map_file=<TARGET_NAME>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>") +set(CMAKE_ASM_RESPONSE_FILE_FLAG "--cmd_file=") +set(CMAKE_C_RESPONSE_FILE_FLAG "--cmd_file=") +set(CMAKE_C_RESPONSE_FILE_LINK_FLAG " ") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index 1683dff..e01ec8e 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -8,6 +8,7 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>] set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm] set(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=") +set(CMAKE_Fortran_MODDIR_INCLUDE_FLAG "-I") # -qmoddir= does not affect search path set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 5bac0d8..326ee06 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -9,8 +9,11 @@ ExternalProject .. contents:: +Commands +^^^^^^^^ + External Project Definition -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +""""""""""""""""""""""""""" .. command:: ExternalProject_Add @@ -665,7 +668,7 @@ External Project Definition automatic substitutions that are supported for some options. Obtaining Project Properties -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +"""""""""""""""""""""""""""" .. command:: ExternalProject_Get_Property @@ -686,7 +689,7 @@ Obtaining Project Properties message("Source dir of myExtProj = ${SOURCE_DIR}") Explicit Step Management -^^^^^^^^^^^^^^^^^^^^^^^^ +"""""""""""""""""""""""" The ``ExternalProject_Add()`` function on its own is often sufficient for incorporating an external project into the main build. Certain scenarios diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index f3e1b51..0e98f49 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -76,8 +76,11 @@ sometimes useful as part of implementing some higher level feature or to populate some content in CMake's script mode. +Commands +^^^^^^^^ + Declaring Content Details -^^^^^^^^^^^^^^^^^^^^^^^^^ +""""""""""""""""""""""""" .. command:: FetchContent_Declare @@ -130,7 +133,7 @@ Declaring Content Details ) Populating The Content -^^^^^^^^^^^^^^^^^^^^^^ +"""""""""""""""""""""" For most common scenarios, population means making content available to the main build according to previously declared details for that dependency. diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake index c4e55ce..243b9e0 100644 --- a/Modules/FindArmadillo.cmake +++ b/Modules/FindArmadillo.cmake @@ -6,7 +6,7 @@ FindArmadillo ------------- Find the Armadillo C++ library. -Armadillo is library for linear algebra & scientific computing. +Armadillo is a library for linear algebra & scientific computing. Using Armadillo: @@ -31,19 +31,13 @@ This module sets the following variables: ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") #]=======================================================================] -# UNIX paths are standard, no need to write. -find_library(ARMADILLO_LIBRARY - NAMES armadillo - PATHS "$ENV{ProgramFiles}/Armadillo/lib" "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo" - ) find_path(ARMADILLO_INCLUDE_DIR NAMES armadillo PATHS "$ENV{ProgramFiles}/Armadillo/include" ) - +mark_as_advanced(ARMADILLO_INCLUDE_DIR) if(ARMADILLO_INCLUDE_DIR) - # ------------------------------------------------------------------------ # Extract version information from <armadillo> # ------------------------------------------------------------------------ @@ -59,32 +53,79 @@ if(ARMADILLO_INCLUDE_DIR) if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp") # Read and parse armdillo version header file for version number - file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS REGEX "#define ARMA_VERSION_[A-Z]+ ") - string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}") - string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}") + file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _ARMA_HEADER_CONTENTS REGEX "#define ARMA_VERSION_[A-Z]+ ") + string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_ARMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_ARMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_ARMA_HEADER_CONTENTS}") # WARNING: The number of spaces before the version name is not one. - string(REGEX REPLACE ".*#define ARMA_VERSION_NAME +\"([0-9a-zA-Z _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_ARMA_HEADER_CONTENTS}") - unset(_armadillo_HEADER_CONTENTS) endif() set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}") endif () +if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp") + file(STRINGS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/config.hpp" _ARMA_CONFIG_CONTENTS REGEX "^#define ARMA_USE_[A-Z]+") + string(REGEX MATCH "ARMA_USE_WRAPPER" _ARMA_USE_WRAPPER "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_LAPACK" _ARMA_USE_LAPACK "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_BLAS" _ARMA_USE_BLAS "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_ARPACK" _ARMA_USE_ARPACK "${_ARMA_CONFIG_CONTENTS}") + string(REGEX MATCH "ARMA_USE_HDF5" _ARMA_USE_HDF5 "${_ARMA_CONFIG_CONTENTS}") +endif() + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) + +# If _ARMA_USE_WRAPPER is set, then we just link to armadillo, but if it's not then we need support libraries instead +set(_ARMA_SUPPORT_LIBRARIES) + +if(_ARMA_USE_WRAPPER) + # Link to the armadillo wrapper library. + find_library(ARMADILLO_LIBRARY + NAMES armadillo + PATHS + "$ENV{ProgramFiles}/Armadillo/lib" + "$ENV{ProgramFiles}/Armadillo/lib64" + "$ENV{ProgramFiles}/Armadillo" + ) + mark_as_advanced(ARMADILLO_LIBRARY) + set(_ARMA_REQUIRED_VARS ARMADILLO_LIBRARY) +else() + # Link directly to individual components. + set(ARMADILLO_LIBRARY "") + foreach(pkg + LAPACK + BLAS + ARPACK + HDF5 + ) + if(_ARMA_USE_${pkg}) + find_package(${pkg} QUIET) + list(APPEND _ARMA_REQUIRED_VARS "${pkg}_FOUND") + if(${pkg}_FOUND) + list(APPEND _ARMA_SUPPORT_LIBRARIES ${${pkg}_LIBRARIES}) + endif() + endif() + endforeach() +endif() + find_package_handle_standard_args(Armadillo - REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR + REQUIRED_VARS ARMADILLO_INCLUDE_DIR ${_ARMA_REQUIRED_VARS} VERSION_VAR ARMADILLO_VERSION_STRING) -# version_var fails with cmake < 2.8.4. if (ARMADILLO_FOUND) set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR}) - set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY}) + set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY} ${_ARMA_SUPPORT_LIBRARIES}) endif () -# Hide internal variables -mark_as_advanced( - ARMADILLO_INCLUDE_DIR - ARMADILLO_LIBRARY) +# Clean up internal variables +unset(_ARMA_REQUIRED_VARS) +unset(_ARMA_SUPPORT_LIBRARIES) +unset(_ARMA_USE_WRAPPER) +unset(_ARMA_USE_LAPACK) +unset(_ARMA_USE_BLAS) +unset(_ARMA_USE_ARPACK) +unset(_ARMA_USE_HDF5) +unset(_ARMA_CONFIG_CONTENTS) +unset(_ARMA_HEADER_CONTENTS) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index b488418..c1888a4 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -19,9 +19,12 @@ The module will optionally accept the ``COMPONENTS`` argument. If no ``COMPONENTS`` are specified, then the find module will default to finding only the ``HDF5`` C library. If one or more ``COMPONENTS`` are specified, the module will attempt to find the language bindings for the specified -components. The only valid components are ``C``, ``CXX``, ``Fortran``, ``HL``, -and ``Fortran_HL``. If the ``COMPONENTS`` argument is not given, the module will +components. The valid components are ``C``, ``CXX``, ``Fortran``, ``HL``. +``HL`` refers to the "high-level" HDF5 functions for C and Fortran. +If the ``COMPONENTS`` argument is not given, the module will attempt to find only the C bindings. +For example, to use Fortran HDF5 and HDF5-HL functions, do: +``find_package(HDF5 COMPONENTS Fortran HL)``. This module will read the variable ``HDF5_USE_STATIC_LIBRARIES`` to determine whether or not to prefer a @@ -29,11 +32,6 @@ static link to a dynamic link for ``HDF5`` and all of it's dependencies. To use this feature, make sure that the ``HDF5_USE_STATIC_LIBRARIES`` variable is set before the call to find_package. -To provide the module with a hint about where to find your ``HDF5`` -installation, you can set the environment variable ``HDF5_ROOT``. The -Find module will then look in this path when searching for ``HDF5`` -executables, paths, and libraries. - Both the serial and parallel ``HDF5`` wrappers are considered and the first directory to contain either one will be used. In the event that both appear in the same directory the serial version is preferentially selected. This @@ -115,10 +113,10 @@ also be defined. With all components enabled, the following variables will be d Hints ^^^^^ -The following variable can be set to guide the search for HDF5 libraries and includes: +The following variables can be set to guide the search for HDF5 libraries and includes: -``HDF5_ROOT`` - Specify the path to the HDF5 installation to use. +``HDF5_PREFER_PARALLEL`` + set ``true`` to prefer parallel HDF5 (by default, serial is preferred) ``HDF5_FIND_DEBUG`` Set ``true`` to get extra debugging output. @@ -343,35 +341,46 @@ macro( _HDF5_invoke_compiler language output return_value version is_parallel) elseif("${language}" STREQUAL "Fortran") set(test_file ${scratch_dir}/cmake_hdf5_test.f90) endif() + # Verify that the compiler wrapper can actually compile: sometimes the compiler + # wrapper exists, but not the compiler. E.g. Miniconda / Anaconda Python execute_process( - COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file} - OUTPUT_VARIABLE ${output} - ERROR_VARIABLE ${output} + COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file} RESULT_VARIABLE ${return_value} ) if(NOT ${${return_value}} EQUAL 0) - message(STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") - endif() - execute_process( - COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig - OUTPUT_VARIABLE config_output - ERROR_VARIABLE config_output - RESULT_VARIABLE config_return - ) - if(NOT ${return_value} EQUAL 0) - message( STATUS - "Unable to determine HDF5 ${language} version from HDF5 wrapper.") - endif() - string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") - if(version_match) - string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") - string(REPLACE "-patch" "." ${version} "${${version}}") - endif() - if(config_output MATCHES "Parallel HDF5: yes") - set(${is_parallel} TRUE) + message(STATUS + "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.") else() - set(${is_parallel} FALSE) + execute_process( + COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file} + OUTPUT_VARIABLE ${output} + ERROR_VARIABLE ${output} + RESULT_VARIABLE ${return_value} + ) + if(NOT ${${return_value}} EQUAL 0) + message(STATUS + "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") + endif() + execute_process( + COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig + OUTPUT_VARIABLE config_output + ERROR_VARIABLE config_output + RESULT_VARIABLE config_return + ) + if(NOT ${return_value} EQUAL 0) + message( STATUS + "Unable to determine HDF5 ${language} version from HDF5 wrapper.") + endif() + string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}") + if(version_match) + string(REPLACE "HDF5 Version: " "" ${version} "${version_match}") + string(REPLACE "-patch" "." ${version} "${${version}}") + endif() + if(config_output MATCHES "Parallel HDF5: yes") + set(${is_parallel} TRUE) + else() + set(${is_parallel} FALSE) + endif() endif() endmacro() @@ -769,6 +778,17 @@ if( NOT HDF5_FOUND ) set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES}) set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES}) + # suffixes as seen on Linux, MSYS2, ... + set(_lib_suffixes hdf5) + if(NOT HDF5_PREFER_PARALLEL) + list(APPEND _lib_suffixes hdf5/serial) + endif() + if(HDF5_USE_STATIC_LIBRARIES) + set(_inc_suffixes include/static) + else() + set(_inc_suffixes include/shared) + endif() + foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS) # find the HDF5 include directories if("${__lang}" STREQUAL "Fortran") @@ -782,7 +802,7 @@ if( NOT HDF5_FOUND ) find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} HINTS ${HDF5_ROOT} PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include + PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} ${_HDF5_SEARCH_OPTS} ) mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR) @@ -811,14 +831,15 @@ if( NOT HDF5_FOUND ) endif() find_library(HDF5_${LIB}_LIBRARY_DEBUG NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes} ${_HDF5_SEARCH_OPTS} ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE + find_library(HDF5_${LIB}_LIBRARY_RELEASE NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes} ${_HDF5_SEARCH_OPTS} ) + select_library_configurations( HDF5_${LIB} ) list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) endforeach() @@ -848,14 +869,15 @@ if( NOT HDF5_FOUND ) endif() find_library(HDF5_${LIB}_LIBRARY_DEBUG NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes} ${_HDF5_SEARCH_OPTS} ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE + find_library(HDF5_${LIB}_LIBRARY_RELEASE NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib + HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes} ${_HDF5_SEARCH_OPTS} ) + select_library_configurations( HDF5_${LIB} ) list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY}) endforeach() diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 27dcaf5..c9c0903 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -5,27 +5,45 @@ FindOpenAL ---------- - Finds Open Audio Library (OpenAL). -This module defines ``OPENAL_LIBRARY OPENAL_FOUND``, if -false, do not try to link to OpenAL ``OPENAL_INCLUDE_DIR``, where to find -the headers. -``$OPENALDIR`` is an environment variable that would correspond to the -``./configure --prefix=$OPENALDIR`` used in building OpenAL. +Projects using this module should use ``#include <al.h>`` to include the OpenAL +header file, **not** ``#include <AL.al.h>``. The reason for this is that the +latter is not entirely portable. Windows/Creative Labs does not by default put +their headers in ``AL/`` and macOS uses the convention ``<OpenAL/al.h>``. + +Hints +^^^^^ + +Environment variable ``$OPENALDIR`` can be used to set the prefix of OpenAL +installation to be found. + +By default on macOS, system framework is search first. In other words, +OpenAL is searched in the following order: + +1. System framework: ``/System/Library/Frameworks``, whose priority can be + changed via setting the :variable:`CMAKE_FIND_FRAMEWORK` variable. +2. Environment variable ``$OPENALDIR``. +3. System paths. +4. User-compiled framework: ``~/Library/Frameworks``. +5. Manually compiled framework: ``/Library/Frameworks``. +6. Add-on package: ``/opt``. + +Result Variables +^^^^^^^^^^^^^^^^ -Created by Eric Wing. This was influenced by the ``FindSDL.cmake`` -module. +This module defines the following variables: + +``OPENAL_FOUND`` + If false, do not try to link to OpenAL +``OPENAL_INCLUDE_DIR`` + OpenAL include directory +``OPENAL_LIBRARY`` + Path to the OpenAL library +``OPENAL_VERSION_STRING`` + Human-readable string containing the version of OpenAL #]=======================================================================] -# This makes the presumption that you are include al.h like -# #include "al.h" -# and not -# #include <AL/al.h> -# The reason for this is that the latter is not entirely portable. -# Windows/Creative Labs does not by default put their headers in AL/ and -# OS X uses the convention <OpenAL/al.h>. -# # For Windows, Creative Labs seems to have added a registry key for their # OpenAL 1.1 installer. I have added that key to the list of search paths, # however, the key looks like it could be a little fragile depending on @@ -36,36 +54,17 @@ module. # platforms are introduced. # The OpenAL 1.0 installer doesn't seem to have a useful key I can use. # I do not know if the Nvidia OpenAL SDK has a registry key. -# -# For OS X, remember that OpenAL was added by Apple in 10.4 (Tiger). -# To support the framework, I originally wrote special framework detection -# code in this module which I have now removed with CMake's introduction -# of native support for frameworks. -# In addition, OpenAL is open source, and it is possible to compile on Panther. -# Furthermore, due to bugs in the initial OpenAL release, and the -# transition to OpenAL 1.1, it is common to need to override the built-in -# framework. -# Per my request, CMake should search for frameworks first in -# the following order: -# ~/Library/Frameworks/OpenAL.framework/Headers -# /Library/Frameworks/OpenAL.framework/Headers -# /System/Library/Frameworks/OpenAL.framework/Headers -# -# On OS X, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# OPENAL_LIBRARY to override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. find_path(OPENAL_INCLUDE_DIR al.h HINTS ENV OPENALDIR - PATH_SUFFIXES include/AL include/OpenAL include AL OpenAL PATHS - ~/Library/Frameworks - /Library/Frameworks - /opt - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] -) + ~/Library/Frameworks + /Library/Frameworks + /opt + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] + PATH_SUFFIXES include/AL include/OpenAL include AL OpenAL + ) if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_OpenAL_ARCH_DIR libs/Win64) @@ -77,17 +76,21 @@ find_library(OPENAL_LIBRARY NAMES OpenAL al openal OpenAL32 HINTS ENV OPENALDIR - PATH_SUFFIXES libx32 lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} PATHS - ~/Library/Frameworks - /Library/Frameworks - /opt - [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] -) + ~/Library/Frameworks + /Library/Frameworks + /opt + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] + PATH_SUFFIXES libx32 lib64 lib libs64 libs ${_OpenAL_ARCH_DIR} + ) unset(_OpenAL_ARCH_DIR) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) +find_package_handle_standard_args( + OpenAL + REQUIRED_VARS OPENAL_LIBRARY OPENAL_INCLUDE_DIR + VERSION_VAR OPENAL_VERSION_STRING + ) mark_as_advanced(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake index 9891724..34a203e 100644 --- a/Modules/FindOpenCL.cmake +++ b/Modules/FindOpenCL.cmake @@ -78,6 +78,8 @@ find_path(OpenCL_INCLUDE_DIR ENV CUDA_PATH ENV ATISTREAMSDKROOT ENV OCL_ROOT + /usr/local/cuda + /opt/cuda PATH_SUFFIXES include OpenCL/common/inc @@ -126,6 +128,8 @@ else() PATHS ENV AMDAPPSDKROOT ENV CUDA_PATH + /usr/local/cuda + /opt/cuda PATH_SUFFIXES lib/x86 lib) @@ -135,6 +139,8 @@ else() PATHS ENV AMDAPPSDKROOT ENV CUDA_PATH + /usr/local/cuda + /opt/cuda PATH_SUFFIXES lib/x86_64 lib/x64 diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 9dfa222..6132693 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -288,6 +288,22 @@ setting the following variables: If more than one artifact is specified, it is the user's responsability to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controled with the following variable: + +``Python_ARTIFACTS_INTERACTIVE`` + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index ce06458..a40d7f7 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -75,22 +75,20 @@ macro (_PYTHON_SELECT_LIBRARY_CONFIGURATIONS _PYTHON_BASENAME) (_PYTHON_isMultiConfig OR CMAKE_BUILD_TYPE)) # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for # single-config generators, set optimized and debug libraries - set (${_PYTHON_BASENAME}_LIBRARY "") - foreach (_PYTHON_libname IN LISTS ${_PYTHON_BASENAME}_LIBRARY_RELEASE ) - list( APPEND ${_PYTHON_BASENAME}_LIBRARY optimized "${_PYTHON_libname}" ) + set (${_PYTHON_BASENAME}_LIBRARIES "") + foreach (_PYTHON_libname IN LISTS ${_PYTHON_BASENAME}_LIBRARY_RELEASE) + list( APPEND ${_PYTHON_BASENAME}_LIBRARIES optimized "${_PYTHON_libname}") endforeach() - foreach (_PYTHON_libname IN LISTS ${_PYTHON_BASENAME}_LIBRARY_DEBUG ) - list( APPEND ${_PYTHON_BASENAME}_LIBRARY debug "${_PYTHON_libname}" ) + foreach (_PYTHON_libname IN LISTS ${_PYTHON_BASENAME}_LIBRARY_DEBUG) + list( APPEND ${_PYTHON_BASENAME}_LIBRARIES debug "${_PYTHON_libname}") endforeach() elseif (${_PYTHON_BASENAME}_LIBRARY_RELEASE) - set (${_PYTHON_BASENAME}_LIBRARY "${${_PYTHON_BASENAME}_LIBRARY_RELEASE}") + set (${_PYTHON_BASENAME}_LIBRARIES "${${_PYTHON_BASENAME}_LIBRARY_RELEASE}") elseif (${_PYTHON_BASENAME}_LIBRARY_DEBUG) - set (${_PYTHON_BASENAME}_LIBRARY "${${_PYTHON_BASENAME}_LIBRARY_DEBUG}") + set (${_PYTHON_BASENAME}_LIBRARIES "${${_PYTHON_BASENAME}_LIBRARY_DEBUG}") else() - set (${_PYTHON_BASENAME}_LIBRARY "${_PYTHON_BASENAME}_LIBRARY-NOTFOUND") + set (${_PYTHON_BASENAME}_LIBRARIES "${_PYTHON_BASENAME}_LIBRARY-NOTFOUND") endif() - - set (${_PYTHON_BASENAME}_LIBRARIES "${${_PYTHON_BASENAME}_LIBRARY}") endmacro() @@ -1413,6 +1411,10 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() endif() + if (${_PYTHON_PREFIX}_ARTIFACTS_INTERACTIVE) + set (${_PYTHON_PREFIX}_EXECUTABLE "${_${_PYTHON_PREFIX}_EXECUTABLE}" CACHE FILEPATH "${_PYTHON_PREFIX} Interpreter") + endif() + _python_mark_as_internal (_${_PYTHON_PREFIX}_EXECUTABLE _${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES _${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE) @@ -1608,6 +1610,10 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) unset (${_PYTHON_PREFIX}_COMPILER_ID) endif() + if (${_PYTHON_PREFIX}_ARTIFACTS_INTERACTIVE) + set (${_PYTHON_PREFIX}_COMPILER "${_${_PYTHON_PREFIX}_COMPILER}" CACHE FILEPATH "${_PYTHON_PREFIX} Compiler") + endif() + _python_mark_as_internal (_${_PYTHON_PREFIX}_COMPILER _${_PYTHON_PREFIX}_COMPILER_SIGNATURE) endif() @@ -2299,6 +2305,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS set (CMAKE_FIND_LIBRARY_SUFFIXES ${_${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES}) endif() + if (${_PYTHON_PREFIX}_ARTIFACTS_INTERACTIVE) + set (${_PYTHON_PREFIX}_LIBRARY "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "${_PYTHON_PREFIX} Library") + set (${_PYTHON_PREFIX}_INCLUDE_DIR "${_${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE FILEPATH "${_PYTHON_PREFIX} Include Directory") + endif() + _python_mark_as_internal (_${_PYTHON_PREFIX}_LIBRARY_RELEASE _${_PYTHON_PREFIX}_LIBRARY_DEBUG _${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE @@ -2377,6 +2388,10 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE) endif() + if (${_PYTHON_PREFIX}_ARTIFACTS_INTERACTIVE) + set (${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}" CACHE FILEPATH "${_PYTHON_PREFIX} NumPy Include Directory") + endif() + _python_mark_as_internal (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR _${_PYTHON_PREFIX}_NUMPY_SIGNATURE) endif() @@ -2452,8 +2467,8 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") else() set_target_properties (${__name} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARY}" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY}") + IMPORTED_IMPLIB "${${_PYTHON_PREFIX}_LIBRARIES}" + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE}") endif() else() if (${_PYTHON_PREFIX}_LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_LIBRARY_DEBUG) @@ -2467,7 +2482,7 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") else() set_target_properties (${__name} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" - IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY}") + IMPORTED_LOCATION "${${_PYTHON_PREFIX}_LIBRARY_RELEASE}") endif() endif() diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index af8ad39..10fe211 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -237,6 +237,22 @@ setting the following variables: If more than one artifact is specified, it is the user's responsability to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controled with the following variable: + +``Python2_ARTIFACTS_INTERACTIVE`` + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 66f4f75..211f982 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -285,6 +285,22 @@ setting the following variables: If more than one artifact is specified, it is the user's responsability to ensure the consistency of the various artifacts. +By default, this module supports multiple calls in different directories of a +project with different version/component requirements while providing correct +and consistent results for each call. To support this behavior, ``CMake`` cache +is not used in the traditional way which can be problematic for interactive +specification. So, to enable also interactive specification, module behavior +can be controled with the following variable: + +``Python3_ARTIFACTS_INTERACTIVE`` + Selects the behavior of the module. This is a boolean variable: + + * If set to ``TRUE``: Create CMake cache entries for the above artifact + specification variables so that users can edit them interactively. + This disables support for multiple version/component requirements. + * If set to ``FALSE`` or undefined: Enable multiple version/component + requirements. + Commands ^^^^^^^^ diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 7e01fbc..5df242b 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -17,279 +17,323 @@ standard syntax, e.g. find_package(Ruby 1.8) It also determines what the name of the library is. This code sets the following variables: -``RUBY_EXECUTABLE`` +``Ruby_EXECUTABLE`` full path to the ruby binary -``RUBY_INCLUDE_DIRS`` +``Ruby_INCLUDE_DIRS`` include dirs to be used when using the ruby library -``RUBY_LIBRARY`` +``Ruby_LIBRARY`` full path to the ruby library -``RUBY_VERSION`` +``Ruby_VERSION`` the version of ruby which was found, e.g. "1.8.7" -``RUBY_FOUND`` +``Ruby_FOUND`` set to true if ruby ws found successfully Also: -``RUBY_INCLUDE_PATH`` - same as RUBY_INCLUDE_DIRS, only provided for compatibility reasons, don't use it +``Ruby_INCLUDE_PATH`` + same as Ruby_INCLUDE_DIRS, only provided for compatibility reasons, don't use it #]=======================================================================] -# RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` -# RUBY_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'` -# RUBY_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'` -# RUBY_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'` -# RUBY_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'` +# Backwards compatibility +# Define camel case versions of input variables +foreach(UPPER + RUBY_EXECUTABLE + RUBY_LIBRARY + RUBY_INCLUDE_DIR + RUBY_CONFIG_INCLUDE_DIR + ) + if (DEFINED ${UPPER}) + string(REPLACE "RUBY_" "Ruby_" Camel ${UPPER}) + if (NOT DEFINED ${Camel}) + set(${Camel} ${${UPPER}}) + endif() + endif() +endforeach() + +# Ruby_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` +# Ruby_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'` +# Ruby_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'` +# Ruby_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'` +# Ruby_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'` # uncomment the following line to get debug output for this file -# set(_RUBY_DEBUG_OUTPUT TRUE) +# set(_Ruby_DEBUG_OUTPUT TRUE) # Determine the list of possible names of the ruby executable depending # on which version of ruby is required -set(_RUBY_POSSIBLE_EXECUTABLE_NAMES ruby) +set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby) # if 1.9 is required, don't look for ruby18 and ruby1.8, default to version 1.8 if(DEFINED Ruby_FIND_VERSION_MAJOR AND DEFINED Ruby_FIND_VERSION_MINOR) - set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${RUBY_FIND_VERSION_MINOR}") + set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}") # we can't construct that if only major version is given - set(_RUBY_POSSIBLE_EXECUTABLE_NAMES + set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby${Ruby_FIND_VERSION_MAJOR}.${Ruby_FIND_VERSION_MINOR} ruby${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR} - ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}) + ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}) else() set(Ruby_FIND_VERSION_SHORT_NODOT "18") endif() if(NOT Ruby_FIND_VERSION_EXACT) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.4 ruby24) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.3 ruby23) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.2 ruby22) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.1 ruby21) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby2.0 ruby20) - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby2.4 ruby24) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby2.3 ruby23) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby2.2 ruby22) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby2.1 ruby21) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby2.0 ruby20) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby1.9 ruby19) # if we want a version below 1.9, also look for ruby 1.8 if("${Ruby_FIND_VERSION_SHORT_NODOT}" VERSION_LESS "19") - list(APPEND _RUBY_POSSIBLE_EXECUTABLE_NAMES ruby1.8 ruby18) + list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby1.8 ruby18) endif() - list(REMOVE_DUPLICATES _RUBY_POSSIBLE_EXECUTABLE_NAMES) + list(REMOVE_DUPLICATES _Ruby_POSSIBLE_EXECUTABLE_NAMES) endif() -find_program(RUBY_EXECUTABLE NAMES ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}) +find_program(Ruby_EXECUTABLE NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}) -if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) +if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) function(_RUBY_CONFIG_VAR RBVAR OUTVAR) - execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']" - RESULT_VARIABLE _RUBY_SUCCESS - OUTPUT_VARIABLE _RUBY_OUTPUT + execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']" + RESULT_VARIABLE _Ruby_SUCCESS + OUTPUT_VARIABLE _Ruby_OUTPUT ERROR_QUIET) - if(_RUBY_SUCCESS OR _RUBY_OUTPUT STREQUAL "") - execute_process(COMMAND ${RUBY_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']" - RESULT_VARIABLE _RUBY_SUCCESS - OUTPUT_VARIABLE _RUBY_OUTPUT + if(_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "") + execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']" + RESULT_VARIABLE _Ruby_SUCCESS + OUTPUT_VARIABLE _Ruby_OUTPUT ERROR_QUIET) endif() - set(${OUTVAR} "${_RUBY_OUTPUT}" PARENT_SCOPE) + set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE) endfunction() # query the ruby version - _RUBY_CONFIG_VAR("MAJOR" RUBY_VERSION_MAJOR) - _RUBY_CONFIG_VAR("MINOR" RUBY_VERSION_MINOR) - _RUBY_CONFIG_VAR("TEENY" RUBY_VERSION_PATCH) + _RUBY_CONFIG_VAR("MAJOR" Ruby_VERSION_MAJOR) + _RUBY_CONFIG_VAR("MINOR" Ruby_VERSION_MINOR) + _RUBY_CONFIG_VAR("TEENY" Ruby_VERSION_PATCH) # query the different directories - _RUBY_CONFIG_VAR("archdir" RUBY_ARCH_DIR) - _RUBY_CONFIG_VAR("arch" RUBY_ARCH) - _RUBY_CONFIG_VAR("rubyhdrdir" RUBY_HDR_DIR) - _RUBY_CONFIG_VAR("rubyarchhdrdir" RUBY_ARCHHDR_DIR) - _RUBY_CONFIG_VAR("libdir" RUBY_POSSIBLE_LIB_DIR) - _RUBY_CONFIG_VAR("rubylibdir" RUBY_RUBY_LIB_DIR) + _RUBY_CONFIG_VAR("archdir" Ruby_ARCH_DIR) + _RUBY_CONFIG_VAR("arch" Ruby_ARCH) + _RUBY_CONFIG_VAR("rubyhdrdir" Ruby_HDR_DIR) + _RUBY_CONFIG_VAR("rubyarchhdrdir" Ruby_ARCHHDR_DIR) + _RUBY_CONFIG_VAR("libdir" Ruby_POSSIBLE_LIB_DIR) + _RUBY_CONFIG_VAR("rubylibdir" Ruby_RUBY_LIB_DIR) # site_ruby - _RUBY_CONFIG_VAR("sitearchdir" RUBY_SITEARCH_DIR) - _RUBY_CONFIG_VAR("sitelibdir" RUBY_SITELIB_DIR) + _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR) + _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR) # vendor_ruby available ? - execute_process(COMMAND ${RUBY_EXECUTABLE} -r vendor-specific -e "print 'true'" - OUTPUT_VARIABLE RUBY_HAS_VENDOR_RUBY ERROR_QUIET) + execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'" + OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET) - if(RUBY_HAS_VENDOR_RUBY) - _RUBY_CONFIG_VAR("vendorlibdir" RUBY_VENDORLIB_DIR) - _RUBY_CONFIG_VAR("vendorarchdir" RUBY_VENDORARCH_DIR) + if(Ruby_HAS_VENDOR_RUBY) + _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR) + _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR) endif() # save the results in the cache so we don't have to run ruby the next time again - set(RUBY_VERSION_MAJOR ${RUBY_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE) - set(RUBY_VERSION_MINOR ${RUBY_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE) - set(RUBY_VERSION_PATCH ${RUBY_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE) - set(RUBY_ARCH_DIR ${RUBY_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE) - set(RUBY_HDR_DIR ${RUBY_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE) - set(RUBY_ARCHHDR_DIR ${RUBY_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE) - set(RUBY_POSSIBLE_LIB_DIR ${RUBY_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE) - set(RUBY_RUBY_LIB_DIR ${RUBY_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE) - set(RUBY_SITEARCH_DIR ${RUBY_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE) - set(RUBY_SITELIB_DIR ${RUBY_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE) - set(RUBY_HAS_VENDOR_RUBY ${RUBY_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE) - set(RUBY_VENDORARCH_DIR ${RUBY_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE) - set(RUBY_VENDORLIB_DIR ${RUBY_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE) + set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE) + set(Ruby_VERSION_MINOR ${Ruby_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE) + set(Ruby_VERSION_PATCH ${Ruby_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE) + set(Ruby_ARCH_DIR ${Ruby_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE) + set(Ruby_HDR_DIR ${Ruby_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE) + set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE) + set(Ruby_POSSIBLE_LIB_DIR ${Ruby_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE) + set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE) + set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE) + set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE) + set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE) + set(Ruby_VENDORARCH_DIR ${Ruby_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE) + set(Ruby_VENDORLIB_DIR ${Ruby_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE) mark_as_advanced( - RUBY_ARCH_DIR - RUBY_ARCH - RUBY_HDR_DIR - RUBY_ARCHHDR_DIR - RUBY_POSSIBLE_LIB_DIR - RUBY_RUBY_LIB_DIR - RUBY_SITEARCH_DIR - RUBY_SITELIB_DIR - RUBY_HAS_VENDOR_RUBY - RUBY_VENDORARCH_DIR - RUBY_VENDORLIB_DIR - RUBY_VERSION_MAJOR - RUBY_VERSION_MINOR - RUBY_VERSION_PATCH + Ruby_ARCH_DIR + Ruby_ARCH + Ruby_HDR_DIR + Ruby_ARCHHDR_DIR + Ruby_POSSIBLE_LIB_DIR + Ruby_RUBY_LIB_DIR + Ruby_SITEARCH_DIR + Ruby_SITELIB_DIR + Ruby_HAS_VENDOR_RUBY + Ruby_VENDORARCH_DIR + Ruby_VENDORLIB_DIR + Ruby_VERSION_MAJOR + Ruby_VERSION_MINOR + Ruby_VERSION_PATCH ) endif() -# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) +# In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling) # try to detect which version we found. This is not too good. -if(RUBY_EXECUTABLE AND NOT RUBY_VERSION_MAJOR) +if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) # by default assume 1.8.0 - set(RUBY_VERSION_MAJOR 1) - set(RUBY_VERSION_MINOR 8) - set(RUBY_VERSION_PATCH 0) + set(Ruby_VERSION_MAJOR 1) + set(Ruby_VERSION_MINOR 8) + set(Ruby_VERSION_PATCH 0) # check whether we found 1.9.x - if(${RUBY_EXECUTABLE} MATCHES "ruby1\\.?9") - set(RUBY_VERSION_MAJOR 1) - set(RUBY_VERSION_MINOR 9) + if(${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9") + set(Ruby_VERSION_MAJOR 1) + set(Ruby_VERSION_MINOR 9) endif() # check whether we found 2.0.x - if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?0") - set(RUBY_VERSION_MAJOR 2) - set(RUBY_VERSION_MINOR 0) + if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?0") + set(Ruby_VERSION_MAJOR 2) + set(Ruby_VERSION_MINOR 0) endif() # check whether we found 2.1.x - if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?1") - set(RUBY_VERSION_MAJOR 2) - set(RUBY_VERSION_MINOR 1) + if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?1") + set(Ruby_VERSION_MAJOR 2) + set(Ruby_VERSION_MINOR 1) endif() # check whether we found 2.2.x - if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?2") - set(RUBY_VERSION_MAJOR 2) - set(RUBY_VERSION_MINOR 2) + if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?2") + set(Ruby_VERSION_MAJOR 2) + set(Ruby_VERSION_MINOR 2) endif() # check whether we found 2.3.x - if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?3") - set(RUBY_VERSION_MAJOR 2) - set(RUBY_VERSION_MINOR 3) + if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?3") + set(Ruby_VERSION_MAJOR 2) + set(Ruby_VERSION_MINOR 3) endif() # check whether we found 2.4.x - if(${RUBY_EXECUTABLE} MATCHES "ruby2\\.?4") - set(RUBY_VERSION_MAJOR 2) - set(RUBY_VERSION_MINOR 4) + if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?4") + set(Ruby_VERSION_MAJOR 2) + set(Ruby_VERSION_MINOR 4) endif() endif() -if(RUBY_VERSION_MAJOR) - set(RUBY_VERSION "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}.${RUBY_VERSION_PATCH}") - set(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") - set(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") - set(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") +if(Ruby_VERSION_MAJOR) + set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}") + set(_Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}") + set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}") + set(_Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}") endif() -find_path(RUBY_INCLUDE_DIR +find_path(Ruby_INCLUDE_DIR NAMES ruby.h HINTS - ${RUBY_HDR_DIR} - ${RUBY_ARCH_DIR} - /usr/lib/ruby/${_RUBY_VERSION_SHORT}/i586-linux-gnu/ + ${Ruby_HDR_DIR} + ${Ruby_ARCH_DIR} + /usr/lib/ruby/${_Ruby_VERSION_SHORT}/i586-linux-gnu/ ) -set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} ) +set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIR} ) # if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir -if( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_RUBY_VERSION_SHORT_NODOT}" GREATER 18 OR RUBY_HDR_DIR) - find_path(RUBY_CONFIG_INCLUDE_DIR +if( "${Ruby_FIND_VERSION_SHORT_NODOT}" GREATER 18 OR "${_Ruby_VERSION_SHORT_NODOT}" GREATER 18 OR Ruby_HDR_DIR) + find_path(Ruby_CONFIG_INCLUDE_DIR NAMES ruby/config.h config.h HINTS - ${RUBY_HDR_DIR}/${RUBY_ARCH} - ${RUBY_ARCH_DIR} - ${RUBY_ARCHHDR_DIR} + ${Ruby_HDR_DIR}/${Ruby_ARCH} + ${Ruby_ARCH_DIR} + ${Ruby_ARCHHDR_DIR} ) - set(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} ) + set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIRS} ${Ruby_CONFIG_INCLUDE_DIR} ) endif() # Determine the list of possible names for the ruby library -set(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT} ruby-${_RUBY_VERSION_SHORT} ruby-${RUBY_VERSION}) +set(_Ruby_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_Ruby_VERSION_SHORT} ruby${_Ruby_VERSION_SHORT_NODOT} ruby-${_Ruby_VERSION_SHORT} ruby-${Ruby_VERSION}) if(WIN32) - set( _RUBY_MSVC_RUNTIME "" ) + set( _Ruby_MSVC_RUNTIME "" ) if( MSVC_VERSION EQUAL 1200 ) - set( _RUBY_MSVC_RUNTIME "60" ) + set( _Ruby_MSVC_RUNTIME "60" ) endif() if( MSVC_VERSION EQUAL 1300 ) - set( _RUBY_MSVC_RUNTIME "70" ) + set( _Ruby_MSVC_RUNTIME "70" ) endif() if( MSVC_VERSION EQUAL 1310 ) - set( _RUBY_MSVC_RUNTIME "71" ) + set( _Ruby_MSVC_RUNTIME "71" ) endif() if( MSVC_VERSION EQUAL 1400 ) - set( _RUBY_MSVC_RUNTIME "80" ) + set( _Ruby_MSVC_RUNTIME "80" ) endif() if( MSVC_VERSION EQUAL 1500 ) - set( _RUBY_MSVC_RUNTIME "90" ) + set( _Ruby_MSVC_RUNTIME "90" ) endif() - set(_RUBY_ARCH_PREFIX "") + set(_Ruby_ARCH_PREFIX "") if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_RUBY_ARCH_PREFIX "x64-") + set(_Ruby_ARCH_PREFIX "x64-") endif() - list(APPEND _RUBY_POSSIBLE_LIB_NAMES - "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}" - "${_RUBY_ARCH_PREFIX}msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" - "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}" - "${_RUBY_ARCH_PREFIX}msvcrt-ruby${_RUBY_NODOT_VERSION}-static" ) + list(APPEND _Ruby_POSSIBLE_LIB_NAMES + "${_Ruby_ARCH_PREFIX}msvcr${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_NODOT_VERSION}" + "${_Ruby_ARCH_PREFIX}msvcr${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_NODOT_VERSION}-static" + "${_Ruby_ARCH_PREFIX}msvcrt-ruby${_Ruby_NODOT_VERSION}" + "${_Ruby_ARCH_PREFIX}msvcrt-ruby${_Ruby_NODOT_VERSION}-static" ) endif() -find_library(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} ) +find_library(Ruby_LIBRARY NAMES ${_Ruby_POSSIBLE_LIB_NAMES} HINTS ${Ruby_POSSIBLE_LIB_DIR} ) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -set(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY) -if(_RUBY_VERSION_SHORT_NODOT GREATER 18) - list(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR) +set(_Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY) +if(_Ruby_VERSION_SHORT_NODOT GREATER 18) + list(APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR) endif() -if(_RUBY_DEBUG_OUTPUT) +if(_Ruby_DEBUG_OUTPUT) message(STATUS "--------FindRuby.cmake debug------------") - message(STATUS "_RUBY_POSSIBLE_EXECUTABLE_NAMES: ${_RUBY_POSSIBLE_EXECUTABLE_NAMES}") - message(STATUS "_RUBY_POSSIBLE_LIB_NAMES: ${_RUBY_POSSIBLE_LIB_NAMES}") - message(STATUS "RUBY_ARCH_DIR: ${RUBY_ARCH_DIR}") - message(STATUS "RUBY_HDR_DIR: ${RUBY_HDR_DIR}") - message(STATUS "RUBY_POSSIBLE_LIB_DIR: ${RUBY_POSSIBLE_LIB_DIR}") - message(STATUS "Found RUBY_VERSION: \"${RUBY_VERSION}\" , short: \"${_RUBY_VERSION_SHORT}\", nodot: \"${_RUBY_VERSION_SHORT_NODOT}\"") - message(STATUS "_RUBY_REQUIRED_VARS: ${_RUBY_REQUIRED_VARS}") - message(STATUS "RUBY_EXECUTABLE: ${RUBY_EXECUTABLE}") - message(STATUS "RUBY_LIBRARY: ${RUBY_LIBRARY}") - message(STATUS "RUBY_INCLUDE_DIR: ${RUBY_INCLUDE_DIR}") - message(STATUS "RUBY_CONFIG_INCLUDE_DIR: ${RUBY_CONFIG_INCLUDE_DIR}") + message(STATUS "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") + message(STATUS "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}") + message(STATUS "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}") + message(STATUS "Ruby_HDR_DIR: ${Ruby_HDR_DIR}") + message(STATUS "Ruby_POSSIBLE_LIB_DIR: ${Ruby_POSSIBLE_LIB_DIR}") + message(STATUS "Found Ruby_VERSION: \"${Ruby_VERSION}\" , short: \"${_Ruby_VERSION_SHORT}\", nodot: \"${_Ruby_VERSION_SHORT_NODOT}\"") + message(STATUS "_Ruby_REQUIRED_VARS: ${_Ruby_REQUIRED_VARS}") + message(STATUS "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}") + message(STATUS "Ruby_LIBRARY: ${Ruby_LIBRARY}") + message(STATUS "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}") + message(STATUS "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}") message(STATUS "--------------------") endif() -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_RUBY_REQUIRED_VARS} - VERSION_VAR RUBY_VERSION ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_Ruby_REQUIRED_VARS} + VERSION_VAR Ruby_VERSION ) mark_as_advanced( - RUBY_EXECUTABLE - RUBY_LIBRARY - RUBY_INCLUDE_DIR - RUBY_CONFIG_INCLUDE_DIR + Ruby_EXECUTABLE + Ruby_LIBRARY + Ruby_INCLUDE_DIR + Ruby_CONFIG_INCLUDE_DIR ) -# Set some variables for compatibility with previous version of this file -set(RUBY_POSSIBLE_LIB_PATH ${RUBY_POSSIBLE_LIB_DIR}) -set(RUBY_RUBY_LIB_PATH ${RUBY_RUBY_LIB_DIR}) -set(RUBY_INCLUDE_PATH ${RUBY_INCLUDE_DIRS}) +# Set some variables for compatibility with previous version of this file (no need to provide a CamelCase version of that...) +set(RUBY_POSSIBLE_LIB_PATH ${Ruby_POSSIBLE_LIB_DIR}) +set(RUBY_RUBY_LIB_PATH ${Ruby_RUBY_LIB_DIR}) +set(RUBY_INCLUDE_PATH ${Ruby_INCLUDE_DIRS}) + +# Backwards compatibility +# Define upper case versions of output variables +foreach(Camel + Ruby_EXECUTABLE + Ruby_INCLUDE_DIRS + Ruby_LIBRARY + Ruby_VERSION + Ruby_VERSION_MAJOR + Ruby_VERSION_MINOR + Ruby_VERSION_PATCH + Ruby_INCLUDE_PATH + + Ruby_ARCH_DIR + Ruby_ARCH + Ruby_HDR_DIR + Ruby_ARCHHDR_DIR + Ruby_POSSIBLE_LIB_DIR + Ruby_RUBY_LIB_DIR + Ruby_SITEARCH_DIR + Ruby_SITELIB_DIR + Ruby_HAS_VENDOR_RUBY + Ruby_VENDORARCH_DIR + + ) + string(TOUPPER ${Camel} UPPER) + set(${UPPER} ${${Camel}}) +endforeach() diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index ae6ae56..2fded49 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -5,25 +5,49 @@ FindSWIG -------- -Find Simplified Wrapper and Interface Generator (SWIG) +Find the Simplified Wrapper and Interface Generator (SWIG_) executable. -This module finds an installed SWIG. It sets the following variables: - -:: - - SWIG_FOUND - set to "True" if SWIG is found - SWIG_DIR - the directory where swig is installed - SWIG_EXECUTABLE - the path to the swig executable - SWIG_VERSION - the version number of the swig executable +This module finds an installed SWIG and determines its version. If a +``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` argument is given to ``find_package``, +it will also determine supported target languages. The module sents the +following variables: +``SWIG_FOUND`` + Whether SWIG and any required components were found on the system. +``SWIG_EXECUTABLE`` + Path to the SWIG executable. +``SWIG_DIR`` + Path to the installed SWIG ``Lib`` directory (result of ``swig -swiglib``). +``SWIG_VERSION`` + SWIG executable version (result of ``swig -version``). +``SWIG_<lang>_FOUND`` + If ``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` are requested, each available + target language ``<lang>`` (lowercase) will be set to TRUE. -The minimum required version of SWIG can be specified using the -standard syntax, e.g. :command:`find_package(SWIG 1.1)` +Any ``COMPONENTS`` given to ``find_package`` should be the names of supported +target languages as provided to the LANGUAGE argument of ``swig_add_library``, +such as ``python`` or ``perl5``. Language names *must* be lowercase. All information is collected from the ``SWIG_EXECUTABLE``, so the version to be found can be changed from the command line by means of setting -``SWIG_EXECUTABLE`` +``SWIG_EXECUTABLE``. + +Example usage requiring SWIG 4.0 or higher and Python language support, with +optional Fortran support: + +.. code-block:: cmake + + find_package(SWIG 4.0 COMPONENTS python OPTIONAL_COMPONENTS fortran) + if(SWIG_FOUND) + message("SWIG found: ${SWIG_EXECUTABLE}") + if(NOT SWIG_fortran_FOUND) + message(WARNING "SWIG Fortran bindings cannot be generated") + endif() + endif() + +.. _`SWIG`: http://swig.org + #]=======================================================================] find_program(SWIG_EXECUTABLE NAMES swig4.0 swig3.0 swig2.0 swig) @@ -58,10 +82,29 @@ if(SWIG_EXECUTABLE) endif() endif() endif() + + if(SWIG_FIND_COMPONENTS) + execute_process(COMMAND ${SWIG_EXECUTABLE} -help + OUTPUT_VARIABLE SWIG_swighelp_output + ERROR_VARIABLE SWIG_swighelp_error + RESULT_VARIABLE SWIG_swighelp_result) + if(SWIG_swighelp_result) + message(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -help\" failed with output:\n${SWIG_swiglib_error}") + else() + string(REPLACE "\n" ";" SWIG_swighelp_output "${SWIG_swighelp_output}") + foreach(SWIG_line IN LISTS SWIG_swighelp_output) + if(SWIG_line MATCHES "-([A-Za-z0-9_]+) +- *Generate.*wrappers") + set(SWIG_${CMAKE_MATCH_1}_FOUND TRUE) + endif() + endforeach() + endif() + endif() endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR - VERSION_VAR SWIG_VERSION ) +find_package_handle_standard_args( + SWIG HANDLE_COMPONENTS + REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR + VERSION_VAR SWIG_VERSION) mark_as_advanced(SWIG_DIR SWIG_VERSION SWIG_EXECUTABLE) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 85174d9..f97e5c8 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -7,31 +7,44 @@ FindThreads This module determines the thread library of the system. -The following variables are set +Imported Targets +^^^^^^^^^^^^^^^^ -:: +This module defines the following :prop_tgt:`IMPORTED` target: - CMAKE_THREAD_LIBS_INIT - the thread library - CMAKE_USE_WIN32_THREADS_INIT - using WIN32 threads? - CMAKE_USE_PTHREADS_INIT - are we using pthreads - CMAKE_HP_PTHREADS_INIT - are we using hp pthreads +``Threads::Threads`` + The thread library, if found. -The following import target is created +Result Variables +^^^^^^^^^^^^^^^^ -:: +The following variables are set: - Threads::Threads +``Threads_FOUND`` + If a supported thread library was found. +``CMAKE_THREAD_LIBS_INIT`` + The thread library to use. This may be empty if the thread functions + are provided by the system libraries and no special flags are needed + to use them. +``CMAKE_USE_WIN32_THREADS_INIT`` + If the found thread library is the win32 one. +``CMAKE_USE_PTHREADS_INIT`` + If the found thread library is pthread compatible. +``CMAKE_HP_PTHREADS_INIT`` + If the found thread library is the HP thread library. -If the use of the -pthread compiler and linker flag is preferred then the -caller can set +Variables Affecting Behavior +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:: +.. variable:: THREADS_PREFER_PTHREAD_FLAG - THREADS_PREFER_PTHREAD_FLAG + If the use of the -pthread compiler and linker flag is preferred then + the caller can set this variable to TRUE. The compiler flag can only be + used with the imported target. Use of both the imported target as well + as this switch is highly recommended for new code. -The compiler flag can only be used with the imported -target. Use of both the imported target as well as this switch is highly -recommended for new code. + This variable has no effect if the system libraries provide the + thread functions, i.e. when ``CMAKE_THREAD_LIBS_INIT`` will be empty. #]=======================================================================] include (CheckLibraryExists) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index b28dd12..aa83575 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -25,6 +25,10 @@ and also the following more fine grained variables and targets: X11_Xaccessrules_INCLUDE_PATH, X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND X11_Xau_INCLUDE_PATH, X11_Xau_LIB, X11_Xau_FOUND, X11::Xau + X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb + X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb + X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm + X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor X11_Xdamage_INCLUDE_PATH, X11_Xdamage_LIB, X11_Xdamage_FOUND, X11::Xdamage @@ -38,6 +42,8 @@ and also the following more fine grained variables and targets: X11_Xinerama_INCLUDE_PATH, X11_Xinerama_LIB, X11_Xinerama_FOUND, X11::Xinerama X11_Xkb_INCLUDE_PATH, X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND, X11::Xkb + X11_xkbcommon_INCLUDE_PATH, X11_xkbcommon_LIB, X11_xkbcommon_FOUND, X11::xkbcommon + X11_xkbcommon_X11_INCLUDE_PATH,X11_xkbcommon_X11_LIB,X11_xkbcommon_X11_FOUND,X11::xkbcommon_X11 X11_xkbfile_INCLUDE_PATH, X11_xkbfile_LIB, X11_xkbfile_FOUND, X11::xkbfile X11_Xmu_INCLUDE_PATH, X11_Xmu_LIB, X11_Xmu_FOUND, X11::Xmu X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND, X11::Xpm @@ -94,6 +100,9 @@ if (UNIX) find_path(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h ${X11_INC_SEARCH_PATH}) + find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH}) @@ -107,6 +116,8 @@ if (UNIX) find_path(X11_Xi_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xinerama_INCLUDE_PATH X11/extensions/Xinerama.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xkbcommon_INCLUDE_PATH xkbcommon/xkbcommon.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xkbcommon_X11_INCLUDE_PATH xkbcommon/xkbcommon-x11.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h ${X11_INC_SEARCH_PATH}) find_path(X11_xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xmu_INCLUDE_PATH X11/Xmu/Xmu.h ${X11_INC_SEARCH_PATH}) @@ -137,6 +148,10 @@ if (UNIX) find_library(X11_ICE_LIB ICE ${X11_LIB_SEARCH_PATH}) find_library(X11_SM_LIB SM ${X11_LIB_SEARCH_PATH}) find_library(X11_Xau_LIB Xau ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH}) + find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) find_library(X11_Xdamage_LIB Xdamage ${X11_LIB_SEARCH_PATH}) @@ -146,6 +161,8 @@ if (UNIX) find_library(X11_Xft_LIB Xft ${X11_LIB_SEARCH_PATH}) find_library(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) find_library(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) + find_library(X11_xkbcommon_LIB xkbcommon ${X11_LIB_SEARCH_PATH}) + find_library(X11_xkbcommon_X11_LIB xkbcommon-x11 ${X11_LIB_SEARCH_PATH}) find_library(X11_xkbfile_LIB xkbfile ${X11_LIB_SEARCH_PATH}) find_library(X11_Xmu_LIB Xmu ${X11_LIB_SEARCH_PATH}) find_library(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) @@ -221,6 +238,22 @@ if (UNIX) set(X11_Xau_FOUND TRUE) endif () + if (X11_xcb_LIB AND X11_xcb_INCLUDE_PATH) + set(X11_xcb_FOUND TRUE) + endif () + + if (X11_X11_xcb_LIB AND X11_X11_xcb_INCLUDE_PATH) + set(X11_X11_xcb_FOUND TRUE) + endif () + + if (X11_xcb_icccm_LIB AND X11_xcb_icccm_INCLUDE_PATH) + set(X11_xcb_icccm_FOUND TRUE) + endif () + + if (X11_xcb_xkb_LIB) + set(X11_xcb_xkb_FOUND TRUE) + endif () + if (X11_Xdmcp_INCLUDE_PATH AND X11_Xdmcp_LIB) set(X11_Xdmcp_FOUND TRUE) list(APPEND X11_INCLUDE_DIR ${X11_Xdmcp_INCLUDE_PATH}) @@ -326,6 +359,14 @@ if (UNIX) list(APPEND X11_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH} ) endif () + if (X11_xkbcommon_INCLUDE_PATH AND X11_xkbcommon_LIB) + set(X11_xkbcommon_FOUND TRUE) + endif () + + if (X11_xkbcommon_X11_INCLUDE_PATH AND X11_xkbcommon_X11_LIB) + set(X11_xkbcommon_X11_FOUND TRUE) + endif () + if (X11_xkbfile_INCLUDE_PATH AND X11_xkbfile_LIB AND X11_Xlib_INCLUDE_PATH) set(X11_xkbfile_FOUND TRUE) # Backwards compatibility. @@ -478,6 +519,35 @@ if (UNIX) INTERFACE_INCLUDE_DIRECTORIES "${X11_Xau_INCLUDE_PATH}") endif () + if (X11_xcb_FOUND AND NOT TARGET X11::xcb) + add_library(X11::xcb UNKNOWN IMPORTED) + set_target_properties(X11::xcb PROPERTIES + IMPORTED_LOCATION "${X11_xcb_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_xcb_INCLUDE_PATH}") + endif () + + if (X11_X11_xcb_FOUND AND NOT TARGET X11::X11_xcb) + add_library(X11::X11_xcb UNKNOWN IMPORTED) + set_target_properties(X11::X11_xcb PROPERTIES + IMPORTED_LOCATION "${X11_X11_xcb_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_X11_xcb_INCLUDE_PATH}" + INTERFACE_LINK_LIBRARIES "X11::xcb;X11::X11") + endif () + + if (X11_xcb_icccm_FOUND AND NOT TARGET X11::xcb_icccm) + add_library(X11::xcb_icccm UNKNOWN IMPORTED) + set_target_properties(X11::xcb_icccm PROPERTIES + IMPORTED_LOCATION "${X11_xcb_icccm_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) + add_library(X11::xcb_xkb UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xkb PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xkb_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_Xcomposite_FOUND AND NOT TARGET X11::Xcomposite) add_library(X11::Xcomposite UNKNOWN IMPORTED) set_target_properties(X11::Xcomposite PROPERTIES @@ -572,6 +642,21 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::X11") endif () + if (X11_xkbcommon_FOUND AND NOT TARGET X11::xkbcommon) + add_library(X11::xkbcommon UNKNOWN IMPORTED) + set_target_properties(X11::xkbcommon PROPERTIES + IMPORTED_LOCATION "${X11_xkbcommon_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbcommon_INCLUDE_PATH}") + endif () + + if (X11_xkbcommon_X11_FOUND AND NOT TARGET X11::xkbcommon_X11) + add_library(X11::xkbcommon_X11 UNKNOWN IMPORTED) + set_target_properties(X11::xkbcommon_X11 PROPERTIES + IMPORTED_LOCATION "${X11_xkbcommon_X11_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${X11_xkbcommon_X11_INCLUDE_PATH}" + INTERFACE_LINK_LIBRARIES "X11::X11;X11::xkbcommon") + endif () + if (X11_xkbfile_FOUND AND NOT TARGET X11::xkbfile) add_library(X11::xkbfile UNKNOWN IMPORTED) set_target_properties(X11::xkbfile PROPERTIES @@ -668,6 +753,11 @@ if (UNIX) X11_Xext_LIB X11_Xau_LIB X11_Xau_INCLUDE_PATH + X11_xcb_LIB + X11_xcb_INCLUDE_PATH + X11_xcb_xkb_LIB + X11_X11_xcb_LIB + X11_X11_xcb_INCLUDE_PATH X11_Xlib_INCLUDE_PATH X11_Xutil_INCLUDE_PATH X11_Xcomposite_INCLUDE_PATH @@ -704,6 +794,10 @@ if (UNIX) X11_Xdmcp_INCLUDE_PATH X11_Xkb_INCLUDE_PATH X11_Xkblib_INCLUDE_PATH + X11_xkbcommon_INCLUDE_PATH + X11_xkbcommon_LIB + X11_xkbcommon_X11_INCLUDE_PATH + X11_xkbcommon_X11_LIB X11_xkbfile_INCLUDE_PATH X11_xkbfile_LIB X11_Xmu_INCLUDE_PATH diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 381080b..13e4498 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -101,3 +101,7 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1) # Require symbols through Fortran. add_executable(FortranCInterface main.F call_sub.f ${call_mod}) target_link_libraries(FortranCInterface PUBLIC symbols) + +file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[ +set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>") +]]) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 33de6c6..c75067b 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -43,17 +43,11 @@ set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED}) unset(FortranCInterface_COMPILED CACHE) # Locate the sample project executable. +set(FortranCInterface_EXE) if(FortranCInterface_COMPILED) - find_program(FortranCInterface_EXE - NAMES FortranCInterface${CMAKE_EXECUTABLE_SUFFIX} - PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Release - NO_DEFAULT_PATH - ) - set(FortranCInterface_EXE ${FortranCInterface_EXE}) - unset(FortranCInterface_EXE CACHE) + include(${FortranCInterface_BINARY_DIR}/exe-Release.cmake OPTIONAL) else() set(_result "Failed to compile") - set(FortranCInterface_EXE) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Fortran/C interface test project failed with the following output:\n" "${FortranCInterface_OUTPUT}\n") diff --git a/Modules/GoogleTest.cmake b/Modules/GoogleTest.cmake index a5bb863..1d4398e 100644 --- a/Modules/GoogleTest.cmake +++ b/Modules/GoogleTest.cmake @@ -151,6 +151,7 @@ same as the Google Test name (i.e. ``suite.testcase``); see also [PROPERTIES name1 value1...] [TEST_LIST var] [DISCOVERY_TIMEOUT seconds] + [XML_OUTPUT_DIR dir] ) ``gtest_discover_tests`` sets up a post-build command on the test executable @@ -236,6 +237,13 @@ same as the Google Test name (i.e. ``suite.testcase``); see also problem. The ambiguous behavior of the ``TIMEOUT`` keyword in 3.10.1 and 3.10.2 has not been preserved. + ``XML_OUTPUT_DIR dir`` + If specified, the parameter is passed along with ``--gtest_output=xml:`` + to test executable. The actual file name is the same as the test target, + including prefix and suffix. This should be used instead of + ``EXTRA_ARGS --gtest_output=xml`` to avoid race conditions writing the + XML result output when using parallel test execution. + #]=======================================================================] # Save project's policies @@ -372,7 +380,7 @@ function(gtest_discover_tests TARGET) cmake_parse_arguments( "" "NO_PRETTY_TYPES;NO_PRETTY_VALUES" - "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;DISCOVERY_TIMEOUT;XML_OUTPUT_DIR" "EXTRA_ARGS;PROPERTIES" ${ARGN} ) @@ -434,6 +442,7 @@ function(gtest_discover_tests TARGET) -D "TEST_LIST=${_TEST_LIST}" -D "CTEST_FILE=${ctest_tests_file}" -D "TEST_DISCOVERY_TIMEOUT=${_DISCOVERY_TIMEOUT}" + -D "TEST_XML_OUTPUT_DIR=${_XML_OUTPUT_DIR}" -P "${_GOOGLETEST_DISCOVER_TESTS_SCRIPT}" VERBATIM ) diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake index 4abbbec..753319f 100644 --- a/Modules/GoogleTestAddTests.cmake +++ b/Modules/GoogleTestAddTests.cmake @@ -1,6 +1,8 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. +cmake_minimum_required(VERSION ${CMAKE_VERSION}) + set(prefix "${TEST_PREFIX}") set(suffix "${TEST_SUFFIX}") set(extra_args ${TEST_EXTRA_ARGS}) @@ -8,18 +10,43 @@ set(properties ${TEST_PROPERTIES}) set(script) set(suite) set(tests) +set(tests_buffer) + +# Overwrite possibly existing ${CTEST_FILE} with empty file +set(flush_tests_MODE WRITE) + +# Flushes script to ${CTEST_FILE} +macro(flush_script) + file(${flush_tests_MODE} "${CTEST_FILE}" "${script}") + set(flush_tests_MODE APPEND) + + set(script "") +endmacro() + +# Flushes tests_buffer to tests +macro(flush_tests_buffer) + list(APPEND tests "${tests_buffer}") + set(tests_buffer "") +endmacro() -function(add_command NAME) +macro(add_command NAME) set(_args "") foreach(_arg ${ARGN}) if(_arg MATCHES "[^-./:a-zA-Z0-9_]") - set(_args "${_args} [==[${_arg}]==]") + string(APPEND _args " [==[${_arg}]==]") else() - set(_args "${_args} ${_arg}") + string(APPEND _args " ${_arg}") endif() endforeach() - set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) -endfunction() + string(APPEND script "${NAME}(${_args})\n") + string(LENGTH "${script}" _script_len) + if(${_script_len} GREATER "50000") + flush_script() + endif() + # Unsets macro local variables to prevent leakage outside of this macro. + unset(_args) + unset(_script_len) +endmacro() # Run test executable to get list of available tests if(NOT EXISTS "${TEST_EXECUTABLE}") @@ -72,6 +99,11 @@ foreach(line ${output}) endif() string(REGEX REPLACE "^DISABLED_" "" pretty_test "${pretty_test}") string(REGEX REPLACE "#.*" "" test "${test}") + if(NOT TEST_XML_OUTPUT_DIR STREQUAL "") + set(TEST_XML_OUTPUT_PARAM "--gtest_output=xml:${TEST_XML_OUTPUT_DIR}/${prefix}${pretty_suite}.${pretty_test}${suffix}.xml") + else() + unset(TEST_XML_OUTPUT_PARAM) + endif() # ...and add to script add_command(add_test "${prefix}${pretty_suite}.${pretty_test}${suffix}" @@ -79,6 +111,7 @@ foreach(line ${output}) "${TEST_EXECUTABLE}" "--gtest_filter=${suite}.${test}" "--gtest_also_run_disabled_tests" + ${TEST_XML_OUTPUT_PARAM} ${extra_args} ) if(suite MATCHES "^DISABLED" OR test MATCHES "^DISABLED") @@ -93,14 +126,20 @@ foreach(line ${output}) WORKING_DIRECTORY "${TEST_WORKING_DIR}" ${properties} ) - list(APPEND tests "${prefix}${pretty_suite}.${pretty_test}${suffix}") + list(APPEND tests_buffer "${prefix}${pretty_suite}.${pretty_test}${suffix}") + list(LENGTH tests_buffer tests_buffer_length) + if(${tests_buffer_length} GREATER "250") + flush_tests_buffer() + endif() endif() endif() endforeach() + # Create a list of all discovered tests, which users may use to e.g. set # properties on the tests +flush_tests_buffer() add_command(set ${TEST_LIST} ${tests}) # Write CTest script -file(WRITE "${CTEST_FILE}" "${script}") +flush_script() diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index 1f4bcfd..20eed2e 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -287,7 +287,11 @@ if(CPACK_NUGET_ORDINAL_MONOLITIC) execute_process( COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE _nuget_result ) + if(NOT _nuget_result EQUAL 0) + message(FATAL_ERROR "Nuget pack failed") + endif() elseif(CPACK_NUGET_ALL_IN_ONE) # This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code: @@ -300,7 +304,11 @@ elseif(CPACK_NUGET_ALL_IN_ONE) execute_process( COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE _nuget_result ) + if(NOT _nuget_result EQUAL 0) + message(FATAL_ERROR "Nuget pack failed") + endif() else() # Is there any grouped component? @@ -322,7 +330,11 @@ else() execute_process( COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE _nuget_result ) + if(NOT _nuget_result EQUAL 0) + message(FATAL_ERROR "Nuget pack failed") + endif() endforeach() endif() # Is there any single component package needed? @@ -341,7 +353,11 @@ else() execute_process( COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS} WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE _nuget_result ) + if(NOT _nuget_result EQUAL 0) + message(FATAL_ERROR "Nuget pack failed") + endif() endforeach() endif() endif() diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 3485e7d..08bbc68 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1099,16 +1099,18 @@ function(cpack_rpm_generate_package) # CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE) # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE) - # May be used to embed a post (un)installation script in the spec file. + # CPACK_RPM_POST_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE) + # May be used to embed a post installation/uninstallation/transaction script in the spec file. # The referred script file(s) will be read and directly - # put after the %post or %postun section + # put after the %post or %postun or %posttrans section # ---------------------------------------------------------------- # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE) # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE) - # May be used to embed a pre (un)installation script in the spec file. + # CPACK_RPM_PRE_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE) + # May be used to embed a pre installation/uninstallation/transaction script in the spec file. # The referred script file(s) will be read and directly - # put after the %pre or %preun section - foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL") + # put after the %pre or %preun or %pretrans section + foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL" "TRANS") foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST") set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE" "${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}") @@ -1727,12 +1729,18 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT \@RPM_SYMLINK_POSTINSTALL\@ \@CPACK_RPM_SPEC_POSTINSTALL\@ +%posttrans +\@CPACK_RPM_SPEC_POSTTRANS\@ + %postun \@CPACK_RPM_SPEC_POSTUNINSTALL\@ %pre \@CPACK_RPM_SPEC_PREINSTALL\@ +%pretrans +\@CPACK_RPM_SPEC_PRETRANS\@ + %preun \@CPACK_RPM_SPEC_PREUNINSTALL\@ diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index 96b1760..5d8f7fc 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -11,7 +11,7 @@ set(__WINDOWS_INTEL 1) include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - string(REPLACE "<CMAKE_LINKER> /lib" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") + string(REPLACE "<CMAKE_AR>" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") foreach(rule CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) string(REPLACE "<CMAKE_LINKER>" "xilink" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") endforeach() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e1d6733..7ee501b 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -316,7 +316,7 @@ macro(__windows_compiler_msvc lang) "${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_AR> ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") set(CMAKE_${lang}_COMPILE_OBJECT "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <DEFINES> <INCLUDES> <FLAGS> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}") diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index f809094..2f50280 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -1,11 +1,11 @@ include(Platform/Windows-MSVC) set(CMAKE_CUDA_COMPILE_PTX_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -ptx <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -dc <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(CMAKE_CUDA_COMPILE_WHOLE_COMPILATION - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> -x cu -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -c <SOURCE> -o <OBJECT> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS") set(__IMPLICT_LINKS ) foreach(dir ${CMAKE_CUDA_HOST_IMPLICIT_LINK_DIRECTORIES}) @@ -23,7 +23,7 @@ set(CMAKE_CUDA_CREATE_SHARED_LIBRARY "${_CMAKE_VS_LINK_DLL}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /dll /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY}) -set(CMAKE_CUDA_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") +set(CMAKE_CUDA_CREATE_STATIC_LIBRARY "<CMAKE_AR> ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") set(CMAKE_CUDA_LINKER_SUPPORTS_PDB ON) set(CMAKE_CUDA_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <LINK_FLAGS> <LINK_LIBRARIES>${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}") @@ -48,7 +48,7 @@ unset(__IMPLICT_DLINK_DIRS) set(CMAKE_CUDA_DEVICE_LINK_LIBRARY "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <LANGUAGE_COMPILE_FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") set(CMAKE_CUDA_DEVICE_LINK_EXECUTABLE - "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") + "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <FLAGS> ${_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS} -shared -dlink <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -Xcompiler=-Fd<TARGET_COMPILE_PDB>,-FS${__IMPLICT_DLINK_FLAGS}") unset(__IMPLICT_DLINK_FLAGS) string(REPLACE "/D" "-D" _PLATFORM_DEFINES_CUDA "${_PLATFORM_DEFINES}${_PLATFORM_DEFINES_CXX}") diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 78522da..f6a20f8 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -341,6 +341,23 @@ function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) list(APPEND files "${extra_file}") endforeach() + if (language STREQUAL "FORTRAN" AND CMAKE_Fortran_COMPILER_LOADED) + # Process possible user-supplied extension in flags (obtained via parent + # scope variable) to determine the source file name. + list(FIND SWIG_COMPILATION_FLAGS "-fext" fext_idx) + if (fext_idx EQUAL -1) + # Default Fortran generated extension + set(fext "f90") + else() + # Get extension from user-provided flag + math(EXPR fext_idx "${fext_idx} + 1") + list(GET SWIG_COMPILATION_FLAGS "${fext_idx}" fext) + endif() + set(extra_file "${generatedpath}/${module_basename}.${fext}") + set_source_files_properties("${extra_file}" PROPERTIES LANGUAGE "Fortran") + list(APPEND files "${extra_file}") + endif() + set (${outfiles} ${files} PARENT_SCOPE) endfunction() @@ -415,6 +432,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE) if (NOT SWIG_MODULE_${name}_NOPROXY) + set(SWIG_COMPILATION_FLAGS ${swig_source_file_flags}) SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE} swig_extra_generated_files "${outdir}" @@ -787,6 +805,8 @@ function(SWIG_ADD_LIBRARY name) if (APPLE) set_target_properties (${target_name} PROPERTIES SUFFIX ".dylib") endif () + elseif (swig_lowercase_language STREQUAL "fortran") + # Do *not* override the target's library prefix else() # assume empty prefix because we expect the module to be dynamically loaded set_target_properties (${target_name} PROPERTIES PREFIX "") |