-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
73 lines (59 loc) · 1.7 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
cmake_minimum_required(VERSION 3.15)
project(embo_lib CXX)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN yes)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH $ORIGIN)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
add_library(${PROJECT_NAME})
set_target_properties(
${PROJECT_NAME} PROPERTIES
SOVERSION 1
VERSION 1.0.0
)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})
target_sources(${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/embo_lib_export.h
${CMAKE_CURRENT_SOURCE_DIR}/include/embo_lib.hh
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/embo_lib.cc
)
target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
find_package(fmt REQUIRED)
target_link_libraries(${PROJECT_NAME}
PRIVATE
fmt::fmt
)
get_target_property(_PUBLIC_HEADERS ${PROJECT_NAME} INTERFACE_SOURCES)
set_target_properties(
${PROJECT_NAME} PROPERTIES
PUBLIC_HEADER "${_PUBLIC_HEADERS}"
)
unset(_PUBLIC_HEADERS)
install(TARGETS ${PROJECT_NAME})
if(NOT CMAKE_CROSSCOMPILING)
add_executable(${PROJECT_NAME}_test)
target_sources(${PROJECT_NAME}_test
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test/embo_lib_test.cc
)
find_package(GTest REQUIRED)
target_link_libraries(${PROJECT_NAME}_test
PRIVATE
${PROJECT_NAME}
GTest::gtest
GTest::gtest_main
)
enable_testing()
include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME}_test
DISCOVERY_MODE PRE_TEST
)
endif()