-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
108 lines (99 loc) · 2.69 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# This file is part of jonquil.
# SPDX-Identifier: Apache-2.0 OR MIT
#
# Licensed under either of Apache License, Version 2.0 or MIT license
# at your option; you may not use this file except in compliance with
# the License.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.9)
get_directory_property(is-subproject PARENT_DIRECTORY)
project(
"jonquil"
LANGUAGES "Fortran"
VERSION "0.2.0"
DESCRIPTION "Bringing TOML blooms to JSON land"
)
# Follow GNU conventions for installing directories
include(GNUInstallDirs)
# General configuration information
add_subdirectory("config")
# Collect subprojects
if(NOT TARGET "test-drive::test-drive" AND ENABLE_TESTING)
find_package("test-drive" REQUIRED)
endif()
if(NOT TARGET "toml-f::toml-f")
find_package("toml-f" REQUIRED)
endif()
# Collect source of the project
set(srcs)
add_subdirectory("src")
# TOML-Fortran library target
add_library(
"${PROJECT_NAME}-lib"
"${srcs}"
)
target_link_libraries(
"${PROJECT_NAME}-lib"
PUBLIC
"toml-f::toml-f"
)
set_target_properties(
"${PROJECT_NAME}-lib"
PROPERTIES
POSITION_INDEPENDENT_CODE TRUE
OUTPUT_NAME "${PROJECT_NAME}"
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}"
Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include"
)
target_include_directories(
"${PROJECT_NAME}-lib"
PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${module-dir}>
)
if(NOT EXISTS "${PROJECT_BINARY_DIR}/include")
make_directory("${PROJECT_BINARY_DIR}/include")
endif()
# Export targets for other projects
add_library("${PROJECT_NAME}" INTERFACE)
target_link_libraries("${PROJECT_NAME}" INTERFACE "${PROJECT_NAME}-lib")
install(
TARGETS
"${PROJECT_NAME}"
"${PROJECT_NAME}-lib"
EXPORT
"${PROJECT_NAME}-targets"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
install(
EXPORT
"${PROJECT_NAME}-targets"
NAMESPACE
"${PROJECT_NAME}::"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
install(
DIRECTORY
"${PROJECT_BINARY_DIR}/include/"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${module-dir}"
)
# Package license files
install(
FILES
"LICENSE-Apache"
"LICENSE-MIT"
DESTINATION "${CMAKE_INSTALL_DATADIR}/licenses/${PROJECT_NAME}"
)
if(ENABLE_TESTING)
# add the testsuite
enable_testing()
add_subdirectory("test")
endif()