Muxer
Search…
Building with CMake
When building the Muxer Server and Muxer Client Plugins into your applications it will be necessary to update your build system to correctly source all of the required dependencies. Details of which headers to add to your source can be found in the Integration and Setup section.
Below we look at how to set up CMake to correctly build for two targets, the server application and the client application.
On this page we provide a CMakeLists.txt configurations to build libraries for both the muxer-server-plugin and muxer-client-plugin, these can be found at the bottom of the page and should be added to the muxer-sdk in the folders repclient and muxer-server.
Immediately below is an example of how you could set up your project to link in to the plugins for both a server and client application.
cMakeLists.txt
1
cmake_minimum_required(VERSION 3.15)
2
3
project(my-example-project-client)
4
5
option(BUILD_SERVER "Build the server" ON)
6
option(BUILD_CLIENT "Build the client" ON)
7
8
# General setting for your project, these are not requirements for Muxer
9
set(BUILD_SHARED_LIBS OFF)
10
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
11
set(CMAKE_CXX_STANDARD 17)
12
set(CXX_STANDARD_REQUIRED ON)
13
set(CMAKE_CXX_EXTENSIONS OFF)
14
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
15
16
if(WIN32)
17
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib")
18
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g ")
19
else(WIN32)
20
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -g -fpermissive")
21
endif(WIN32)
22
23
message(STATUS "Starting build, Client : ${BUILD_CLIENT} Server : ${BUILD_SERVER}")
24
25
# REQUIRED
26
# Here we build a server side application written in the server.cc file
27
# We link in to the muxer-server directory where you can place the additional
28
# CMakeLists.txt that specify the muxer-server-plugin
29
if(BUILD_SERVER)
30
message(STATUS "Building Muxer Server Example")
31
32
add_subdirectory(muxer-sdk/muxer-server)
33
34
add_executable(server
35
${CMAKE_CURRENT_LIST_DIR}/server.cc
36
)
37
38
target_link_libraries(server muxer-server-plugin)
39
endif()
40
41
# REQUIRED
42
# Here we build a client side application written in the client.cc file
43
# We link in to the muxer-server directory where you can place the additional
44
# CMakeLists.txt that specify the muxer-server-plugin
45
if(BUILD_CLIENT)
46
message(STATUS "Building Muxer Client Example")
47
48
add_subdirectory(muxer-sdk/repclient)
49
50
add_executable(client
51
${CMAKE_CURRENT_LIST_DIR}/client.cc
52
)
53
54
target_link_libraries(client muxer-client-plugin)
55
endif()
Copied!
Below we show CMake configurations for including both the server and client plugins. The files assume that they are located within the muxer-sdk.

muxer-sdk/repclient

