-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
82 lines (66 loc) · 2.41 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
cmake_minimum_required( VERSION 3.18 )
project(Minisi
LANGUAGES CXX
VERSION 1.0.0
DESCRIPTION "Lightweight Units Library for C++17"
)
enable_testing()
set(CMAKE_SKIP_RULE_DEPENDENCY 1)
option(MINISI_DEVELOPMENT_WARNINGS
"Enable Warnings for Library Development"
FALSE)
if (${MINISI_DEVELOPMENT_WARNINGS})
add_definitions(-Weverything)
add_definitions(-Wno-c++98-compat)
add_definitions(-Wno-global-constructors)
add_definitions(-Wno-c99-compat )
add_definitions(-Wno-float-equal)
add_definitions(-fcolor-diagnostics)
add_definitions(-Wno-c++98-compat-pedantic)
add_definitions(-Wno-disabled-macro-expansion)
endif()
set(CMAKE_CXX_STANDARD 17)
option(MINISI_USE_LIBCXX
"Use libc++ instead of libstdc++"
FALSE)
if (${MINISI_USE_LIBCXX})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
endif()
add_library(Minisi INTERFACE)
if (BUILD_INTERFACE)
target_sources(Minisi INTERFACE
include/minisi/forward.h
include/minisi/io.h
include/minisi/limits.h
include/minisi/literals.h
include/minisi/math.h
include/minisi/minisi.h
include/minisi/quantity.h
include/minisi/unit.h
)
endif()
target_include_directories(Minisi
INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>)
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
if (Boost_FOUND)
macro(minisi_add_test NAME SOURCES)
add_executable(${NAME} ${SOURCES})
# target_include_directories(${NAME} ${Boost_INCLUDE_DIRS})
target_compile_definitions(${NAME} PRIVATE "BOOST_TEST_DYN_LINK=1")
target_link_libraries(${NAME} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} Minisi)
add_test(${NAME} ${NAME})
endmacro()
minisi_add_test(io_test test/minisi/io_test.cpp)
minisi_add_test(literals_test test/minisi/literals_test.cpp)
minisi_add_test(math_test test/minisi/math_test.cpp)
minisi_add_test(minisi_test test/minisi/minisi_test.cpp)
minisi_add_test(quantity_test test/minisi/quantity_test.cpp)
minisi_add_test(unit_test test/minisi/unit_test.cpp)
endif()
install(DIRECTORY include/minisi DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
install(TARGETS Minisi DESTINATION lib/cmake/Minisi EXPORT MinisiTargets)
install(EXPORT MinisiTargets DESTINATION lib/cmake/Minisi)
install(FILES MinisiConfig.cmake MinisiConfigVersion.cmake DESTINATION lib/cmake/Minisi)