Debian Codegraph @

Modules/FortranCInterface/Verify/CMakeLists.txt

raw
1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file LICENSE.rst or https://cmake.org/licensing for details.
3
4 cmake_minimum_required(VERSION ${CMAKE_VERSION})
5 project(VerifyFortranC C Fortran)
6
7 if(CMAKE_Fortran_COMPILER_ID STREQUAL "LFortran")
8 if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL "0.55")
9 set(_LFORTRAN_SC_FLAG --separate-compilation)
10 else()
11 set(_LFORTRAN_SC_FLAG --generate-object-code)
12 endif()
13 add_compile_options("$<$<COMPILE_LANGUAGE:Fortran>:${_LFORTRAN_SC_FLAG}>")
14 endif()
15
16 option(VERIFY_CXX "Whether to verify C++ and Fortran" OFF)
17 if(VERIFY_CXX)
18 enable_language(CXX)
19 set(VerifyCXX VerifyCXX.cxx)
20 add_definitions(-DVERIFY_CXX)
21 endif()
22
23 include(FortranCInterface)
24
25 FortranCInterface_HEADER(VerifyFortran.h SYMBOLS VerifyFortran)
26 include_directories(${VerifyFortranC_BINARY_DIR})
27
28 add_library(VerifyFortran STATIC VerifyFortran.f)
29 add_executable(VerifyFortranC main.c VerifyC.c ${VerifyCXX})
30 target_link_libraries(VerifyFortranC VerifyFortran)
31
32 if(NOT VERIFY_CXX)
33 # The entry point (main) is defined in C; link with the C compiler.
34 set_property(TARGET VerifyFortranC PROPERTY LINKER_LANGUAGE C)
35 endif()