CMakeLists.txt
1
#---------------------------------- MUXER CLIENT - in muxer-sdk/repclient
2
3
if(WIN32)
4
set(LIB_FOLDER win64)
5
else()
6
set(LIB_FOLDER linux)
7
8
# This ensures that the hadean logging library is available for ther server plugin
9
find_package(PkgConfig REQUIRED)
10
pkg_check_modules(HADEAN-LOGGER REQUIRED hadean-logger-cc)
11
12
# Only required in the unix version
13
find_library(MUXER-FMT NAMES libfmt.a PATHS ${CMAKE_CURRENT_LIST_DIR}/../common/lib/${LIB_FOLDER} REQUIRED)
14
15
endif()
16
17
message(STATUS "Building Muxer Server Plugin for ${LIB_FOLDER}")
18
19
# Set the locations of the various required files based on where you have deployed the muxer sdk
20
set( PROTOCOL_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../protocol/include)
21
set( PROTOCOL_SRC_PATH ${CMAKE_CURRENT_LIST_DIR}/../protocol/src)
22
23
set( COMMON_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../common/include)
24
set( COMMON_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/../common/lib)
25
26
set( CLIENT_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/include)
27
set( CLIENT_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/lib)
28
set( CLIENT_SRC_PATH ${CMAKE_CURRENT_LIST_DIR}/src)
29
30
31
32
find_library(MUXER-CAPNP NAMES libcapnp.a capnp.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
33
find_library(MUXER-CAPNPJSON NAMES libcapnp-json.a capnp-json.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
34
find_library(MUXER-CAPNPRPC NAMES libcapnp-rpc.a capnp-rpc.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
35
find_library(MUXER-KJ NAMES libkj.a kj.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
36
find_library(MUXER-KJHTTP NAMES libkj-http.a kj-http.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
37
find_library(MUXER-COMMON NAMES libaether_common.a PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
38
39
40
41
add_library(muxer-client-plugin
42
${PROTOCOL_SRC_PATH}/marshalling.cc
43
${CLIENT_SRC_PATH}/repclient.cc
44
)
45
46
47
target_compile_features(muxer-client-plugin PUBLIC cxx_std_14)
48
target_compile_definitions(muxer-client-plugin PUBLIC WITHOUT_HADEAN_LOGGING)
49
50
51
target_include_directories(muxer-client-plugin
52
PUBLIC ${CLIENT_INCLUDE_PATH}
53
PUBLIC ${PROTOCOL_INCLUDE_PATH}
54
PUBLIC ${COMMON_INCLUDE_PATH}
55
PUBLIC $ENV{HADEAN_SDK}/sdk/include
56
)
57
58
59
target_link_libraries(
60
muxer-client-plugin
61
62
${MUXER-CAPNP}
63
${MUXER-CAPNPJSON}
64
${MUXER-CAPNPRPC}
65
${MUXER-KJ}
66
${MUXER-COMMON}
67
${HADEAN-LOGGER_LDFLAGS}
68
${MUXER-FMT}
69
)
70
Copied!

muxer-sdk/muxer-server

1
#---------------------------------- MUXER SERVER - in muxer-sdk/muxer-server
2
3
if(WIN32)
4
set(LIB_FOLDER win64)
5
else()
6
set(LIB_FOLDER linux)
7
8
# This ensures that the hadean logging library is available for ther server plugin
9
find_package(PkgConfig REQUIRED)
10
pkg_check_modules(HADEAN-LOGGER REQUIRED hadean-logger-cc)
11
12
# Only required in the unix version
13
find_library(MUXER-FMT NAMES libfmt.a PATHS ${CMAKE_CURRENT_LIST_DIR}/../common/lib/${LIB_FOLDER} REQUIRED)
14
15
endif()
16
17
message(STATUS "Building Muxer Server Plugin for ${LIB_FOLDER}")
18
19
# Set the locations of the various required files based on where you have deployed the muxer sdk
20
set( PROTOCOL_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../protocol/include)
21
set( PROTOCOL_SRC_PATH ${CMAKE_CURRENT_LIST_DIR}/../protocol/src)
22
23
set( COMMON_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/../common/include)
24
set( COMMON_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/../common/lib)
25
26
set( SERVER_INCLUDE_PATH ${CMAKE_CURRENT_LIST_DIR}/include)
27
set( SERVER_LIB_PATH ${CMAKE_CURRENT_LIST_DIR}/lib)
28
set( SERVER_SRC_PATH ${CMAKE_CURRENT_LIST_DIR}/src)
29
30
31
find_library(MUXER-SERVER NAMES libmuxer-server.a PATHS ${SERVER_LIB_PATH}/${LIB_FOLDER} REQUIRED)
32
find_library(MUXER-CAPNP NAMES libcapnp.a capnp.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
33
find_library(MUXER-CAPNPJSON NAMES libcapnp-json.a capnp-json.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
34
find_library(MUXER-CAPNPRPC NAMES libcapnp-rpc.a capnp-rpc.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
35
find_library(MUXER-KJ NAMES libkj.a kj.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
36
find_library(MUXER-KJTEST NAMES libkj-test.a kj-test.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
37
find_library(MUXER-KJASYNC NAMES libkj-async.a kj-async.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
38
find_library(MUXER-KJHTTP NAMES libkj-http.a kj-http.lib PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
39
find_library(MUXER-COMMON NAMES libaether_common.a PATHS ${COMMON_LIB_PATH}/${LIB_FOLDER} REQUIRED)
40
41
42
43
add_library(muxer-server-plugin
44
${PROTOCOL_SRC_PATH}/marshalling.cc
45
)
46
47
48
target_compile_features(muxer-server-plugin PUBLIC cxx_std_17)
49
target_compile_definitions(muxer-server-plugin PUBLIC WITHOUT_HADEAN_LOGGING)
50
51
52
target_include_directories(muxer-server-plugin
53
PUBLIC ${SERVER_INCLUDE_PATH}
54
PUBLIC ${PROTOCOL_INCLUDE_PATH}
55
PUBLIC ${COMMON_INCLUDE_PATH}
56
PUBLIC $ENV{HADEAN_SDK}/sdk/include
57
)
58
59
60
target_link_libraries(
61
muxer-server-plugin
62
${MUXER-SERVER}
63
${MUXER-CAPNP}
64
${MUXER-CAPNPJSON}
65
${MUXER-CAPNPRPC}
66
${MUXER-KJ}
67
${MUXER-KJTEST}
68
${MUXER-KJHTTP}
69
${MUXER-KJASYNC}
70
${MUXER-COMMON}
71
${HADEAN-LOGGER_LDFLAGS}
72
${MUXER-FMT}
73
)
Copied!