forked from astralord/RandLib
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
125 lines (99 loc) · 3.53 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
cmake_minimum_required(VERSION 3.19)
project(RandLib
VERSION 1.0.0
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_library(RandLib INTERFACE)
target_compile_features(RandLib
INTERFACE
cxx_std_17
)
set(RANDLIB_HDRS
${RandLib_SOURCE_DIR}/source/RandLib/distributions/ProbabilityDistribution.hpp
${RandLib_SOURCE_DIR}/source/RandLib/distributions/BasicRandGenerator.hpp
${RandLib_SOURCE_DIR}/source/RandLib/distributions/UniformRand.hpp
${RandLib_SOURCE_DIR}/source/RandLib/distributions/UniformDiscreteRand.hpp
${RandLib_SOURCE_DIR}/source/RandLib/distributions/UnivariateDistribution.hpp
${RandLib_SOURCE_DIR}/source/RandLib/RandLib_global.h
)
target_include_directories(RandLib
INTERFACE
$<BUILD_INTERFACE:${RandLib_SOURCE_DIR}/source>
$<INSTALL_INTERFACE:include>
)
include(CTest)
if(BUILD_TESTING)
# testing binary
add_executable(UniformDiscreteTesting ${RandLib_SOURCE_DIR}/testing/UniformDiscreteTesting.cpp)
target_link_libraries(UniformDiscreteTesting PRIVATE RandLib)
add_test(NAME UniformDiscreteTesting
COMMAND UniformDiscreteTesting
)
add_executable(UniformContinuousTesting ${RandLib_SOURCE_DIR}/testing/UniformContinuousTesting.cpp)
target_link_libraries(UniformContinuousTesting PRIVATE RandLib)
add_test(NAME UniformContinuousTesting
COMMAND UniformContinuousTesting
)
endif()
option(RANDLIB_ENABLE_INSTALL "Enables RandLib install rules" ON)
if(RANDLIB_ENABLE_INSTALL)
function(install_with_directory)
set(optionsArgs)
set(oneValueArgs DESTINATION COMPONENT BASE_DIR)
set(multiValueArgs FILES)
cmake_parse_arguments(ARGS "${optionsArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
foreach(file ${ARGS_FILES})
file(RELATIVE_PATH relative_file ${ARGS_BASE_DIR} ${file})
get_filename_component(destination_dir ${relative_file} DIRECTORY)
install(FILES ${file}
DESTINATION ${ARGS_DESTINATION}/${destination_dir}
COMPONENT ${ARGS_COMPONENT}
)
endforeach()
endfunction()
install(TARGETS RandLib
EXPORT RandLibTargets
)
set(RANDLIB_PACKAGE_NAMESPACE "RandLib::")
export(EXPORT RandLibTargets NAMESPACE ${RANDLIB_PACKAGE_NAMESPACE})
include(CMakePackageConfigHelpers)
set(RANDLIB_INSTALL_CMAKE_PREFIX "lib/cmake" CACHE STRING "Install dir for CMake config")
set(RANDLIB_CONFIG_FILE ${RandLib_BINARY_DIR}/RandLibConfig.cmake)
set(RANDLIB_VERSION_FILE ${RandLib_BINARY_DIR}/RandLibConfigVersion.cmake)
configure_package_config_file(${RandLib_SOURCE_DIR}/cmake/RandLibConfig.cmake.in ${RANDLIB_CONFIG_FILE}
INSTALL_DESTINATION ${RANDLIB_INSTALL_CMAKE_PREFIX}
)
write_basic_package_version_file(${RANDLIB_VERSION_FILE}
COMPATIBILITY SameMajorVersion
ARCH_INDEPENDENT
)
install(FILES ${RANDLIB_CONFIG_FILE} ${RANDLIB_VERSION_FILE}
DESTINATION ${RANDLIB_INSTALL_CMAKE_PREFIX}
COMPONENT develop
)
include(GNUInstallDirs)
install(TARGETS RandLib
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT runtime
NAMELINK_COMPONENT develop
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT develop
)
install(EXPORT RandLibTargets
NAMESPACE ${RANDLIB_PACKAGE_NAMESPACE}
DESTINATION ${RANDLIB_INSTALL_CMAKE_PREFIX}
)
install_with_directory(FILES ${RANDLIB_HDRS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/RandLib
COMPONENT develop
BASE_DIR ${RandLib_SOURCE_DIR}/source/RandLib
)
endif()