summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2017-04-02 13:41:33 (GMT)
committerBrad King <brad.king@kitware.com>2017-04-04 13:35:39 (GMT)
commit87199ea66b171708736e85989bf9b0af89a805c1 (patch)
tree14705eb749251f45f58fefcdd1dd96a218079907 /Modules
parentc92fd25661c08ff991a2482b8a5e42c8490cb3c2 (diff)
downloadCMake-87199ea66b171708736e85989bf9b0af89a805c1.zip
CMake-87199ea66b171708736e85989bf9b0af89a805c1.tar.gz
CMake-87199ea66b171708736e85989bf9b0af89a805c1.tar.bz2
CheckIPOSupported: Add Fortran support
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CheckIPOSupported.cmake9
-rw-r--r--Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in8
-rw-r--r--Modules/CheckIPOSupported/foo.f2
-rw-r--r--Modules/CheckIPOSupported/main.f3
4 files changed, 16 insertions, 6 deletions
diff --git a/Modules/CheckIPOSupported.cmake b/Modules/CheckIPOSupported.cmake
index f0e476a..712a95e 100644
--- a/Modules/CheckIPOSupported.cmake
+++ b/Modules/CheckIPOSupported.cmake
@@ -93,11 +93,14 @@ macro(_ipo_run_language_check language)
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()
@@ -204,12 +207,6 @@ function(check_ipo_supported)
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()
diff --git a/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in
new file mode 100644
index 0000000..9fab077
--- /dev/null
+++ b/Modules/CheckIPOSupported/CMakeLists-Fortran.txt.in
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION "@CMAKE_VERSION@")
+project("@TRY_COMPILE_PROJECT_NAME@" LANGUAGES Fortran)
+
+cmake_policy(SET CMP0069 NEW)
+
+add_library(foo foo.f)
+add_executable(boo main.f)
+target_link_libraries(boo PUBLIC foo)
diff --git a/Modules/CheckIPOSupported/foo.f b/Modules/CheckIPOSupported/foo.f
new file mode 100644
index 0000000..945d2d5
--- /dev/null
+++ b/Modules/CheckIPOSupported/foo.f
@@ -0,0 +1,2 @@
+ SUBROUTINE FOO
+ END
diff --git a/Modules/CheckIPOSupported/main.f b/Modules/CheckIPOSupported/main.f
new file mode 100644
index 0000000..9d1de9f
--- /dev/null
+++ b/Modules/CheckIPOSupported/main.f
@@ -0,0 +1,3 @@
+ PROGRAM BOO
+ CALL FOO()
+ END