blob: 04faebbb0b45183bd4a9a73be1dc98fad5748cdb (
plain)
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
|
cmake_minimum_required(VERSION 3.10)
project(
MM
VERSION 0.1
DESCRIPTION "MiniMath, a mathematical library that (ab)uses abstraction"
LANGUAGES CXX
)
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
############################
# build libmm
add_library(mm STATIC
${CMAKE_CURRENT_SOURCE_DIR}/mmvec.cpp
)
add_library(MM::mm ALIAS mm)
# set up headers
target_include_directories(mm
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include/mm
)
target_compile_options(mm
PRIVATE
$<$<CXX_COMPILER_ID:GNU>:
-pedantic -Wall -Wextra -Wcast-qual -Wcast-align -Wpointer-arith
-Winit-self -Wshadow -Wswitch-enum -Wredundant-decls -Wfloat-equal
-Wundef -Wvla -Wconversion -Wstrict-aliasing
>
$<$<CXX_COMPILER_ID:MSVC>:/W4>
)
target_compile_definitions(mm
PRIVATE
$<$<CONFIG:Debug>:DEBUG>
)
# set compiler features
# For a complete list see:
# https://cmake.org/cmake/help/latest/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
target_compile_features(mm
PRIVATE
cxx_std_17
)
############################
# installation
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/MM)
install(TARGETS mm
EXPORT mm-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set_target_properties(mm PROPERTIES EXPORT_NAME MM)
# install public headers
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/include/mmvec.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/mm
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/mm
)
# export targets
install(EXPORT mm-targets
FILE
MMTargets.cmake
NAMESPACE
MM::
DESTINATION
${INSTALL_CONFIGDIR}
)
# create ConfigVersion.cmake
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/MMConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/MMConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/MMConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
# install config, configversion
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/MMConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/MMConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
############################
# export from the build tree
export(EXPORT mm-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/MMTargets.cmake
NAMESPACE MM::
)
export(PACKAGE MM)
############################
# tests
add_subdirectory(test)
|