-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (53 loc) · 2.16 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
cmake_minimum_required(VERSION 3.4)
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.251.tar.gz"
SHA1 "5659b15dc0884d4b03dbd95710e6a1fa0fc3258d"
)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(BUILD_EXAMPLES "Build examples" ON)
option(BUILD_TESTS "Build tests" ON)
project(div)
set(DIV_VERSION_MAJOR 0)
set(DIV_VERSION_MINOR 1)
set(DIV_VERSION_PATCH 0)
set(DIV_VERSION_TWEAK 0)
set(DIV_VERSION
${DIV_VERSION_MAJOR}.${DIV_VERSION_MINOR}.${DIV_VERSION_PATCH}.${DIV_VERSION_TWEAK})
set(DIV_VERSION_STRING "v${DIV_VERSION}")
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
add_library(div STATIC ${CMAKE_CURRENT_SOURCE_DIR}/sources/div.cpp)
target_include_directories(div PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if(BUILD_EXAMPLES)
file(GLOB EXAMPLE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/examples/*.cpp")
foreach(EXAMPLE_SOURCE ${EXAMPLE_SOURCES})
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SOURCE} NAME_WE)
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SOURCE})
target_link_libraries(${EXAMPLE_NAME} div)
install(TARGETS ${EXAMPLE_NAME}
RUNTIME DESTINATION div
)
endforeach(EXAMPLE_SOURCE ${EXAMPLE_SOURCES})
endif()
target_link_libraries(demo div)
install(TARGETS demo RUNTIME DESTINATION div)
install(TARGETS div
EXPORT div-config
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
install(EXPORT div-config DESTINATION cmake)
if(BUILD_TESTS)
enable_testing()
file(GLOB ${PROJECT_NAME}_TEST_SOURCES tests/*.cpp)
add_executable(check ${${PROJECT_NAME}_TEST_SOURCES})
target_link_libraries(check ${PROJECT_NAME} GTest::gtest_main)
add_test(NAME check COMMAND check)
endif()
include(CPackConfig.cmake)