-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
75 lines (67 loc) · 2.18 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
project(RngStreams LANGUAGES CXX)
cmake_minimum_required(VERSION 3.5)
option(RngStreams_BUILD_SHARED_LIBS "Compile RngStreams as a shared library" ON)
if(RngStreams_BUILD_SHARED_LIBS)
add_library(${PROJECT_NAME}
SHARED
src/RngStream.cpp
src/RngStream.h
)
message(STATUS "Configuring ${PROJECT_NAME} shared library")
else()
add_library(${PROJECT_NAME}
STATIC
src/RngStream.cpp
src/RngStream.h
)
message(STATUS "Configuring ${PROJECT_NAME} static library")
endif()
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
# Configurations
if(CMAKE_CONFIGURATION_TYPES)
# i.e. Visual Studio or Xcode Definition of available build configurations,
# Release and Debug.
set(CMAKE_CONFIGURATION_TYPES "Release;Debug")
else()
# For single configuration generators, default build type is Release.
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(
STATUS
"Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE
"${default_build_type}"
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
endif()
if (${PROJECT_NAME}_BUILD_TESTS)
# Prevent doctest installation
set(DOCTEST_NO_INSTALL ON)
add_subdirectory(tests/doctest)
# find_package(doctest REQUIRED)
enable_testing()
add_subdirectory(tests/)
endif()
include(GNUInstallDirs)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG>
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG>
)
install(FILES src/RngStream.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
message(STATUS "${PROJECT_NAME} configured.")