summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/BundleUtilities.cmake11
-rw-r--r--Modules/CheckIPOSupported.cmake2
-rw-r--r--Modules/CheckPIESupported.cmake134
-rw-r--r--Modules/Compiler/AppleClang-C.cmake3
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake3
-rw-r--r--Modules/Compiler/Clang.cmake20
-rw-r--r--Modules/Compiler/GNU.cmake19
-rw-r--r--Modules/Compiler/SunPro-C.cmake1
-rw-r--r--Modules/Compiler/SunPro-CXX.cmake1
-rw-r--r--Modules/Compiler/SunPro-Fortran.cmake1
-rw-r--r--Modules/Compiler/XL.cmake2
-rw-r--r--Modules/ExternalProject.cmake51
-rw-r--r--Modules/FeatureSummary.cmake2
-rw-r--r--Modules/FindBISON.cmake38
-rw-r--r--Modules/FindIce.cmake4
-rw-r--r--Modules/FindLibLZMA.cmake58
-rw-r--r--Modules/FindProtobuf.cmake2
-rw-r--r--Modules/FindThreads.cmake5
-rw-r--r--Modules/GetPrerequisites.cmake38
-rw-r--r--Modules/GoogleTestAddTests.cmake1
-rw-r--r--Modules/Internal/CMakeCheckCompilerFlag.cmake26
-rw-r--r--Modules/Platform/CYGWIN-GNU.cmake1
-rw-r--r--Modules/Platform/Fuchsia.cmake1
-rw-r--r--Modules/Platform/Linux-Intel.cmake2
-rw-r--r--Modules/Platform/Linux-PGI.cmake1
-rw-r--r--Modules/Platform/SINIX.cmake1
-rw-r--r--Modules/Platform/UNIX_SV.cmake1
-rw-r--r--Modules/Platform/UnixWare.cmake1
-rw-r--r--Modules/Platform/Windows-GNU.cmake1
-rw-r--r--Modules/UseSWIG.cmake26
30 files changed, 365 insertions, 92 deletions
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index 10e5510..8c7646e 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -717,6 +717,9 @@ function(link_resolved_item_into_bundle resolved_item resolved_embedded_item)
else()
get_filename_component(target_dir "${resolved_embedded_item}" DIRECTORY)
file(RELATIVE_PATH symlink_target "${target_dir}" "${resolved_item}")
+ if (NOT EXISTS "${target_dir}")
+ file(MAKE_DIRECTORY "${target_dir}")
+ endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${symlink_target}" "${resolved_embedded_item}")
endif()
endfunction()
@@ -877,9 +880,13 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
execute_process(COMMAND chmod u+w "${resolved_embedded_item}")
endif()
+ # CMAKE_INSTALL_NAME_TOOL may not be set if executed in script mode
+ # Duplicated from CMakeFindBinUtils.cmake
+ find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+
# Only if install_name_tool supports -delete_rpath:
#
- execute_process(COMMAND install_name_tool
+ execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL}
OUTPUT_VARIABLE install_name_tool_usage
ERROR_VARIABLE install_name_tool_usage
)
@@ -897,7 +904,7 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs)
# to install_name_tool:
#
if(changes)
- set(cmd install_name_tool ${changes} "${resolved_embedded_item}")
+ set(cmd ${CMAKE_INSTALL_NAME_TOOL} ${changes} "${resolved_embedded_item}")
execute_process(COMMAND ${cmd} RESULT_VARIABLE install_name_tool_result)
if(NOT install_name_tool_result EQUAL 0)
string(REPLACE ";" "' '" msg "'${cmd}'")
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake
index ad8852c..0d6ad20 100644
--- a/Modules/CheckIPOSupported.cmake
+++ b/Modules/CheckIPOSupported.cmake
@@ -51,8 +51,6 @@ Examples
#]=======================================================================]
-include(CMakeParseArguments) # cmake_parse_arguments
-
# X_RESULT - name of the final result variable
# X_OUTPUT - name of the variable with information about error
macro(_ipo_not_supported output)
diff --git a/Modules/CheckPIESupported.cmake b/Modules/CheckPIESupported.cmake
new file mode 100644
index 0000000..720217d
--- /dev/null
+++ b/Modules/CheckPIESupported.cmake
@@ -0,0 +1,134 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckPIESupported
+-----------------
+
+Check whether the linker supports position independent code (PIE) or no
+position independent code (NO_PIE) for executables.
+Use this to ensure that the :prop_tgt:`POSITION_INDEPENDENT_CODE` target
+property for executables will be honored at link time.
+
+.. command:: check_pie_supported
+
+ ::
+
+ check_pie_supported([OUTPUT_VARIABLE <output>]
+ [LANGUAGES <lang>...])
+
+ Options are:
+
+ ``OUTPUT_VARIABLE <output>``
+ Set ``<output>`` variable with details about any error.
+ ``LANGUAGES <lang>...``
+ Check the linkers used for each of the specified languages.
+ Supported languages are ``C``, ``CXX``, and ``Fortran``.
+
+It makes no sense to use this module when :policy:`CMP0083` is set to ``OLD``,
+so the command will return an error in this case. See policy :policy:`CMP0083`
+for details.
+
+Variables
+^^^^^^^^^
+
+For each language checked, two boolean cache variables are defined.
+
+ ``CMAKE_<lang>_LINK_PIE_SUPPORTED``
+ Set to ``YES`` if ``PIE`` is supported by the linker and ``NO`` otherwise.
+ ``CMAKE_<lang>_LINK_NO_PIE_SUPPORTED``
+ Set to ``YES`` if ``NO_PIE`` is supported by the linker and ``NO`` otherwise.
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ check_pie_supported()
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
+
+.. code-block:: cmake
+
+ # Retrieve any error message.
+ check_pie_supported(OUTPUT_VARIABLE output LANGUAGES C)
+ set_property(TARGET foo PROPERTY POSITION_INDEPENDENT_CODE TRUE)
+ if(NOT CMAKE_C_LINK_PIE_SUPPORTED)
+ message(WARNING "PIE is not supported at link time: ${output}.\n"
+ "PIE link options will not be passed to linker.")
+ endif()
+
+#]=======================================================================]
+
+
+include (Internal/CMakeCheckCompilerFlag)
+
+function (check_pie_supported)
+ cmake_policy(GET CMP0083 cmp0083)
+
+ if (NOT cmp0083)
+ message(FATAL_ERROR "check_pie_supported: Policy CMP0083 is not set")
+ endif()
+
+ if(cmp0083 STREQUAL "OLD")
+ message(FATAL_ERROR "check_pie_supported: Policy CMP0083 set to OLD")
+ endif()
+
+ set(optional)
+ set(one OUTPUT_VARIABLE)
+ set(multiple LANGUAGES)
+
+ cmake_parse_arguments(CHECK_PIE "${optional}" "${one}" "${multiple}" "${ARGN}")
+ if(CHECK_PIE_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "check_pie_supported: Unparsed arguments: ${CHECK_PIE_UNPARSED_ARGUMENTS}")
+ endif()
+
+ if (CHECK_PIE_LANGUAGES)
+ set (unsupported_languages "${CHECK_PIE_LANGUAGES}")
+ list (REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran")
+ if(unsupported_languages)
+ message(FATAL_ERROR "check_pie_supported: language(s) '${unsupported_languages}' not supported")
+ endif()
+ else()
+ # User did not set any languages, use defaults
+ get_property (enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
+ if (NOT enabled_languages)
+ return()
+ endif()
+
+ list (FILTER enabled_languages INCLUDE REGEX "^(C|CXX|Fortran)$")
+ if (NOT enabled_languages)
+ return()
+ endif()
+
+ set (CHECK_PIE_LANGUAGES ${enabled_languages})
+ endif()
+
+ set (outputs)
+
+ foreach(lang IN LISTS CHECK_PIE_LANGUAGES)
+ if(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER)
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_PIE}"
+ CMAKE_${lang}_LINK_PIE_SUPPORTED
+ OUTPUT_VARIABLE output)
+ if (NOT CMAKE_${lang}_LINK_PIE_SUPPORTED)
+ string (APPEND outputs "PIE (${lang}): ${output}\n")
+ endif()
+
+ cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_LINK_OPTIONS_NO_PIE}"
+ CMAKE_${lang}_LINK_NO_PIE_SUPPORTED
+ OUTPUT_VARIABLE output)
+ if (NOT CMAKE_${lang}_LINK_NO_PIE_SUPPORTED)
+ string (APPEND outputs "NO_PIE (${lang}): ${output}\n")
+ endif()
+ else()
+ # no support at link time. Set cache variables to NO
+ set(CMAKE_${lang}_LINK_PIE_SUPPORTED NO CACHE INTERNAL "PIE (${lang})")
+ set(CMAKE_${lang}_LINK_NO_PIE_SUPPORTED NO CACHE INTERNAL "NO_PIE (${lang})")
+ string (APPEND outputs "PIE and NO_PIE are not supported by linker for ${lang}")
+ endif()
+ endforeach()
+
+ if (CHECK_PIE_OUTPUT_VARIABLE)
+ set (${CHECK_PIE_OUTPUT_VARIABLE} "${outputs}" PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake
index 8754951..a48adec 100644
--- a/Modules/Compiler/AppleClang-C.cmake
+++ b/Modules/Compiler/AppleClang-C.cmake
@@ -1,9 +1,6 @@
include(Compiler/Clang)
__compiler_clang(C)
-set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} -Xlinker -pie)
-set(CMAKE_C_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
-
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90")
set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90")
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index 54c1388..e5fd647 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -1,9 +1,6 @@
include(Compiler/Clang)
__compiler_clang(CXX)
-set(CMAKE_CXX_LINK_OPTIONS_PIE ${CMAKE_CXX_COMPILE_OPTIONS_PIE} -Xlinker -pie)
-set(CMAKE_CXX_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
-
if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 7cee9c7..c3f13f3 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -23,23 +23,9 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
# Link options for PIE are already set in 'Compiler/GNU.cmake'
# but clang may require alternate syntax on some platforms
- if (NOT CMAKE_${lang}_FLAG_PIE)
- cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-Xlinker;-pie"
- CMAKE_${lang}_FLAG_XLINKER_PIE)
- if (CMAKE_${lang}_FLAG_XLINKER_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-Xlinker" "-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
- endif()
- endif()
- if (NOT CMAKE_${lang}_FLAG_NO_PIE)
- cmake_check_compiler_flag(${lang} "-Xlinker;-no_pie"
- CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
- if (CMAKE_${lang}_FLAG_XLINKER_NO_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-Xlinker" "-no_pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
- endif()
+ if (APPLE)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} -Xlinker -pie)
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE -Xlinker -no_pie)
endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 688a1b5..6b1bd3a 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -15,23 +15,14 @@ macro(__compiler_gnu lang)
# Feature flags.
set(CMAKE_${lang}_VERBOSE_FLAG "-v")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
# Support of PIE at link stage depends on various elements : platform, compiler, linker
- # so the easiest way is to check if compiler supports these flags
- cmake_check_compiler_flag(${lang} "${CMAKE_${lang}_COMPILE_OPTIONS_PIE};-pie"
- CMAKE_${lang}_FLAG_PIE)
- if (CMAKE_${lang}_FLAG_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
- endif()
- cmake_check_compiler_flag(${lang} "-no-pie" CMAKE_${lang}_FLAG_NO_PIE)
- if (CMAKE_${lang}_FLAG_NO_PIE)
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
- else()
- set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
- endif()
+ # so to activate it, module CheckPIESupported must be used.
+ set (_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
+ set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
+ set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
endif()
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index 75b8fe6..c4aba8e 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -7,6 +7,7 @@ set(CMAKE_C_VERBOSE_FLAG "-#")
set(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_C_LINK_OPTIONS_PIE "")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC")
diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake
index 662ac30..5ce58b2 100644
--- a/Modules/Compiler/SunPro-CXX.cmake
+++ b/Modules/Compiler/SunPro-CXX.cmake
@@ -7,6 +7,7 @@ set(CMAKE_CXX_VERBOSE_FLAG "-v")
set(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC)
set(CMAKE_CXX_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_CXX_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_CXX_LINK_OPTIONS_PIE "")
set(CMAKE_CXX_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC")
diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake
index e110253..0c93c94 100644
--- a/Modules/Compiler/SunPro-Fortran.cmake
+++ b/Modules/Compiler/SunPro-Fortran.cmake
@@ -4,6 +4,7 @@ set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-KPIC")
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_Fortran_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_Fortran_LINK_OPTIONS_PIE "")
set(CMAKE_Fortran_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC")
diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake
index 21fe5e8..68dc28a 100644
--- a/Modules/Compiler/XL.cmake
+++ b/Modules/Compiler/XL.cmake
@@ -48,7 +48,7 @@ macro(__compiler_xl lang)
# files so that we export only the symbols actually provided by the sources.
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
"${CMAKE_XL_CreateExportList} <OBJECT_DIR>/objects.exp <OBJECTS>"
- "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> -Wl,-bE:<OBJECT_DIR>/objects.exp <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
)
endif()
endmacro()
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 93cd74a..e763bab 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -550,6 +550,14 @@ External Project Definition
``LOG_MERGED_STDOUTERR <bool>``
When enabled, the output the step is not split by stdout and stderr.
+ ``LOG_OUTPUT_ON_FAILURE <bool>``
+ This option only has an effect if at least one of the other ``LOG_<step>``
+ options is enabled. If an error occurs for a step which has logging to
+ file enabled, that step's output will be printed to the console if
+ ``LOG_OUTPUT_ON_FAILURE`` is set to true. For cases where a large amount
+ of output is recorded, just the end of that output may be printed to the
+ console.
+
**Terminal Access Options:**
Steps can be given direct access to the terminal in some cases. Giving a
step access to the terminal may allow it to receive terminal input if
@@ -1953,6 +1961,7 @@ endif()
set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake)
set(logbase ${log_dir}/${name}-${step})
get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR)
+ get_property(log_output_on_failure TARGET ${name} PROPERTY _EP_LOG_OUTPUT_ON_FAILURE)
if (log_merged)
set(stdout_log "${logbase}.log")
set(stderr_log "${logbase}.log")
@@ -1961,21 +1970,55 @@ endif()
set(stderr_log "${logbase}-err.log")
endif()
set(code "
+cmake_minimum_required(VERSION 3.13)
${code_cygpath_make}
set(command \"${command}\")
+set(log_merged \"${log_merged}\")
+set(log_output_on_failure \"${log_output_on_failure}\")
+set(stdout_log \"${stdout_log}\")
+set(stderr_log \"${stderr_log}\")
execute_process(
COMMAND \${command}
RESULT_VARIABLE result
- OUTPUT_FILE \"${stdout_log}\"
- ERROR_FILE \"${stderr_log}\"
+ OUTPUT_FILE \"\${stdout_log}\"
+ ERROR_FILE \"\${stderr_log}\"
)
+macro(read_up_to_max_size log_file output_var)
+ file(SIZE \${log_file} determined_size)
+ set(max_size 10240)
+ if (determined_size GREATER max_size)
+ math(EXPR seek_position \"\${determined_size} - \${max_size}\")
+ file(READ \${log_file} \${output_var} OFFSET \${seek_position})
+ set(\${output_var} \"...skipping to end...\\n\${\${output_var}}\")
+ else()
+ file(READ \${log_file} \${output_var})
+ endif()
+endmacro()
if(result)
set(msg \"Command failed: \${result}\\n\")
foreach(arg IN LISTS command)
set(msg \"\${msg} '\${arg}'\")
endforeach()
- set(msg \"\${msg}\\nSee also\\n ${stderr_log}\")
- message(FATAL_ERROR \"\${msg}\")
+ if (\${log_merged})
+ set(msg \"\${msg}\\nSee also\\n \${stderr_log}\")
+ else()
+ set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\")
+ endif()
+ if (\${log_output_on_failure})
+ message(SEND_ERROR \"\${msg}\")
+ if (\${log_merged})
+ read_up_to_max_size(\"\${stderr_log}\" error_log_contents)
+ message(STATUS \"Log output is:\\n\${error_log_contents}\")
+ else()
+ read_up_to_max_size(\"\${stdout_log}\" out_log_contents)
+ read_up_to_max_size(\"\${stderr_log}\" err_log_contents)
+ message(STATUS \"stdout output is:\\n\${out_log_contents}\")
+ message(STATUS \"stderr output is:\\n\${err_log_contents}\")
+ endif()
+ message(FATAL_ERROR \"Stopping after outputting logs.\")
+ else()
+ message(FATAL_ERROR \"\${msg}\")
+ endif()
else()
set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\")
message(STATUS \"\${msg}\")
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index fbce235..4a3e83a 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -97,8 +97,6 @@ Functions
#]=======================================================================]
-include(CMakeParseArguments)
-
function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
get_property(_fsPkgTypes GLOBAL PROPERTY FeatureSummary_PKG_TYPES)
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index d59dc27..06ac2d9 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -151,7 +151,15 @@ if(BISON_EXECUTABLE)
list(APPEND BISON_TARGET_cmdopt "--report-file=${BISON_TARGET_verbose_file}")
endif()
if(NOT IS_ABSOLUTE "${BISON_TARGET_verbose_file}")
- set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_TARGET_verbose_file}")
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_BINARY_DIR}/${BISON_TARGET_verbose_file}")
+ else()
+ set(BISON_TARGET_verbose_file "${CMAKE_CURRENT_SOURCE_DIR}/${BISON_TARGET_verbose_file}")
+ endif()
+ unset(_BISON_CMP0088)
endif()
endmacro()
@@ -159,6 +167,15 @@ if(BISON_EXECUTABLE)
# adds a custom command and sets
# BISON_TARGET_cmdopt, BISON_TARGET_extraoutputs
macro(BISON_TARGET_option_verbose Name BisonOutput filename)
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ unset(_BISON_CMP0088)
+
list(APPEND BISON_TARGET_cmdopt "--verbose")
list(APPEND BISON_TARGET_outputs
"${BISON_TARGET_verbose_file}")
@@ -166,8 +183,9 @@ if(BISON_EXECUTABLE)
if(IS_ABSOLUTE "${filename}")
set(BISON_TARGET_verbose_extra_file "${filename}")
else()
- set(BISON_TARGET_verbose_extra_file "${CMAKE_CURRENT_SOURCE_DIR}/${filename}")
+ set(BISON_TARGET_verbose_extra_file "${_BISON_WORKING_DIRECTORY}/${filename}")
endif()
+
add_custom_command(OUTPUT ${BISON_TARGET_verbose_extra_file}
COMMAND ${CMAKE_COMMAND} -E copy
"${BISON_TARGET_verbose_file}"
@@ -176,10 +194,11 @@ if(BISON_EXECUTABLE)
DEPENDS
"${BISON_TARGET_verbose_file}"
COMMENT "[BISON][${Name}] Copying bison verbose table to ${filename}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ WORKING_DIRECTORY ${_BISON_WORKING_DIRECTORY})
list(APPEND BISON_TARGET_extraoutputs
"${BISON_TARGET_verbose_extra_file}")
unset(BISON_TARGET_verbose_extra_file)
+ unset(_BISON_WORKING_DIRECTORY)
endif()
endmacro()
@@ -234,12 +253,23 @@ if(BISON_EXECUTABLE)
list(APPEND BISON_TARGET_outputs "${BISON_TARGET_output_header}")
+ cmake_policy(GET CMP0088 _BISON_CMP0088
+ PARENT_SCOPE # undocumented, do not use outside of CMake
+ )
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ if("x${_BISON_CMP0088}x" STREQUAL "xNEWx")
+ set(_BISON_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ unset(_BISON_CMP0088)
+
add_custom_command(OUTPUT ${BISON_TARGET_outputs}
COMMAND ${BISON_EXECUTABLE} ${BISON_TARGET_cmdopt} -o ${BisonOutput} ${BisonInput}
VERBATIM
DEPENDS ${BisonInput}
COMMENT "[BISON][${Name}] Building parser with bison ${BISON_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+ WORKING_DIRECTORY ${_BISON_WORKING_DIRECTORY})
+
+ unset(_BISON_WORKING_DIRECTORY)
# define target variables
set(BISON_${Name}_DEFINED TRUE)
diff --git a/Modules/FindIce.cmake b/Modules/FindIce.cmake
index 42d3d47..1e0f0b8 100644
--- a/Modules/FindIce.cmake
+++ b/Modules/FindIce.cmake
@@ -40,6 +40,7 @@ Where ``<C>`` is the name of an Ice component, for example
Ice slice programs are reported in::
+ Ice_SLICE2CONFLUENCE_EXECUTABLE - path to slice2confluence executable
Ice_SLICE2CPP_EXECUTABLE - path to slice2cpp executable
Ice_SLICE2CS_EXECUTABLE - path to slice2cs executable
Ice_SLICE2FREEZEJ_EXECUTABLE - path to slice2freezej executable
@@ -47,6 +48,7 @@ Ice slice programs are reported in::
Ice_SLICE2HTML_EXECUTABLE - path to slice2html executable
Ice_SLICE2JAVA_EXECUTABLE - path to slice2java executable
Ice_SLICE2JS_EXECUTABLE - path to slice2js executable
+ Ice_SLICE2MATLAB_EXECUTABLE - path to slice2matlab executable
Ice_SLICE2OBJC_EXECUTABLE - path to slice2objc executable
Ice_SLICE2PHP_EXECUTABLE - path to slice2php executable
Ice_SLICE2PY_EXECUTABLE - path to slice2py executable
@@ -185,6 +187,7 @@ Other variables one may set to control this module are::
icestormmigrate)
set(_Ice_slice_programs
+ slice2confluence
slice2cpp
slice2cs
slice2freezej
@@ -192,6 +195,7 @@ Other variables one may set to control this module are::
slice2html
slice2java
slice2js
+ slice2matlab
slice2objc
slice2php
slice2py
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index 6d30e57..6225744 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -5,22 +5,40 @@
FindLibLZMA
-----------
-Find LibLZMA
+Find LZMA compression algorithm headers and library.
-Find LibLZMA headers and library
-::
+Imported Targets
+^^^^^^^^^^^^^^^^
- LIBLZMA_FOUND - True if liblzma is found.
- LIBLZMA_INCLUDE_DIRS - Directory where liblzma headers are located.
- LIBLZMA_LIBRARIES - Lzma libraries to link against.
- LIBLZMA_HAS_AUTO_DECODER - True if lzma_auto_decoder() is found (required).
- LIBLZMA_HAS_EASY_ENCODER - True if lzma_easy_encoder() is found (required).
- LIBLZMA_HAS_LZMA_PRESET - True if lzma_lzma_preset() is found (required).
- LIBLZMA_VERSION_MAJOR - The major version of lzma
- LIBLZMA_VERSION_MINOR - The minor version of lzma
- LIBLZMA_VERSION_PATCH - The patch version of lzma
- LIBLZMA_VERSION_STRING - version number as a string (ex: "5.0.3")
+This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if
+liblzma has been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``LIBLZMA_FOUND``
+ True if liblzma headers and library were found.
+``LIBLZMA_INCLUDE_DIRS``
+ Directory where liblzma headers are located.
+``LIBLZMA_LIBRARIES``
+ Lzma libraries to link against.
+``LIBLZMA_HAS_AUTO_DECODER``
+ True if lzma_auto_decoder() is found (required).
+``LIBLZMA_HAS_EASY_ENCODER``
+ True if lzma_easy_encoder() is found (required).
+``LIBLZMA_HAS_LZMA_PRESET``
+ True if lzma_lzma_preset() is found (required).
+``LIBLZMA_VERSION_MAJOR``
+ The major version of lzma
+``LIBLZMA_VERSION_MINOR``
+ The minor version of lzma
+``LIBLZMA_VERSION_PATCH``
+ The patch version of lzma
+``LIBLZMA_VERSION_STRING``
+ version number as a string (ex: "5.0.3")
#]=======================================================================]
find_path(LIBLZMA_INCLUDE_DIR lzma.h )
@@ -51,17 +69,23 @@ if (LIBLZMA_LIBRARY)
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZMA REQUIRED_VARS LIBLZMA_INCLUDE_DIR
- LIBLZMA_LIBRARY
+find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
+ LIBLZMA_INCLUDE_DIR
LIBLZMA_HAS_AUTO_DECODER
LIBLZMA_HAS_EASY_ENCODER
LIBLZMA_HAS_LZMA_PRESET
VERSION_VAR LIBLZMA_VERSION_STRING
)
+mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
if (LIBLZMA_FOUND)
set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
+ if(NOT TARGET LibLZMA::LibLZMA)
+ add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
+ IMPORTED_LINK_INTERFACE_LANGUAGES C
+ IMPORTED_LOCATION ${LIBLZMA_LIBRARY})
+ endif()
endif ()
-
-mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 593fff6..1758fb3 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -121,8 +121,6 @@ Example:
#]=======================================================================]
function(protobuf_generate)
- include(CMakeParseArguments)
-
set(_options APPEND_PATH DESCRIPTORS)
set(_singleargs LANGUAGE OUT_VAR EXPORT_MACRO PROTOC_OUT_DIR)
if(COMMAND target_sources)
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index 9c96a1b..5d894c8 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -29,9 +29,12 @@ caller can set
THREADS_PREFER_PTHREAD_FLAG
-Please note that the compiler flag can only be used with the imported
+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 module is not needed for C++11 and later if threading is done using
+``std::thread`` from the standard library.
#]=======================================================================]
include (CheckLibraryExists)
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index 5b32f7c..fa6d75a 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -63,6 +63,9 @@ searched first when a target without any path info is given. Then
standard system locations are also searched: PATH, Framework
locations, /usr/lib...
+The variable GET_PREREQUISITES_VERBOSE can be set to true to enable verbose
+output.
+
::
LIST_PREREQUISITES(<target> [<recurse> [<exclude_system> [<verbose>]]])
@@ -644,6 +647,10 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(rpaths "")
endif()
+ if(GET_PREREQUISITES_VERBOSE)
+ set(verbose 1)
+ endif()
+
if(NOT IS_ABSOLUTE "${target}")
message("warning: target '${target}' is not absolute...")
endif()
@@ -653,6 +660,15 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
return()
endif()
+ # Check for a script by extension (.bat,.sh,...) or if the file starts with "#!" (shebang)
+ file(READ ${target} file_contents LIMIT 5)
+ if(target MATCHES "\\.(bat|c?sh|bash|ksh|cmd)$" OR file_contents MATCHES "^#!")
+ message(STATUS "GetPrequisites(${target}) : ignoring script file")
+ # Clear var
+ set(${prerequisites_var} "" PARENT_SCOPE)
+ return()
+ endif()
+
set(gp_cmd_paths ${gp_cmd_paths}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\14.0;InstallDir]/../../VC/bin"
"$ENV{VS140COMNTOOLS}/../../VC/bin"
@@ -711,25 +727,25 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
set(gp_cmd_maybe_filter) # optional command to pre-filter gp_tool results
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(gp_cmd_args "")
set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$")
set(gp_regex_error "not found${eol_char}$")
set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$")
set(gp_regex_cmp_count 1)
- elseif(gp_tool STREQUAL "otool")
+ elseif(gp_tool MATCHES "otool$")
set(gp_cmd_args "-L")
set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$")
set(gp_regex_error "")
set(gp_regex_fallback "")
set(gp_regex_cmp_count 3)
- elseif(gp_tool STREQUAL "dumpbin")
+ elseif(gp_tool MATCHES "dumpbin$")
set(gp_cmd_args "/dependents")
set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "")
set(gp_regex_fallback "")
set(gp_regex_cmp_count 1)
- elseif(gp_tool STREQUAL "objdump")
+ elseif(gp_tool MATCHES "objdump$")
set(gp_cmd_args "-p")
set(gp_regex "^\t*DLL Name: (.*\\.[Dd][Ll][Ll])${eol_char}$")
set(gp_regex_error "")
@@ -752,7 +768,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# When running dumpbin, it also needs the "Common7/IDE" directory in the
# PATH. It will already be in the PATH if being run from a Visual Studio
# command prompt. Add it to the PATH here in case we are running from a
@@ -781,7 +797,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
#
# </setup-gp_tool-vars>
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(old_ld_env "$ENV{LD_LIBRARY_PATH}")
set(new_ld_env "${exepath}")
foreach(dir ${dirs})
@@ -806,7 +822,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
ERROR_VARIABLE gp_ev
)
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# Exclude delay load dependencies under windows (they are listed in dumpbin output after the message below)
string(FIND "${gp_cmd_ov}" "Image has the following delay load dependencies" gp_delayload_pos)
if (${gp_delayload_pos} GREATER -1)
@@ -820,7 +836,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
if(NOT gp_rv STREQUAL "0")
- if(gp_tool STREQUAL "dumpbin")
+ if(gp_tool MATCHES "dumpbin$")
# dumpbin error messages seem to go to stdout
message(FATAL_ERROR "${gp_cmd} failed: ${gp_rv}\n${gp_ev}\n${gp_cmd_ov}")
else()
@@ -828,7 +844,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
endif()
endif()
- if(gp_tool STREQUAL "ldd")
+ if(gp_tool MATCHES "ldd$")
set(ENV{LD_LIBRARY_PATH} "${old_ld_env}")
endif()
@@ -848,9 +864,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# check for install id and remove it from list, since otool -L can include a
# reference to itself
set(gp_install_id)
- if(gp_tool STREQUAL "otool")
+ if(gp_tool MATCHES "otool$")
execute_process(
- COMMAND otool -D ${target}
+ COMMAND ${gp_cmd} -D ${target}
RESULT_VARIABLE otool_rv
OUTPUT_VARIABLE gp_install_id_ov
ERROR_VARIABLE otool_ev
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 5a4bdca..4abbbec 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -30,6 +30,7 @@ if(NOT EXISTS "${TEST_EXECUTABLE}")
endif()
execute_process(
COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --gtest_list_tests
+ WORKING_DIRECTORY "${TEST_WORKING_DIR}"
TIMEOUT ${TEST_DISCOVERY_TIMEOUT}
OUTPUT_VARIABLE output
RESULT_VARIABLE result
diff --git a/Modules/Internal/CMakeCheckCompilerFlag.cmake b/Modules/Internal/CMakeCheckCompilerFlag.cmake
index ca9b356..9c8dfb6 100644
--- a/Modules/Internal/CMakeCheckCompilerFlag.cmake
+++ b/Modules/Internal/CMakeCheckCompilerFlag.cmake
@@ -12,12 +12,17 @@ The function does not use the try_compile() command so as to avoid infinite
recursion. It may not work for all platforms or toolchains, the caller is
responsible for ensuring it is only called in valid situations.
+ cmake_check_compiler_flag(<lang> <flag> <result>
+ [SRC_EXT <ext>] [COMMAND_PATTERN <pattern>]
+ [FAIL_REGEX <regex> ...]
+ [OUTPUT_VARIABLE <output>])
+
Parameters:
- lang - Language to check.
- flag - The flag to add to the compile/link command line.
- result - Boolean output variable. It will be stored in the cache as an
- internal variable and if true, will cause future tests that assign
- to that variable to be bypassed.
+ <lang> - Language to check.
+ <flag> - The flag to add to the compile/link command line.
+ <result> - Boolean output variable. It will be stored in the cache as an
+ internal variable and if true, will cause future tests that assign
+ to that variable to be bypassed.
Optional parameters:
SRC_EXT - Overrides the extension of the source file used for the
@@ -28,7 +33,7 @@ Optional parameters:
the output, give a failed result for the check. A common
set of regular expressions will be included in addition to
those given by FAIL_REGEX.
-
+ OUTPUT_VARIABLE - Set <output> variable with details about any error.
#]=]
include_guard(GLOBAL)
@@ -58,7 +63,7 @@ function(CMAKE_CHECK_COMPILER_FLAG lang flag result)
set(check_lang ${lang})
endif()
- cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN" "FAIL_REGEX" ${ARGN})
+ cmake_parse_arguments(CCCF "" "SRC_EXT;COMMAND_PATTERN;OUTPUT_VARIABLE" "FAIL_REGEX" ${ARGN})
if (NOT CCCF_COMMAND_PATTERN)
set (CCCF_COMMAND_PATTERN "<FLAG> -o <OUTPUT> <SOURCE>")
@@ -95,6 +100,10 @@ function(CMAKE_CHECK_COMPILER_FLAG lang flag result)
endif()
endif()
+ if (CCCF_OUTPUT_VARIABLE)
+ unset(${CCCF_OUTPUT_VARIABLE} PARENT_SCOPE)
+ endif()
+
# Compute the directory in which to run the test.
set(COMPILER_FLAG_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
# Compute source and output files.
@@ -139,6 +148,9 @@ function(CMAKE_CHECK_COMPILER_FLAG lang flag result)
"Determining if the ${flag} option "
"is supported for ${lang} language failed with the following output:\n"
"${COMPILER_FLAG_OUTPUT}\n")
+ if (CCCF_OUTPUT_VARIABLE)
+ set(${CCCF_OUTPUT_VARIABLE} "${COMPILER_FLAG_OUTPUT}" PARENT_SCOPE)
+ endif()
return()
endif()
diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake
index f55b80d..ca90712 100644
--- a/Modules/Platform/CYGWIN-GNU.cmake
+++ b/Modules/Platform/CYGWIN-GNU.cmake
@@ -27,6 +27,7 @@ macro(__cygwin_compiler_gnu lang)
# No -fPIC on cygwin
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
diff --git a/Modules/Platform/Fuchsia.cmake b/Modules/Platform/Fuchsia.cmake
index 7b33434..4b13805 100644
--- a/Modules/Platform/Fuchsia.cmake
+++ b/Modules/Platform/Fuchsia.cmake
@@ -3,6 +3,7 @@ set(FUCHSIA 1)
set(CMAKE_DL_LIBS "")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
set(CMAKE_C_LINK_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE} "-pie")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "-no-pie")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC")
diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake
index ab22b1d..3b5ca59 100644
--- a/Modules/Platform/Linux-Intel.cmake
+++ b/Modules/Platform/Linux-Intel.cmake
@@ -23,7 +23,9 @@ endif()
macro(__linux_compiler_intel lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 13.0)
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER YES)
set(CMAKE_${lang}_LINK_OPTIONS_PIE ${CMAKE_${lang}_COMPILE_OPTIONS_PIE} "-pie")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "-no-pie")
endif()
diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake
index 3e7e391..0341654 100644
--- a/Modules/Platform/Linux-PGI.cmake
+++ b/Modules/Platform/Linux-PGI.cmake
@@ -12,6 +12,7 @@ macro(__linux_compiler_pgi lang)
# Shared library compile and link flags.
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC")
diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake
index e44ceef..e3b0a05 100644
--- a/Modules/Platform/SINIX.cmake
+++ b/Modules/Platform/SINIX.cmake
@@ -1,5 +1,6 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_C_LINK_OPTIONS_PIE "")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake
index 433daf3..bd1ffce 100644
--- a/Modules/Platform/UNIX_SV.cmake
+++ b/Modules/Platform/UNIX_SV.cmake
@@ -1,5 +1,6 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_C_LINK_OPTIONS_PIE "")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake
index 8c9d430..94888d9 100644
--- a/Modules/Platform/UnixWare.cmake
+++ b/Modules/Platform/UnixWare.cmake
@@ -1,5 +1,6 @@
set(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC)
set(CMAKE_C_COMPILE_OPTIONS_PIE "")
+set(_CMAKE_C_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_C_LINK_OPTIONS_PIE "")
set(CMAKE_C_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC")
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 2e854e5..71189b1 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -72,6 +72,7 @@ macro(__windows_compiler_gnu lang)
# No -fPIC on Windows
set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "")
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")
+ set(_CMAKE_${lang}_PIE_MAY_BE_SUPPORTED_BY_LINKER NO)
set(CMAKE_${lang}_LINK_OPTIONS_PIE "")
set(CMAKE_${lang}_LINK_OPTIONS_NO_PIE "")
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index a3d6d9e..18ea55c 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -75,7 +75,8 @@ Defines the following command for use with ``SWIG``:
``SOURCES``
List of sources for the library. Files with extension ``.i`` will be
identified as sources for the ``SWIG`` tool. Other files will be handled in
- the standard way.
+ the standard way. This behavior can be overriden by specifying the variable
+ ``SWIG_SOURCE_FILE_EXTENSIONS``.
.. note::
@@ -222,6 +223,15 @@ as well as ``SWIG``:
``SWIG_MODULE_<name>_EXTRA_DEPS``
Specify extra dependencies for the generated module for ``<name>``.
+
+``SWIG_SOURCE_FILE_EXTENSIONS``
+ Specify a list of source file extensions to override the default
+ behavior of considering only ``.i`` files as sources for the ``SWIG``
+ tool. For example:
+
+ .. code-block:: cmake
+
+ set(SWIG_SOURCE_FILE_EXTENSIONS ".i" ".swg")
#]=======================================================================]
cmake_policy(GET CMP0078 target_name_policy)
@@ -659,8 +669,20 @@ function(SWIG_ADD_LIBRARY name)
set(CMAKE_SWIG_OUTDIR "${outputdir}")
set(SWIG_OUTFILE_DIR "${outfiledir}")
+ # See if the user has specified source extensions for swig files?
+ if (NOT DEFINED SWIG_SOURCE_FILE_EXTENSIONS)
+ # Assume the default (*.i) file extension for Swig source files
+ set(SWIG_SOURCE_FILE_EXTENSIONS ".i")
+ endif()
+
+ # Generate a regex out of file extensions.
+ string(REGEX REPLACE "([$^.*+?|()-])" "\\\\\\1" swig_source_ext_regex "${SWIG_SOURCE_FILE_EXTENSIONS}")
+ list (JOIN swig_source_ext_regex "|" swig_source_ext_regex)
+ string (PREPEND swig_source_ext_regex "(")
+ string (APPEND swig_source_ext_regex ")$")
+
set(swig_dot_i_sources ${_SAM_SOURCES})
- list(FILTER swig_dot_i_sources INCLUDE REGEX "\\.i$")
+ list(FILTER swig_dot_i_sources INCLUDE REGEX ${swig_source_ext_regex})
if (NOT swig_dot_i_sources)
message(FATAL_ERROR "SWIG_ADD_LIBRARY: no SWIG interface files specified")
endif()