diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2022-06-28 18:09:08 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2022-07-13 14:25:10 (GMT) |
commit | 1527d48cd0071e3e1737b51db3738f7f76ddbf80 (patch) | |
tree | ad9dc16e53f06ded27c09adf5e17930777ae8f26 | |
parent | 4a552ab4ad181768fcbcb32a6c9ebf1383a8fe63 (diff) | |
download | CMake-1527d48cd0071e3e1737b51db3738f7f76ddbf80.zip CMake-1527d48cd0071e3e1737b51db3738f7f76ddbf80.tar.gz CMake-1527d48cd0071e3e1737b51db3738f7f76ddbf80.tar.bz2 |
CheckIPO: Refactor logic selecting test source files
-rw-r--r-- | Modules/CheckIPOSupported.cmake | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake index cca1be9..f0b4fd6 100644 --- a/Modules/CheckIPOSupported.cmake +++ b/Modules/CheckIPOSupported.cmake @@ -91,6 +91,17 @@ macro(_ipo_run_language_check language) set(try_compile_src "${CMAKE_ROOT}/Modules/CheckIPOSupported") + set(_C_ext "c") + set(_CXX_ext "cpp") + set(_Fortran_ext "f") + + set(ext ${_${language}_ext}) + if(NOT "${ext}" STREQUAL "") + set(copy_sources foo.${ext} main.${ext}) + else() + message(FATAL_ERROR "Language not supported") + endif() + # Use: # * TRY_COMPILE_PROJECT_NAME # * CMAKE_VERSION @@ -100,20 +111,6 @@ macro(_ipo_run_language_check language) @ONLY ) - string(COMPARE EQUAL "${language}" "C" is_c) - string(COMPARE EQUAL "${language}" "CXX" is_cxx) - string(COMPARE EQUAL "${language}" "Fortran" is_fortran) - - if(is_c) - set(copy_sources foo.c main.c) - elseif(is_cxx) - set(copy_sources foo.cpp main.cpp) - elseif(is_fortran) - set(copy_sources foo.f main.f) - else() - message(FATAL_ERROR "Language not supported") - endif() - foreach(x ${copy_sources}) configure_file( "${try_compile_src}/${x}" |