-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
158 lines (136 loc) · 4.22 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
cmake_minimum_required(VERSION 3.10)
project(CPPIPER)
option(DEV "Generate compiler commands and set logging to debug." OFF)
option(DOC "Generate documentation." OFF)
set(CPPIPER_VERSION_MAJOR 0)
set(CPPIPER_VERSION_MINOR 1)
set(CPPIPER_VERSION ${CPPIPER_VERSION_MAJOR}.${CPPIPER_VERSION_MINOR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
#set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(DEV)
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
set(CMAKE_BUILD_TYPE Debug)
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
configure_file(src/cppiperconfig.hh.in cppiperconfig.hh)
include(GenerateExportHeader)
########################
# LIBRARY DECLARATIONS #
########################
# Dependencies
find_package (glog REQUIRED)
# Dynamic Lib
add_library(cppiper SHARED src/pipemanager.cc src/receiver.cc src/sender.cc)
target_link_libraries(cppiper PUBLIC glog::glog)
generate_export_header(cppiper)
set_property(TARGET cppiper PROPERTY VERSION ${CPPIPER_VERSION})
#set_property(TARGET cppiper PROPERTY SOVERSION 3)
#set_property(TARGET cppiper PROPERTY
# INTERFACE_CPPIPER_MAJOR_VERSION 3)
#set_property(TARGET cppiper APPEND PROPERTY
# COMPATIBLE_INTERFACE_STRING CPPIPER_MAJOR_VERSION
#)
# Static Lib
add_library(cppiper_static STATIC src/pipemanager.cc src/receiver.cc src/sender.cc)
target_link_libraries(cppiper_static PUBLIC glog::glog)
generate_export_header(cppiper_static)
set_property(TARGET cppiper_static PROPERTY VERSION ${CPPIPER_VERSION})
#set_property(TARGET cppiper_static PROPERTY SOVERSION 3)
#set_property(TARGET cppiper_static PROPERTY
# INTERFACE_CPPIPER_MAJOR_VERSION 3)
#set_property(TARGET cppiper_static APPEND PROPERTY
# COMPATIBLE_INTERFACE_STRING CPPIPER_MAJOR_VERSION
#)
################
# INSTALLATION #
################
install(TARGETS cppiper EXPORT cppiper-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(TARGETS cppiper_static EXPORT cppiper-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
install(
FILES
include/pipemanager.hh
include/receiver.hh
include/sender.hh
"${CMAKE_CURRENT_BINARY_DIR}/cppiper_export.h"
"${CMAKE_CURRENT_BINARY_DIR}/cppiperconfig.hh"
DESTINATION
include/cppiper
COMPONENT
Devel
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cppiper/cppiper-config-version.cmake"
VERSION ${CPPIPER_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT cppiper-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cppiper/cppiper-targets.cmake"
NAMESPACE cppiper::
)
configure_file(cmake/cppiper-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cppiper/cppiper-config.cmake"
COPYONLY
)
set(ConfigPackageLocation lib/cmake/cppiper)
install(EXPORT cppiper-targets
FILE
cppiper-targets.cmake
NAMESPACE
cppiper::
DESTINATION
${ConfigPackageLocation}
)
install(
FILES
cmake/cppiper-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/cppiper/cppiper-config-version.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
Devel
)
########################
# BENCHMARK EXECUTABLE #
########################
add_executable(benchmark benchmark/benchmark.cc)
target_include_directories(benchmark PUBLIC
"${PROJECT_BINARY_DIR}"
include
)
target_link_libraries(benchmark PUBLIC cppiper)
##################
# DOC GENERATION #
##################
if (DOC)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
add_custom_target( doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
endif()