forked from crest-lab/crest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (80 loc) · 2.22 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
# This file is part of crest.
# SPDX-Identifier: LGPL-3.0-or-later
#
# crest is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# crest is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
cmake_minimum_required(VERSION 3.14)
project(
"crest"
LANGUAGES "Fortran" "C"
VERSION "2.12.0"
)
# Follow GNU conventions for installing directories
include(GNUInstallDirs)
# General configuration information
set(exe-deps)
add_subdirectory("config")
# OpenMP dependency
if(NOT TARGET OpenMP::OpenMP_Fortran)
find_package(OpenMP REQUIRED)
list(
APPEND exe-deps
OpenMP::OpenMP_Fortran
)
endif()
if(NOT TARGET BLAS::BLAS)
find_package(BLAS REQUIRED)
if(NOT TARGET BLAS::BLAS AND BLAS_FOUND)
add_library(BLAS::BLAS INTERFACE IMPORTED)
target_link_libraries(BLAS::BLAS INTERFACE "${BLAS_LIBRARIES}")
target_link_options(BLAS::BLAS INTERFACE "${BLAS_LINKER_FLAGS}")
endif()
endif()
if(NOT TARGET LAPACK::LAPACK)
find_package(LAPACK REQUIRED)
if(NOT TARGET LAPACK::LAPACK AND LAPACK_FOUND)
add_library(LAPACK::LAPACK INTERFACE IMPORTED)
target_link_libraries(LAPACK::LAPACK INTERFACE "${LAPACK_LIBRARIES}")
target_link_options(LAPACK::LAPACK INTERFACE "${LAPACK_LINKER_FLAGS}")
endif()
endif()
list(
APPEND exe-deps
LAPACK::LAPACK
BLAS::BLAS
)
# General configuration information
set(prog)
set(srcs)
add_subdirectory("src")
add_executable(
"${PROJECT_NAME}-exe"
"${srcs}" "${prog}"
)
set_target_properties(
"${PROJECT_NAME}-exe"
PROPERTIES
OUTPUT_NAME "${PROJECT_NAME}"
Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include"
)
target_link_libraries(
"${PROJECT_NAME}-exe"
PRIVATE
"${exe-deps}"
)
install(
TARGETS
"${PROJECT_NAME}-exe"
EXPORT
"${PROJECT_NAME}-targets"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)