This repository has been archived by the owner on Sep 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
151 lines (121 loc) · 4.46 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
cmake_minimum_required(VERSION 3.8)
if(${CMAKE_VERSION} VERSION_LESS 3.14)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.14)
endif()
# ---------------------------------------------------------------------------- #
# PROJECT
# name version language
# ---------------------------------------------------------------------------- #
project(ilasynth VERSION 1.0
LANGUAGES CXX
)
# ---------------------------------------------------------------------------- #
# OPTION
# build configuration
# ---------------------------------------------------------------------------- #
option(ILASYNTH_EXPORT_PACKAGE "Export cmake package if enabled" OFF)
option(ILASYNTH_BUILD_DOCS "Build documentation if enabled" OFF)
if(${APPLE})
set(BUILD_SHARED_LIBS OFF)
else(${LINUX})
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
endif()
# ---------------------------------------------------------------------------- #
# VARIABLE
# alias and configurations
# ---------------------------------------------------------------------------- #
set(ILASYNTH_TARGET_NAME ${PROJECT_NAME})
set(ILASYNTH_CONFIG_INSTALL_DIR "lib/cmake/${PROJECT_NAME}" CACHE INTERNAL "")
set(ILASYNTH_INCLUDE_INSTALL_DIR "include")
set(ILASYNTH_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/include")
set(ILASYNTH_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(ILASYNTH_CMAKE_CONFIG_TEMPLATE "cmake/config.cmake.in")
set(ILASYNTH_CMAKE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(ILASYNTH_CMAKE_PROJECT_TARGETS_FILE "${PROJECT_NAME}Targets.cmake")
set(ILASYNTH_CMAKE_VERSION_CONFIG_FILE
"${ILASYNTH_CMAKE_CONFIG_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(ILASYNTH_CMAKE_PROJECT_CONFIG_FILE
"${ILASYNTH_CMAKE_CONFIG_DIR}/${PROJECT_NAME}Config.cmake")
set(BOOST_PY_COMP "python")
if(${BUILD_SHARED_LIBS})
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_MACOSX_RPATH TRUE)
endif()
# ---------------------------------------------------------------------------- #
# External dependencies
# ---------------------------------------------------------------------------- #
##
## Make sure that custom modules can be found.
##
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# ---------------------------------------------------------------------------- #
# TARGET
# library target
# ---------------------------------------------------------------------------- #
set(ILASYNTH_LIB_NAME ${PROJECT_NAME})
set(ILASYNTH_AST_LIB_NAME ${ILASYNTH_LIB_NAME}Ast)
add_subdirectory(src)
# ---------------------------------------------------------------------------- #
# INSTALL
# project related
# ---------------------------------------------------------------------------- #
##
## forward version for find_package
##
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${ILASYNTH_CMAKE_VERSION_CONFIG_FILE}
COMPATIBILITY SameMajorVersion # AnyNewVersion
)
##
## cmake config
##
configure_file(
${ILASYNTH_CMAKE_CONFIG_TEMPLATE}
${ILASYNTH_CMAKE_PROJECT_CONFIG_FILE}
@ONLY
)
install(
FILES ${ILASYNTH_CMAKE_PROJECT_CONFIG_FILE} ${ILASYNTH_CMAKE_VERSION_CONFIG_FILE}
DESTINATION ${ILASYNTH_CONFIG_INSTALL_DIR}
)
##
## project export
##
install(
EXPORT ${ILASYNTH_TARGETS_EXPORT_NAME}
DESTINATION ${ILASYNTH_CONFIG_INSTALL_DIR}
NAMESPACE ${PROJECT_NAME}::
FILE ${ILASYNTH_CMAKE_PROJECT_TARGETS_FILE}
)
export(
TARGETS ${ILASYNTH_AST_LIB_NAME} ${ILASYNTH_LIB_NAME}
NAMESPACE ${PROJECT_NAME}::
FILE ${ILASYNTH_CMAKE_PROJECT_TARGETS_FILE}
)
if(${ILASYNTH_EXPORT_PACKAGE})
export(PACKAGE ${PROJECT_NAME})
endif()
# ---------------------------------------------------------------------------- #
# UNINSTALL
# uninstall files listed in install_manifest.txt
# ---------------------------------------------------------------------------- #
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(uninstall
COMMAND
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake
)
endif()
# ---------------------------------------------------------------------------- #
# Documents
# ---------------------------------------------------------------------------- #
if(${ILASYNTH_BUILD_DOCS})
add_subdirectory(docs)
endif()