Skip to content

Commit 8f6dc3e

Browse files
committed
Check for Fortran support to conditionally build target
1 parent 922f449 commit 8f6dc3e

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ cmake_minimum_required(VERSION 3.10)
1515
#
1616
# project information
1717
#
18-
project("test" LANGUAGES C Fortran)
18+
project("test" LANGUAGES C)
19+
20+
#
21+
# check for fortran support
22+
#
23+
include(CheckLanguage)
24+
check_language(Fortran)
25+
if(CMAKE_Fortran_COMPILER)
26+
enable_language(Fortran)
27+
message(STATUS "Fortran compiler found: ${CMAKE_Fortran_COMPILER}")
28+
else()
29+
message(STATUS "No Fortran support, will be disabled.")
30+
endif()
1931

2032

2133
#

src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@
1313
add_subdirectory(libfoo)
1414
add_subdirectory(bar)
1515
add_subdirectory(libheader)
16-
add_subdirectory(fortran)
16+
17+
if(CMAKE_Fortran_COMPILER)
18+
add_subdirectory(fortran)
19+
endif()

0 commit comments

Comments
 (0)