-
Notifications
You must be signed in to change notification settings - Fork 173
/
CMakeLists.txt
66 lines (57 loc) · 2.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cmake_minimum_required(VERSION 3.14.0)
project(fortran_stdlib
LANGUAGES Fortran
VERSION 0.1.0
DESCRIPTION "Community driven and agreed upon de facto standard library for Fortran"
)
enable_testing()
# Follow GNU conventions for installation directories
include(GNUInstallDirs)
include(${PROJECT_SOURCE_DIR}/cmake/stdlib.cmake)
# --- CMake specific configuration and package data export
add_subdirectory(config)
# --- compiler options
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0)
message(FATAL_ERROR "GCC Version 9 or newer required")
endif()
add_compile_options(-fimplicit-none)
add_compile_options(-ffree-line-length-132)
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wimplicit-procedure)
add_compile_options(-Wconversion-extra)
# -pedantic-errors triggers a false positive for optional arguments of elemental functions,
# see test_optval and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95446
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 11.0)
add_compile_options(-pedantic-errors)
endif()
add_compile_options(-std=f2018)
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
if(WIN32)
add_compile_options(/warn:declarations,general,usage,interfaces,unused)
add_compile_options(/stand:f18)
else()
add_compile_options(-warn declarations,general,usage,interfaces,unused)
add_compile_options(-stand f18)
endif()
endif()
# --- compiler feature checks
include(CheckFortranSourceCompiles)
include(CheckFortranSourceRuns)
check_fortran_source_runs("i=0; error stop i; end" f18errorstop)
check_fortran_source_compiles("real, allocatable :: array(:, :, :, :, :, :, :, :, :, :); end" f03rank SRC_EXT f90)
check_fortran_source_runs("use, intrinsic :: iso_fortran_env, only : real128; real(real128) :: x; x = x+1; end" f03real128)
if(NOT DEFINED CMAKE_MAXIMUM_RANK)
set(CMAKE_MAXIMUM_RANK 4 CACHE STRING "Maximum array rank for generated procedures")
endif()
# --- find preprocessor
find_program(FYPP fypp)
if(NOT FYPP)
message(FATAL_ERROR "Preprocessor fypp not found!")
endif()
add_subdirectory(src)
install(EXPORT ${PROJECT_NAME}-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)