-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
180 lines (148 loc) · 6.41 KB
/
Copy pathCMakeLists.txt
File metadata and controls
180 lines (148 loc) · 6.41 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# - Top level CMake script for SNCabling
#-----------------------------------------------------------------------
# Copyright (C) 2018 François Mauger <mauger@lpccaen.in2p3.fr>
# Copyright (C) 2018 Yves Lemière <lemiere@lpccaen.in2p3.fr>
#
# This file is part of SNCabling.
#
# SNCabling is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SNCabling 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SNCabling. If not, see <http://www.gnu.org/licenses/>.
#-----------------------------------------------------------------------
message (STATUS "[info] Begin of 'CMakeLists.txt'.")
#-----------------------------------------------------------------------
# Enforce an out-of-source build.
#
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(STATUS "SNCabling requires an out-of-source build.")
message(STATUS "Please remove these files from ${CMAKE_BINARY_DIR} first:")
message(STATUS " CMakeCache.txt")
message(STATUS " CMakeFiles")
message(STATUS "Once these files are removed, create a separate directory")
message(STATUS "and run CMake from there, pointing it to:")
message(STATUS " ${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "in-source build detected")
endif()
#-----------------------------------------------------------------------
# CMake/project requirements and configuration
#
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(SNCabling)
# - Load custom modules
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
# - Version number management utilities:
include(BxVersionManager)
# - Versioning only giving major and minor. Patch number is
# automatically deduced from an external file.
bx_version_set(SNCabling 1 0)
message(STATUS "[info] Project version = '${PROJECT_VERSION}'")
#-----------------------------------------------------------------------
# Common LPC utilities
#
include(LPCCMakeSettings)
# - SVN revision number for dev builds
include(LPCSVNUtilities)
set(SNCabling_VERSION_REVISION 0)
Subversion_DIRECTORY_IS_WC(${PROJECT_SOURCE_DIR} SNCabling)
if(SNCabling_DIRECTORY_IS_WC)
Subversion_WC_INFO(${PROJECT_SOURCE_DIR} SNCabling)
set(SNCabling_VERSION_REVISION ${SNCabling_WC_REVISION})
endif()
message (STATUS "[info] SNCABLING_LIBDIR_TO_RESOURCEDIR = '${SNCABLING_LIBDIR_TO_RESOURCEDIR}'")
#-----------------------------------------------------------------------
# Useful variables
set(SNCABLING_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(SNCABLING_BINARY_DIR "${PROJECT_BINARY_DIR}")
#-----------------------------------------------------------------------
# Configure testing if required
#
option(SNCABLING_ENABLE_TESTING "Build unit testing system for SNCabling" ON)
if(SNCABLING_ENABLE_TESTING)
enable_testing()
endif()
#-----------------------------------------------------------------------
# Configure/Build utilities as needed
#
option(SNCABLING_WITH_DEVELOPER_TOOLS "Build/install developer tools" ON)
mark_as_advanced(SNCABLING_WITH_DEVELOPER_TOOLS)
#-----------------------------------------------------------------------
# Optional build of documentation
#
option(SNCABLING_WITH_SERVICE "Build service support for SNCabling (depends on Bayeux)" OFF)
#-----------------------------------------------------------------------
# Optional build of documentation
#
option(SNCABLING_WITH_DOCS "Build documentation for SNCabling" ON)
#-----------------------------------------------------------------------
# Debug
message( STATUS "[info] SNCabling_VERSION = '${SNCabling_VERSION}'")
message( STATUS "[info] SNCABLING_SOURCE_DIR = '${SNCABLING_SOURCE_DIR}'")
message( STATUS "[info] SNCABLING_BINARY_DIR = '${SNCABLING_BINARY_DIR}'")
message( STATUS "[info] SNCABLING_ENABLE_TESTING = '${SNCABLING_ENABLE_TESTING}'")
message( STATUS "[info] SNCABLING_WITH_DEVELOPER_TOOLS = '${SNCABLING_WITH_DEVELOPER_TOOLS}'")
message( STATUS "[info] SNCABLING_WITH_DOCS = '${SNCABLING_WITH_DOCS}'")
#-----------------------------------------------------------------------
include(SNCablingDependencies)
#-----------------------------------------------------------------------
# Build the subdirectories as required
#
message( STATUS "[info] Adding subdirectory 'source'...")
add_subdirectory(source)
if(SNCABLING_WITH_DOCS)
add_subdirectory(documentation)
endif()
#-----------------------------------------------------------------------
# - CMake Support files
include(CMakePackageConfigHelpers)
# - Versioning file is the same for the build and install trees
write_basic_package_version_file(
${SNCABLING_BUILD_CMAKEDIR}/${SNCABLING_TAG}/SNCablingConfigVersion.cmake
COMPATIBILITY SameMajorVersion
)
message(STATUS "[debug] CMAKE_INSTALL_CMAKEDIR = '${CMAKE_INSTALL_CMAKEDIR}'")
message(STATUS "[debug] PROJECT_TAG = '${PROJECT_TAG}'")
# - Config file is also the same in build/install trees as we use same layout
configure_package_config_file(
${PROJECT_SOURCE_DIR}/cmake/SNCablingConfig.cmake.in
${SNCABLING_BUILD_CMAKEDIR}/${SNCABLING_TAG}/SNCablingConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${PROJECT_TAG}
PATH_VARS
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_DATAROOTDIR
)
# - Targets (build tree)
export(EXPORT SNCablingTargets
NAMESPACE SNCabling::
FILE ${SNCABLING_BUILD_CMAKEDIR}/${SNCABLING_TAG}/SNCablingTargets.cmake
)
# - Targets (install tree)
install(EXPORT SNCablingTargets
NAMESPACE SNCabling::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}/${SNCABLING_TAG}
)
# - Installation of, well, install tree files
install(
FILES
${PROJECT_BUILD_CMAKEDIR}/${SNCABLING_TAG}/SNCablingConfigVersion.cmake
${PROJECT_BUILD_CMAKEDIR}/${SNCABLING_TAG}/SNCablingConfig.cmake
DESTINATION
${CMAKE_INSTALL_CMAKEDIR}/${SNCABLING_TAG}
)
#-----------------------------------------------------------------------
# - Install published resources and documentation
#-----------------------------------------------------------------------
# Resource installation
add_subdirectory(resources)
message (STATUS "[info] End of 'CMakeLists.txt'.")
# - end