-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
89 lines (76 loc) · 2.92 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_SOURCE_DIR}/cmake/UserOverride.cmake)
project(dftatom)
enable_language(Fortran)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod_files)
# Until CMake supports LFortran natively, we recognize it by hand and set the
# native CMAKE_Fortran_COMPILER_ID variable.
string(REGEX MATCH "lfortran" fortran_compiler_suffix ${CMAKE_Fortran_COMPILER})
if(fortran_compiler_suffix STREQUAL lfortran)
set(CMAKE_Fortran_COMPILER_ID "LFortran")
set(CMAKE_Fortran_FLAGS_RELEASE "--fast --skip-pass=inline_function_calls,fma")
endif()
# Make sure that CMAKE_BUILD_TYPE is either Debug or Release:
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release
CACHE STRING "Build type (Debug, Release)" FORCE)
endif ()
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
CMAKE_BUILD_TYPE STREQUAL "Release"))
message("${CMAKE_BUILD_TYPE}")
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of: Debug, Release (current value: '${CMAKE_BUILD_TYPE}')")
endif ()
set(WITH_PYTHON no
CACHE BOOL "Build with Python wrappers")
set(WITH_C_INTERFACE no
CACHE BOOL "Build with C interface")
if (WITH_PYTHON)
set(WITH_C_INTERFACE yes)
endif ()
set(WITH_LAPACK no
CACHE BOOL "Build tests that depend on Lapack")
if(WITH_LAPACK)
find_package(Lapack REQUIRED)
set(LIBS ${LIBS} ${LAPACK_LIBRARIES})
endif()
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# gfortran
# Enable this if you want to check for single/double corruption (and use
# the Debug build):
#set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -fdefault-real-8")
endif ()
enable_testing()
add_subdirectory(src)
add_subdirectory(tests)
if (WITH_PYTHON)
# We need to execute the find_package() commands here, so that the
# variables like ${PYTHON_INSTALL_PATH} are defined here and in all cmake
# files (as opposed to just subset of cmake files).
find_package(Python REQUIRED)
find_package(NumPy REQUIRED)
find_package(Cython REQUIRED)
add_subdirectory(dftatom)
endif ()
message("\n")
message("Configuration results")
message("---------------------")
message("Fortran compiler: ${CMAKE_Fortran_COMPILER}")
message("CMAKE_Fortran_COMPILER_ID: ${CMAKE_Fortran_COMPILER_ID}")
message("Build type: ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS_DEBUG}")
else ()
message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS_RELEASE}")
endif ()
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
message("LIBS: ${LIBS}")
if (WITH_PYTHON)
message("Python install path: ${PYTHON_INSTALL_PATH}")
endif ()
message("With C interface: ${WITH_C_INTERFACE}")
message("With Python: ${WITH_PYTHON}")
message("With Lapack: ${WITH_LAPACK}")
if (WITH_LAPACK)
message("LAPACK_LIBRARIES: ${LAPACK_LIBRARIES}")
endif(WITH_LAPACK)