-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (77 loc) · 2.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
#
cmake_minimum_required(VERSION 3.12)
# set the project name and version
project(ioha VERSION 1.1)
set(CMAKE_CXX_STANDARD 17)
set(EXTERNAL_DIR "${PROJECT_SOURCE_DIR}/external")
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# set source file directorys and prepare for adding libraries.
file(GLOB_RECURSE HEADERS ./include *.hpp)
include_directories(GLOB_RECURSE)
add_library(ioha INTERFACE)
add_library(ioha::ioha ALIAS ioha)
# configure external package
include_directories(./IOH/include/ioh)
add_subdirectory(./IOH)
target_link_libraries(ioha INTERFACE ioh)
include_directories(./IOH/external/fmt/include/)
target_link_libraries(ioha INTERFACE fmt::fmt-header-only)
# Include external clutchlog lib
include_directories(./IOH/external/clutchlog)
target_include_directories(ioha
INTERFACE
# Interface paths are relative to the installation path, not the current directory.
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(ioha
INTERFACE
cxx_std_17
)
# Generate package config files.
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/cmake/ioha-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ioha-config.cmake
INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/ioha
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/ioha-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Define installation rules.
include(GNUInstallDirs)
install(TARGETS ioha fmt-header-only
EXPORT ioha-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/ioha-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/ioha-config-version.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/ioha
)
install(EXPORT ioha-targets
FILE ioha-targets.cmake
NAMESPACE ioha::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ioha
)
# Export targets. If an external project adds this project to its build tree
# via `add_subdirectory()`, then `find_package()` will work without
# requiring this project to be installed.
export(EXPORT ioha-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/ioha-targets.cmake
NAMESPACE ioha::
)
export(PACKAGE ioha)
# add the IOH library
# add the executable
add_subdirectory(run)