-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
43 lines (37 loc) · 1.42 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
cmake_minimum_required(VERSION 2.8)
project(udp-reader)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
set(LIBNAME "udp_reader")
include_directories(include)
find_package(Boost COMPONENTS unit_test_framework)
find_package(PkgConfig QUIET)
add_library(${LIBNAME} SHARED "src/ReaderBase.cpp")
target_include_directories(${LIBNAME} PUBLIC
${CMAKE_INSTALL_PREFIX}/include)
# Unit tests
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
add_executable(test-reader "test/test_ReaderBase.cpp")
target_include_directories(test-reader PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(test-reader ${Boost_LIBRARIES} ${LIBNAME})
add_test(NAME test-1 COMMAND test-reader)
endif ()
# Install
if (PkgConfig_FOUND)
set(PKGCONFIG_CFLAGS "")
CONFIGURE_FILE("${CMAKE_CURRENT_LIST_DIR}/cmake/udp-reader.pc.in" "udp-reader.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/udp-reader.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/")
endif ()
set_target_properties(${LIBNAME} PROPERTIES PUBLIC_HEADER "include/ReaderBase.hpp;include/Protocol.hpp")
install(
TARGETS ${LIBNAME}
EXPORT "udp_reader-export"
LIBRARY DESTINATION "lib/${LIBNAME}"
ARCHIVE DESTINATION "lib/${LIBNAME}"
PUBLIC_HEADER DESTINATION "include/${LIBNAME}"
)
install(
EXPORT "udp_reader-export"
FILE "udp_reader-config.cmake"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/udp_reader/cmake"
)