This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake".
The branch, next has been updated via 1f39ec883542971bcbf6532c719e1949ebad2877 (commit) via e115396c973013a8d04701fc5351c453a5286678 (commit) via fdb2ba2521998397d97d466b10a8ac2458363625 (commit) from 193ea34cfd698147f6c88dd145b31a46fd9e3042 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1f39ec883542971bcbf6532c719e1949ebad2877 commit 1f39ec883542971bcbf6532c719e1949ebad2877 Merge: 193ea34 e115396 Author: Brad King <brad.k...@kitware.com> AuthorDate: Mon Mar 20 18:39:00 2017 +0000 Commit: Kitware Robot <kwro...@kitware.com> CommitDate: Mon Mar 20 14:39:04 2017 -0400 Stage topic 'wip.ipo.module' Topic-id: 22904 Topic-url: https://gitlab.kitware.com/cmake/cmake/merge_requests/558 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e115396c973013a8d04701fc5351c453a5286678 commit e115396c973013a8d04701fc5351c453a5286678 Author: Ruslan Baratov <ruslan_bara...@yahoo.com> AuthorDate: Sat Mar 11 19:56:00 2017 +0800 Commit: Ruslan Baratov <ruslan_bara...@yahoo.com> CommitDate: Sat Mar 11 19:56:00 2017 +0800 Tests for 'CheckIPOSupported' module diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5157b9f..217f0d5 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -293,6 +293,7 @@ add_RunCMake_test(target_link_libraries) add_RunCMake_test(target_compile_features) add_RunCMake_test(CheckModules) +add_RunCMake_test(CheckIPOSupported) add_RunCMake_test(CommandLine -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}) add_RunCMake_test(CommandLineTar) diff --git a/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt b/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt new file mode 100644 index 0000000..a0effc9 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.0) +project(${RunCMake_TEST} NONE) +include(CheckIPOSupported) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake new file mode 100644 index 0000000..e304c61 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(unparsed-arguments) +run_cmake(user-lang-unknown) +run_cmake(user-lang-fortran) +run_cmake(default-lang-none) +run_cmake(not-supported-by-cmake) +run_cmake(not-supported-by-compiler) +run_cmake(save-to-result) diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt b/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt b/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt new file mode 100644 index 0000000..dc2c3ad --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + IPO is not supported \(no C/CXX/Fortran languages found in ENABLED_LANGUAGES + global property\)\. +Call Stack \(most recent call first\): + .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) + default-lang-none\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake b/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake new file mode 100644 index 0000000..0a2ac69 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake @@ -0,0 +1 @@ +check_ipo_supported() diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt new file mode 100644 index 0000000..f63f30f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + IPO is not supported \(CMake doesn't support IPO for current compiler\)\. +Call Stack \(most recent call first\): + .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) + not-supported-by-cmake\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake new file mode 100644 index 0000000..6f61f7e --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake @@ -0,0 +1,3 @@ +project(${RunCMake_TEST} LANGUAGES C) +set(_CMAKE_IPO_SUPPORTED_BY_CMAKE NO) +check_ipo_supported() diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt new file mode 100644 index 0000000..73e2f26 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + IPO is not supported \(compiler doesn't support IPO\)\. +Call Stack \(most recent call first\): + .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) + not-supported-by-compiler\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake new file mode 100644 index 0000000..17b670c --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake @@ -0,0 +1,4 @@ +project(${RunCMake_TEST} LANGUAGES C) +set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES) +set(_CMAKE_IPO_SUPPORTED_BY_COMPILER NO) +check_ipo_supported() diff --git a/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake b/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake new file mode 100644 index 0000000..f76db72 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/save-to-result.cmake @@ -0,0 +1,22 @@ +project(${RunCMake_TEST} LANGUAGES C) +check_ipo_supported(RESULT result OUTPUT output) + +string(COMPARE EQUAL "${result}" "" is_empty) +if(is_empty) + message(FATAL_ERROR "Result variable is empty") +endif() + +string(COMPARE EQUAL "${result}" "YES" is_yes) +string(COMPARE EQUAL "${result}" "NO" is_no) + +if(is_yes) + # Compiler supports IPO +elseif(is_no) + # Compiler doesn't support IPO, output should not be empty. + string(COMPARE EQUAL "${output}" "" is_empty) + if(is_empty) + message(FATAL_ERROR "Output is empty") + endif() +else() + message(FATAL_ERROR "Unexpected result: ${result}") +endif() diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt new file mode 100644 index 0000000..a3fee53 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + Unparsed arguments: xxx +Call Stack \(most recent call first\): + unparsed-arguments\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake new file mode 100644 index 0000000..3ee7326 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake @@ -0,0 +1 @@ +check_ipo_supported(RESULT result OUTPUT output xxx) diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt new file mode 100644 index 0000000..2cb595d --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + IPO is not supported \(Fortran is not supported\)\. +Call Stack \(most recent call first\): + .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) + user-lang-fortran\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake new file mode 100644 index 0000000..275dbd9 --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake @@ -0,0 +1 @@ +check_ipo_supported(LANGUAGES "Fortran") diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt new file mode 100644 index 0000000..278ba0b --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(message\): + IPO is not supported \(language\(s\) 'UnknownLanguage' not supported\)\. +Call Stack \(most recent call first\): + .*/Modules/CheckIPOSupported\.cmake:[0-9]+ \(_ipo_not_supported\) + user-lang-unknown\.cmake:[0-9]+ \(check_ipo_supported\) + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake new file mode 100644 index 0000000..ac743ad --- /dev/null +++ b/Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake @@ -0,0 +1 @@ +check_ipo_supported(LANGUAGES UnknownLanguage) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdb2ba2521998397d97d466b10a8ac2458363625 commit fdb2ba2521998397d97d466b10a8ac2458363625 Author: Ruslan Baratov <ruslan_bara...@yahoo.com> AuthorDate: Tue Mar 7 20:18:28 2017 +0800 Commit: Ruslan Baratov <ruslan_bara...@yahoo.com> CommitDate: Sat Mar 11 19:46:25 2017 +0800 CheckIPOSupported: New module to check for compiler/cmake IPO support diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 5e96d79..1e8342c 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -27,6 +27,7 @@ All Modules /module/CheckFortranFunctionExists /module/CheckFortranSourceCompiles /module/CheckFunctionExists + /module/CheckIPOSupported /module/CheckIncludeFileCXX /module/CheckIncludeFile /module/CheckIncludeFiles diff --git a/Help/module/CheckIPOSupported.rst b/Help/module/CheckIPOSupported.rst new file mode 100644 index 0000000..9c8a77b --- /dev/null +++ b/Help/module/CheckIPOSupported.rst @@ -0,0 +1 @@ +.. cmake-module:: ../../Modules/CheckIPOSupported.cmake diff --git a/Help/release/dev/CheckIPOSupported.rst b/Help/release/dev/CheckIPOSupported.rst new file mode 100644 index 0000000..dbc84e6 --- /dev/null +++ b/Help/release/dev/CheckIPOSupported.rst @@ -0,0 +1,6 @@ +CheckIPOSupported +----------------- + +* A :module:`CheckIPOSupported` module was added to help projects + check whether interprocedural optimization (IPO) is supported by + the current toolchain and CMake version. diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake new file mode 100644 index 0000000..6f7bc82 --- /dev/null +++ b/Modules/CheckIPOSupported.cmake @@ -0,0 +1,215 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckIPOSupported +----------------- + +Check whether the compiler supports an interprocedural optimization (IPO/LTO). +Use this before enabling the :prop_tgt:`INTERPROCEDURAL_OPTIMIZATION` target +property. + +.. command:: check_ipo_supported + + :: + + check_ipo_supported([RESULT <result>] [OUTPUT <output>] + [LANGUAGES <lang>...]) + + Options are: + + ``RESULT <result>`` + Set ``<result>`` variable to ``YES`` if IPO is supported by the + compiler and ``NO`` otherwise. If this option is not given then + the command will issue a fatal error if IPO is not supported. + ``OUTPUT <output>`` + Set ``<output>`` variable with details about any error. + ``LANGUAGES <lang>...`` + Specify languages whose compilers to check. + Languages ``C`` and ``CXX`` are supported. + +Examples +^^^^^^^^ + +.. code-block:: cmake + + check_ipo_supported() # fatal error if IPO is not supported + set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + +.. code-block:: cmake + + # Optional IPO. Do not use IPO if it's not supported by compiler. + check_ipo_supported(RESULT result OUTPUT output) + if(result) + set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + else() + message(WARNING "IPO is not supported: ${output}") + endif() + +#]=======================================================================] + +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) + string(COMPARE EQUAL "${X_RESULT}" "" is_empty) + if(is_empty) + message(FATAL_ERROR "IPO is not supported (${output}).") + endif() + + set("${X_RESULT}" NO PARENT_SCOPE) + set("${X_OUTPUT}" "${output}" PARENT_SCOPE) +endmacro() + +# Run IPO/LTO test +macro(_ipo_run_language_check language) + set(testdir "${CMAKE_CURRENT_BINARY_DIR}/_CMakeLTOTest-${language}") + + file(REMOVE_RECURSE "${testdir}") + file(MAKE_DIRECTORY "${testdir}") + + set(bindir "${testdir}/bin") + set(srcdir "${testdir}/src") + + file(MAKE_DIRECTORY "${bindir}") + file(MAKE_DIRECTORY "${srcdir}") + + set(TRY_COMPILE_PROJECT_NAME "lto-test") + + set(try_compile_src "${CMAKE_ROOT}/Modules/CheckIPOSupported") + + # Use: + # * TRY_COMPILE_PROJECT_NAME + # * CMAKE_VERSION + configure_file( + "${try_compile_src}/CMakeLists-${language}.txt.in" + "${srcdir}/CMakeLists.txt" + @ONLY + ) + + string(COMPARE EQUAL "${language}" "C" is_c) + string(COMPARE EQUAL "${language}" "CXX" is_cxx) + + if(is_c) + set(copy_sources foo.c main.c) + elseif(is_cxx) + set(copy_sources foo.cpp main.cpp) + else() + message(FATAL_ERROR "Language not supported") + endif() + + foreach(x ${copy_sources}) + configure_file( + "${try_compile_src}/${x}" + "${srcdir}/${x}" + COPYONLY + ) + endforeach() + + try_compile( + result + "${bindir}" + "${srcdir}" + "${TRY_COMPILE_PROJECT_NAME}" + CMAKE_FLAGS + "-DCMAKE_VERBOSE_MAKEFILE=ON" + "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON" + OUTPUT_VARIABLE output + ) + + if(NOT result) + _ipo_not_supported("${output}") + return() + endif() +endmacro() + +function(check_ipo_supported) + # TODO: IPO policy + + set(optional) + set(one RESULT OUTPUT) + set(multiple LANGUAGES) + + # Introduce: + # * X_RESULT + # * X_OUTPUT + # * X_LANGUAGES + cmake_parse_arguments(X "${optional}" "${one}" "${multiple}" "${ARGV}") + + string(COMPARE NOTEQUAL "${X_UNPARSED_ARGUMENTS}" "" has_unparsed) + if(has_unparsed) + message(FATAL_ERROR "Unparsed arguments: ${X_UNPARSED_ARGUMENTS}") + endif() + + string(COMPARE EQUAL "${X_LANGUAGES}" "" no_languages) + if(no_languages) + # User did not set any languages, use defaults + get_property(enabled_languages GLOBAL PROPERTY ENABLED_LANGUAGES) + string(COMPARE EQUAL "${enabled_languages}" "" no_languages) + if(no_languages) + _ipo_not_supported( + "no languages found in ENABLED_LANGUAGES global property" + ) + return() + endif() + + set(languages "") + list(FIND enabled_languages "CXX" result) + if(NOT result EQUAL -1) + list(APPEND languages "CXX") + endif() + + list(FIND enabled_languages "C" result) + if(NOT result EQUAL -1) + list(APPEND languages "C") + endif() + + list(FIND enabled_languages "Fortran" result) + if(NOT result EQUAL -1) + list(APPEND languages "Fortran") + endif() + + string(COMPARE EQUAL "${languages}" "" no_languages) + if(no_languages) + _ipo_not_supported( + "no C/CXX/Fortran languages found in ENABLED_LANGUAGES global property" + ) + return() + endif() + else() + set(languages "${X_LANGUAGES}") + + set(unsupported_languages "${languages}") + list(REMOVE_ITEM unsupported_languages "C" "CXX" "Fortran") + string(COMPARE NOTEQUAL "${unsupported_languages}" "" has_unsupported) + if(has_unsupported) + _ipo_not_supported( + "language(s) '${unsupported_languages}' not supported" + ) + return() + endif() + endif() + + list(FIND languages "Fortran" result) + if(NOT result EQUAL -1) + _ipo_not_supported("Fortran is not supported") + return() + endif() + + if(NOT _CMAKE_IPO_SUPPORTED_BY_CMAKE) + _ipo_not_supported("CMake doesn't support IPO for current compiler") + return() + endif() + + if(NOT _CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER) + _ipo_not_supported("compiler doesn't support IPO") + return() + endif() + + foreach(x ${languages}) + _ipo_run_language_check(${x}) + endforeach() + + set("${X_RESULT}" YES PARENT_SCOPE) +endfunction() diff --git a/Modules/CheckIPOSupported/CMakeLists-C.txt.in b/Modules/CheckIPOSupported/CMakeLists-C.txt.in new file mode 100644 index 0000000..d20f31f --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-C.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES C) + +# TODO: IPO policy + +add_library(foo foo.c) +add_executable(boo main.c) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in new file mode 100644 index 0000000..4b55c70 --- /dev/null +++ b/Modules/CheckIPOSupported/CMakeLists-CXX.txt.in @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION "@CMAKE_VERSION@") +project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES CXX) + +# TODO: IPO policy + +add_library(foo foo.cpp) +add_executable(boo main.cpp) +target_link_libraries(boo PUBLIC foo) diff --git a/Modules/CheckIPOSupported/foo.c b/Modules/CheckIPOSupported/foo.c new file mode 100644 index 0000000..1e56597 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.c @@ -0,0 +1,4 @@ +int foo() +{ + return 0x42; +} diff --git a/Modules/CheckIPOSupported/foo.cpp b/Modules/CheckIPOSupported/foo.cpp new file mode 100644 index 0000000..1e56597 --- /dev/null +++ b/Modules/CheckIPOSupported/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 0x42; +} diff --git a/Modules/CheckIPOSupported/main.c b/Modules/CheckIPOSupported/main.c new file mode 100644 index 0000000..5be0864 --- /dev/null +++ b/Modules/CheckIPOSupported/main.c @@ -0,0 +1,6 @@ +int foo(); + +int main() +{ + return foo(); +} diff --git a/Modules/CheckIPOSupported/main.cpp b/Modules/CheckIPOSupported/main.cpp new file mode 100644 index 0000000..5be0864 --- /dev/null +++ b/Modules/CheckIPOSupported/main.cpp @@ -0,0 +1,6 @@ +int foo(); + +int main() +{ + return foo(); +} diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index 85a0772..45dc36f 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -30,12 +30,17 @@ macro(__linux_compiler_intel lang) # executables that use dlopen but do not set ENABLE_EXPORTS. set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + set(_CMAKE_IPO_SUPPORTED_BY_CMAKE YES) + if(XIAR) # INTERPROCEDURAL_OPTIMIZATION set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo) set(CMAKE_${lang}_CREATE_STATIC_LIBRARY_IPO "${XIAR} cr <TARGET> <LINK_FLAGS> <OBJECTS> " "${XIAR} -s <TARGET> ") + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) + else() + set(_CMAKE_IPO_MAY_BE_SUPPORTED_BY_COMPILER NO) endif() if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 12.0) ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-modules.7.rst | 1 + Help/module/CheckIPOSupported.rst | 1 + Help/release/dev/CheckIPOSupported.rst | 6 + Modules/CheckIPOSupported.cmake | 215 ++++++++++++++++++++ Modules/CheckIPOSupported/CMakeLists-C.txt.in | 8 + Modules/CheckIPOSupported/CMakeLists-CXX.txt.in | 8 + Modules/CheckIPOSupported/foo.c | 4 + Modules/CheckIPOSupported/foo.cpp | 4 + Modules/CheckIPOSupported/main.c | 6 + Modules/CheckIPOSupported/main.cpp | 6 + Modules/Platform/Linux-Intel.cmake | 5 + Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CheckIPOSupported/CMakeLists.txt | 4 + .../RunCMake/CheckIPOSupported/RunCMakeTest.cmake | 9 + .../default-lang-none-result.txt} | 0 .../CheckIPOSupported/default-lang-none-stderr.txt | 7 + .../CheckIPOSupported/default-lang-none.cmake | 1 + .../not-supported-by-cmake-result.txt} | 0 .../not-supported-by-cmake-stderr.txt | 6 + .../CheckIPOSupported/not-supported-by-cmake.cmake | 3 + .../not-supported-by-compiler-result.txt} | 0 .../not-supported-by-compiler-stderr.txt | 6 + .../not-supported-by-compiler.cmake | 4 + .../CheckIPOSupported/save-to-result.cmake | 22 ++ .../unparsed-arguments-result.txt} | 0 .../unparsed-arguments-stderr.txt | 5 + .../CheckIPOSupported/unparsed-arguments.cmake | 1 + .../user-lang-fortran-result.txt} | 0 .../CheckIPOSupported/user-lang-fortran-stderr.txt | 6 + .../CheckIPOSupported/user-lang-fortran.cmake | 1 + .../user-lang-unknown-result.txt} | 0 .../CheckIPOSupported/user-lang-unknown-stderr.txt | 6 + .../CheckIPOSupported/user-lang-unknown.cmake | 1 + 33 files changed, 347 insertions(+) create mode 100644 Help/module/CheckIPOSupported.rst create mode 100644 Help/release/dev/CheckIPOSupported.rst create mode 100644 Modules/CheckIPOSupported.cmake create mode 100644 Modules/CheckIPOSupported/CMakeLists-C.txt.in create mode 100644 Modules/CheckIPOSupported/CMakeLists-CXX.txt.in create mode 100644 Modules/CheckIPOSupported/foo.c create mode 100644 Modules/CheckIPOSupported/foo.cpp create mode 100644 Modules/CheckIPOSupported/main.c create mode 100644 Modules/CheckIPOSupported/main.cpp create mode 100644 Tests/RunCMake/CheckIPOSupported/CMakeLists.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/RunCMakeTest.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/default-lang-none-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/default-lang-none-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/default-lang-none.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/not-supported-by-cmake-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/not-supported-by-cmake.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/not-supported-by-compiler-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/not-supported-by-compiler.cmake create mode 100644 Tests/RunCMake/CheckIPOSupported/save-to-result.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/unparsed-arguments-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/unparsed-arguments-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/unparsed-arguments.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/user-lang-fortran-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/user-lang-fortran-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/user-lang-fortran.cmake copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => CheckIPOSupported/user-lang-unknown-result.txt} (100%) create mode 100644 Tests/RunCMake/CheckIPOSupported/user-lang-unknown-stderr.txt create mode 100644 Tests/RunCMake/CheckIPOSupported/user-lang-unknown.cmake hooks/post-receive -- CMake _______________________________________________ Cmake-commits mailing list Cmake-commits@cmake.org http://public.kitware.com/mailman/listinfo/cmake-commits