-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
83 lines (65 loc) · 2.21 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
cmake_minimum_required(VERSION 3.7)
project(rvnblock)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
option(BUILD_SHARED_LIBS "Set to ON to build shared libraries; OFF for static libraries." OFF)
option(WARNING_AS_ERROR "Set to ON to build with -Werror" ON)
option(BUILD_TEST_COVERAGE "Set to ON to build while generating coverage information. Will put source on the build directory." OFF)
find_package(rvnbinresource REQUIRED)
find_package(rvnmetadata REQUIRED)
add_library(rvnblock
src/block_writer.cpp
src/block_reader.cpp
)
target_compile_options(rvnblock PRIVATE -W -Wall -Wextra -Wmissing-include-dirs -Wunknown-pragmas -Wpointer-arith -Wmissing-field-initializers -Wno-multichar -Wreturn-type)
if(WARNING_AS_ERROR)
target_compile_options(rvnblock PRIVATE -Werror)
endif()
if(BUILD_TEST_COVERAGE)
target_compile_options(rvnblock PRIVATE -g -O0 --coverage -fprofile-arcs -ftest-coverage)
target_link_libraries(rvnblock PRIVATE gcov)
endif()
target_include_directories(rvnblock
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(rvnblock
PUBLIC
rvnbinresource
rvnmetadata::common
rvnmetadata::sql
)
set(PUBLIC_HEADERS
include/common.h
include/block_writer.h
include/block_reader.h
)
set_target_properties(rvnblock PROPERTIES
PUBLIC_HEADER "${PUBLIC_HEADERS}"
POSITION_INDEPENDENT_CODE ON
)
include(GNUInstallDirs)
install(TARGETS rvnblock
EXPORT rvnblock-export
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
install(EXPORT rvnblock-export
FILE
rvnblock-targets.cmake
DESTINATION
${CMAKE_INSTALL_DATADIR}/cmake/rvnblock
)
install(FILES cmake/rvnblock-config.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/rvnblock
)
add_subdirectory(bin)
enable_testing()
add_subdirectory(test)