CheckIPO: Refactor logic selecting test source files

This commit is contained in:
Robert Maynard 2022-06-28 14:09:08 -04:00
parent 4a552ab4ad
commit 1527d48cd0

View File

@ -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}"