-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (59 loc) · 2.81 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
cmake_minimum_required(VERSION 3.1.0)
project(snc VERSION 1.0 LANGUAGES CXX)
include(GNUInstallDirs)
if (BOOST_DIR)
set(BOOST_ROOT ${BOOST_DIR})
endif (BOOST_DIR)
set(BROKER_SRC src/broker.cpp system/SystemdIface.cpp src/commandNames.cpp)
set(CLIENTLIB_SRC src/client.cpp src/commandNames.cpp)
set(CLIENTLIB_INC src/client.h)
# in case we have a valid installation under /opt/boost, use that one (to prefent pre-installed one
# e.g. ubuntu useses strange boost installation)
if(EXISTS /opt/boost/include/boost/function.hpp)
set(BOOST_ROOT /opt/boost)
endif()
#EXTRA_OECMAKE = "-DWITH_SYSTEMD=1"
if(WITH_SYSTEMD)
message(STATUS "compiling with systemd")
set(defines WITH_SYSTEMD)
endif()
# add boost
find_package(Boost 1.53.0 REQUIRED COMPONENTS system thread)
set(CMAKE_CXX_STANDARD 14)
SET(SNC_VERSION_MAJOR 1)
SET(SNC_VERSION_MINOR 0)
SET(SNC_VERSION_PATCH 0)
SET(SNC_VERSION ${SNC_VERSION_MAJOR}.${SNC_VERSION_MINOR}.${SNC_VERSION_PATCH})
SET(SNC_PUBLIC_HEADER src/config.h src/client.h)
add_executable(snc_broker ${BROKER_SRC})
target_link_libraries(snc_broker ${systemd_lib} ${Boost_LIBRARIES} pthread)
target_include_directories(snc_broker PRIVATE ${Boost_INCLUDE_DIRS} ${systemd_inc} ${CMAKE_SOURCE_DIR}/src)
target_compile_definitions(snc_broker PRIVATE ${defines})
#target
add_library(snc_client SHARED ${CLIENTLIB_SRC})
target_link_libraries(snc_client ${Boost_LIBRARIES} pthread)
target_include_directories(snc_client PRIVATE ${Boost_INCLUDE_DIRS}
PUBLIC ${CMAKE_SOURCE_DIR}/src)
# double quotes are essential, but its kind of odd: value for a property can only be a single value,
# however, you can add multiple properties in one line
set_target_properties(snc_client PROPERTIES PUBLIC_HEADER "${SNC_PUBLIC_HEADER}" )
set_target_properties(snc_client PROPERTIES
VERSION ${SNC_VERSION}
SOVERSION ${SNC_VERSION_MAJOR})
SET(TESTCLIENT_SRC commandline/CommandLine.cpp commandline/KeyHit.cpp commandline/cmd_iface.cpp )
add_executable(client ${TESTCLIENT_SRC})
target_link_libraries(client ${Boost_LIBRARIES} snc_client pthread)
target_include_directories(client PRIVATE ${Boost_INCLUDE_DIRS})
add_executable(sender commandline/genericSender.cpp)
target_link_libraries(sender ${Boost_LIBRARIES} snc_client pthread)
target_include_directories(sender PRIVATE ${Boost_INCLUDE_DIRS})
add_executable(sender2 commandline/genericSender2.cpp)
target_link_libraries(sender2 ${Boost_LIBRARIES} snc_client pthread)
target_include_directories(sender2 PRIVATE ${Boost_INCLUDE_DIRS})
# cmake -DCMAKE_INSTALL_PREFIX=$OECORE_TARGET_SYSROOT/usr/ ..
install(TARGETS client snc_client snc_broker sender sender2
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/snc
)