-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
62 lines (54 loc) · 1.93 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
cmake_minimum_required(VERSION 3.0)
project(kern)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -O -D_FORTIFY_SOURCE=2")
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
elseif(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
set(CMAKE_CXX_STANDARD 14)
set(PROJECT_VERSION 1.0.0)
set(KERN_SOURCES
src/dispatch.cpp
src/builder.cpp
src/sink.cpp
src/info.cpp)
set(KERN_HEADER
src/kern.h
src/dispatch.h
src/builder.h
src/info.h
src/sink.h)
add_library(kern SHARED ${KERN_SOURCES})
set_target_properties(kern PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(kern PROPERTIES PUBLIC_HEADER "${KERN_HEADER}")
if(UNIX)
include(GNUInstallDirs)
install(TARGETS kern
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" COMPONENT dev)
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkconfig files")
configure_file("kern.pc.in" "kern.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/kern.pc" DESTINATION "${INSTALL_PKGCONFIG_DIR}")
elseif(WIN32)
set_target_properties(kern PROPERTIES DEFINE_SYMBOL BUILD_DLL)
install(TARGETS kern
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include COMPONENT devel)
endif()
option(KERN_EXAMPLES "Build usage examples" OFF)
option(KERN_TESTING "Build unit tests with catch" OFF)
if(KERN_EXAMPLES)
add_subdirectory(examples)
endif()
if(KERN_TESTING)
if(DEFINED ENV{CODECOV})
message(STATUS "Enabled codecov")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage tests coverage)
endif()
add_subdirectory(tests)
endif()