-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
80 lines (68 loc) · 1.83 KB
/
Copy pathCMakeLists.txt
File metadata and controls
80 lines (68 loc) · 1.83 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
#Set minimum required version to 3.14
cmake_minimum_required(VERSION 3.14)
project(Mathic
VERSION 1.0.0
LANGUAGES CXX
)
#Submodule the dependencies
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
message(STATUS "Updating submodules")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT
)
if(NOT ${GIT_SUBMOD_RESULT} EQUAL "0")
message(FATAL_ERROR "Unable to update submodules")
else()
message(STATUS "Updated submodules: OK")
endif()
endif()
#check for submodule existance
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/extern/Catch2")
message(FATAL_ERROR "Catch2 has not been downloaded, aborting")
endif()
#Add the dependency
add_subdirectory(extern/Catch2)
#Add the library
add_subdirectory(src)
#Add apps
set(MATHIC_BUILD_APPS ON CACHE BOOL "")
if(${MATHIC_BUILD_APPS})
add_subdirectory(apps)
endif()
#Add tests
enable_testing()
add_subdirectory(tests)
#Add documentations if needed
set(MATHIC_BUILD_DOCS ON CACHE BOOL "")
if(${MATHIC_BUILD_DOCS})
add_subdirectory(docs)
endif()
#Install
include(GNUInstallDirs)
set(INSTALL_CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/Mathic)
#Install targets in appropriate locations
install(
TARGETS
mathic
EXPORT
MathicTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
#Generate and install configuration
install(
EXPORT MathicTargets
DESTINATION ${INSTALL_CONFIG_DIR}
FILE MathicTargets.cmake
NAMESPACE Mathic::
)
#Install the header files
install(
DIRECTORY include/mathic
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h*"
)