-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathCMakeLists.txt
86 lines (73 loc) · 2.8 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
#
# CMakeLists.txt: CMake configuration file for sigutils
#
# Copyright (C) 2019 Gonzalo José Carracedo Carballal
#
# This program 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, version 3.
#
# This program 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.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program. If not, see
# <http://www.gnu.org/licenses/>
#
#
cmake_minimum_required(VERSION 3.20.0)
# CMake modules search path
file(GLOB MODULE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*/" LIST_DIRECTORIES true)
list(APPEND CMAKE_MODULE_PATH "${MODULE_DIRS}")
# Check that all required submodules are there
set(
GIT_CMAKE_SUBMODULES
cmake-gitversiondetect
cmake-pcfilegenerator
cmake-relativefilemacro)
foreach (submodule IN ITEMS ${GIT_CMAKE_SUBMODULES})
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/${submodule}/.git")
message( FATAL_ERROR "Required CMake submodule `${submodule}' not found. This \
is most likely caused by an incomplete clone from the main repository. Please run:
$ git submodule update --init --recursive
to clone all required submodules and run CMake again.")
endif()
endforeach()
# Use git version detect to obtain a project version based on tags
include(GitVersionDetect)
set(SIGUTILS_VERSION_MAJOR ${GITVERSIONDETECT_VERSION_MAJOR})
set(SIGUTILS_VERSION_MINOR ${GITVERSIONDETECT_VERSION_MINOR})
set(SIGUTILS_VERSION_PATCH ${GITVERSIONDETECT_VERSION_PATCH})
set(SIGUTILS_VERSION ${SIGUTILS_VERSION_MAJOR}.${SIGUTILS_VERSION_MINOR}.${SIGUTILS_VERSION_PATCH})
# Define the project
project(
sigutils
VERSION ${SIGUTILS_VERSION}
DESCRIPTION "Small signal processing utility library"
HOMEPAGE_URL "http://github.org/BatchDrake/sigutils"
LANGUAGES C CXX)
# Always use top level dir for generated targets to avoid linker problems
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# The library code is in src
add_subdirectory(src)
# The documentation is in doc
add_subdirectory(doc)
# Tests are in the tests dir
include(CTest)
add_subdirectory(tests)
# uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
# Run ldconfig for certain Unix systems
if(UNIX AND NOT APPLE)
install(CODE "exec_program(ldconfig)")
endif()