-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (59 loc) · 2.26 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
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# Project
project(cluon-lwe450 LANGUAGES CXX)
# Fetch CPM
set(CPM_DOWNLOAD_VERSION 0.32.0)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake v${CPM_DOWNLOAD_VERSION}")
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
endif()
include(${CPM_DOWNLOAD_LOCATION})
# Add dependencies
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
CPMAddPackage("gh:CLIUtils/[email protected]")
CPMAddPackage(
NAME cluon
GITHUB_REPOSITORY chrberger/libcluon
VERSION 0.0.140
SOURCE_SUBDIR libcluon
EXCLUDE_FROM_ALL YES
GIT_SHALLOW YES
PATCH_COMMAND git apply ${CMAKE_SOURCE_DIR}/external/libcluon_CMakeLists_disable_tests.patch ${CMAKE_SOURCE_DIR}/external/libcluon_UDPReceiver_interfaceAddress.patch
)
CPMAddPackage(
NAME memo
GITHUB_REPOSITORY MO-RISE/memo
VERSION 0.3.0
GIT_SHALLOW YES
DOWNLOAD_ONLY YES
)
# Compile message specifications
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/message_specifications
DEPENDS cluon
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/message_specifications
COMMAND cluon-msc --cpp --out=${CMAKE_CURRENT_BINARY_DIR}/message_specifications/memo.hpp ${memo_SOURCE_DIR}/memo.odvd
)
add_custom_target(
generate_message_specifications
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/message_specifications
)
# Create executable
add_executable(${PROJECT_NAME} src/main.cpp)
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
# cluon specific includes
${cluon_SOURCE_DIR}/libcluon/include
${cluon_SOURCE_DIR}/libcluon/thirdparty
${CMAKE_CURRENT_BINARY_DIR}/include # libcluon "built-in" message specifications
# compiled message specifications for this project
${CMAKE_CURRENT_BINARY_DIR}/message_specifications
)
target_link_libraries(${PROJECT_NAME} Threads::Threads cluon-static CLI11)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
add_dependencies(${PROJECT_NAME} generate_message_specifications)
# Install executable.
install(TARGETS ${PROJECT_NAME} DESTINATION bin COMPONENT ${PROJECT_NAME})