forked from Advanced-Robotics-Facility/ecat-client-advr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
131 lines (103 loc) · 3.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
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
project(ecat-client-advr)
cmake_minimum_required(VERSION 3.0)
# std c++17 flags
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# avoid installing catkin-related files
set(CATKIN_BUILD_BINARY_PACKAGE TRUE)
set(ENABLE_XENO OFF CACHE BOOL "Enable xenomai real-time features")
set(ENABLE_PREEMPT_RT OFF CACHE BOOL "Enable preempt-rt real-time features")
option(COMPILE_EXAMPLE "Enable to compile examples" ON)
option(COMPILE_GUI "Enable to compile the GUI" OFF)
option(COMPILE_MATLAB "Enable to compile the matlab" OFF)
find_package(Boost REQUIRED system)
find_package(yaml-cpp REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
set(EXTERNAL "${PROJECT_SOURCE_DIR}/external")
if( ENABLE_XENO AND ENABLE_PREEMPT_RT)
message( FATAL_ERROR "Cannot setup both Xenomai and PREEMPT_RT Real-Time OS!")
endif()
if ( ${ENABLE_XENO} )
option(CMAKE_USE_XENOMAI "Use Xenomai libraries" ON)
find_package(Xenomai REQUIRED)
if(TARGET Xenomai::cobalt)
set(USE_COBALT True)
endif()
else ()
option(CMAKE_USE_XENOMAI "Use Xenomai libraries" OFF)
endif()
if ( Xenomai_FOUND )
set(LIB_TYPE _rt)
else ()
set(LIB_TYPE _nrt)
endif()
if(ENABLE_PREEMPT_RT)
ADD_DEFINITIONS(-DPREEMPT_RT)
endif(ENABLE_PREEMPT_RT)
find_package(magic_enum)
if(NOT ${magic_enum_FOUND})
set(MAGIC_ENUM_OPT_INSTALL ON CACHE BOOL "Enable option to install Magic Enum" FORCE)
include(cmake/CPM.cmake)
CPMAddPackage(
NAME magic_enum
GITHUB_REPOSITORY Neargye/magic_enum
GIT_TAG v0.8.1 # Where `x.y.z` is the release version you want to use.
)
endif()
find_package(matlogger2 REQUIRED)
find_package(ecat_master REQUIRED COMPONENTS ecat_udp ecat_core)
# set includes
include_directories(
${PROJECT_SOURCE_DIR}/include
${EIGEN3_INCLUDE_DIR}
)
#compile ec_library
add_subdirectory(src/library/ec_library/)
add_subdirectory(src/simulator/repl_dummy)
if(${COMPILE_EXAMPLE})
# compile example
add_subdirectory(src/examples)
endif()
if(${COMPILE_GUI})
# compile ec gui
add_subdirectory(src/gui/ec_gui)
endif()
if(${COMPILE_MATLAB})
# compile ec block
add_subdirectory(src/matlab/ec_block/)
endif()
install(
DIRECTORY config
DESTINATION share/${PROJECT_NAME}
COMPONENT configs
FILES_MATCHING
PATTERN "*.*")
# Debian package for the ADVR Facility Debian package
if (NOT CPACK_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_PROCESSOR}")
if (CPACK_SYSTEM_NAME STREQUAL "x86_64")
set(CPACK_SYSTEM_NAME "amd64")
endif ()
endif ()
set(VERSION_LIB "0.0.1")
set(REVISION "0.0.1")
set(DEB_INSTALL_PREFIX "/usr/local" CACHE STRING "Debs install prefix")
include (InstallRequiredSystemLibraries)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_PACKAGING_INSTALL_PREFIX ${DEB_INSTALL_PREFIX})
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME ${PROJECT_NAME}_package)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}${LIB_TYPE}_package-${VERSION_LIB}-r${REVISION}-${CPACK_SYSTEM_NAME}")
# note: comment out next line to be able to install ros msg and srv
#set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};applications;/;${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};libraries;/;${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};headers;/;${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};configs;/;${CMAKE_CURRENT_BINARY_DIR};${PROJECT_NAME};targets;/")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS OFF)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ADVR Facility EtherCAT Client")
include(CPack)
include(cmake/ExportPackage.cmake)
export_ecat_client_advr()