CMakeLists.txt
2.05 KB
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
cmake_minimum_required(VERSION 3.0)
project(zmqrpc)
find_package(Git REQUIRED)
if(CMAKE_TOOLCHAIN_FILE)
set(TOOLCHAIN "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
else()
set(TOOLCHAIN "")
endif()
project(zmqrpc)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.2)
message(FATAL_ERROR "GCC version must be at least 7.2!")
endif()
endif()
add_compile_options(-std=c++17)
add_compile_options(-O4)
include(ExternalProject)
ExternalProject_Add (
cppzmq
GIT_REPOSITORY https://github.com/zeromq/cppzmq.git
GIT_TAG v4.3.0
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
CMAKE_ARGS "${TOOLCHAIN}"
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/external/cppzmq"
)
ExternalProject_Add (
zmq
BUILD_IN_SOURCE 1
URL https://github.com/zeromq/libzmq/releases/download/v4.3.1/zeromq-4.3.1.tar.gz
UPDATE_COMMAND ""
PATCH_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/patches/ip_resolver.cpp ${CMAKE_CURRENT_BINARY_DIR}/external/libzmq/src/zmq/src/
INSTALL_COMMAND make install
CONFIGURE_COMMAND ./configure --without-docs --enable-static --prefix=${CMAKE_CURRENT_BINARY_DIR}/external/libzmq CXX=${CMAKE_CXX_COMPILER} CC=${CMAKE_C_COMPILER} ${CONFIG_HOST}
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/external/libzmq"
BUILD_COMMAND make -j8
)
add_library(libzmq STATIC IMPORTED)
set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/external/libzmq/lib/libzmq.a)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/external/variant/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/external/libzmq/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/external/cppzmq/src/cppzmq)
add_executable(server test/server.cpp)
target_link_libraries(server libzmq pthread rt)
add_dependencies(server zmq cppzmq)
add_executable(client test/client.cpp)
target_link_libraries(client libzmq pthread rt)
add_dependencies(client zmq cppzmq)