This repository has been archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
177 lines (161 loc) · 5.86 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required(VERSION 3.14.0)
project(gecko VERSION 2022.7.1 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
cmake_host_system_information(RESULT HOST QUERY HOSTNAME)
cmake_host_system_information(RESULT OSN QUERY OS_NAME)
cmake_host_system_information(RESULT OS_VERSION QUERY OS_RELEASE)
cmake_host_system_information(RESULT PROC QUERY PROCESSOR_DESCRIPTION)
message(STATUS "-------------------------------------")
message(STATUS " Project: ${PROJECT_NAME}")
message(STATUS " Version: ${CMAKE_PROJECT_VERSION}")
message(STATUS " C++ ${CMAKE_CXX_STANDARD}")
message(STATUS "-------------------------------------")
message(STATUS " ${HOST}")
message(STATUS " ${OSN}: ${OS_VERSION}")
message(STATUS " ${PROC}")
message(STATUS "-------------------------------------")
# CPM =========================================================================
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM.cmake")
set(CPM_VERSION v0.35.1)
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/${CPM_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
else()
message(STATUS "CPM ${CPM_VERSION} ready")
endif()
include(${CPM_DOWNLOAD_LOCATION})
# Library =====================================================================
# https://cmake.org/cmake/help/latest/module/ExternalProject.html
# include(ExternalProject)
# ExternalProject_Add(marko-proj
# GIT_REPOSITORY https://github.com/gecko-robotics/marko.cpp.git
# GIT_TAG main
# GIT_SHALLOW TRUE
# SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/marko/src"
# BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/marko"
# # CONFIGURE_COMMAND ""
# BUILD_COMMAND "make"
# INSTALL_COMMAND ""
# # TEST_COMMAND ""
# PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# )
#
# SET(MARKO_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/marko/src/include)
# SET(MARKO_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/marko)
CPMAddPackage(
NAME marko
VERSION 2022.7.1.1
# TAG latest
GITHUB_REPOSITORY gecko-robotics/marko.cpp
# GIT_REPOSITORY https://github.com/gecko-robotics/marko.cpp.git
OPTIONS
"EXAMPLES OFF"
)
# if (${marko_ADDED})
# message(STATUS "marko added ")
# else()
# message(STATUS "*** couldn't add marko ***")
# endif()
message(STATUS "==> marko CPM added: ${marko_ADDED}")
CPMAddPackage(
NAME serialcomm
VERSION 0.0.0
# TAG latest
GITHUB_REPOSITORY gecko-robotics/serialcomm
# GIT_REPOSITORY https://github.com/gecko-robotics/marko.cpp.git
# OPTIONS
# "EXAMPLES OFF"
)
# if (${marko_ADDED})
# message(STATUS "marko added ")
# else()
# message(STATUS "*** couldn't add marko ***")
# endif()
message(STATUS "==> serialcomm CPM added: ${serialcomm_ADDED}")
# include(ExternalProject)
# ExternalProject_Add(serial-proj
# GIT_REPOSITORY https://github.com/gecko-robotics/serialcomm.git
# GIT_TAG main
# GIT_SHALLOW TRUE
# SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/serial/src"
# BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/serial"
# # CONFIGURE_COMMAND ""
# BUILD_COMMAND "make"
# INSTALL_COMMAND ""
# # TEST_COMMAND ""
# PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# )
#
# SET(SER_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/serial/src/include)
# SET(SER_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/serial)
# Threads ---------------------------------------------------------
find_package(Threads REQUIRED)
if(Threads_FOUND)
message(STATUS ">> Threads found")
if(CMAKE_USE_PTHREADS_INIT)
message(STATUS " -> Using pthreads")
endif()
# list(APPEND ALL_LIBS ${CMAKE_THREAD_LIBS_INIT})
else()
message(WARNING "*** Could not find Threads ***")
endif()
# Library =====================================================================
add_library(${PROJECT_NAME} SHARED $<TARGET_OBJECTS:objlib-gecko>)
add_library(${PROJECT_NAME}-static STATIC $<TARGET_OBJECTS:objlib-gecko>)
set_target_properties(${PROJECT_NAME}-static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
# if building STATIC library, an unimportant but annoying error appears about
# no symbols
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
SET(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
add_library(objlib-gecko
OBJECT
src/time.cpp
)
# add_dependencies(${PROJECT_NAME} marko-proj serial-proj)
add_dependencies(objlib-gecko marko serialcomm)
target_include_directories(objlib-gecko
PUBLIC
# ${MARKO_INCLUDE_DIR}
# ${CMAKE_SOURCE_DIR}/include
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(objlib-gecko
PUBLIC
marko
serialcomm
)
# target_link_directories(${PROJECT_NAME}
# PUBLIC
# ${MARKO_LIB_DIR}
# )
# Binary ======================================================================
option(EXAMPLES "Examples" ON)
message(STATUS "Building examples is ${EXAMPLES}")
if (EXAMPLES)
add_subdirectory(examples)
endif()
# set(MAIN main)
# add_executable(${MAIN} main.cpp)
# add_dependencies(${MAIN} marko-proj)
# target_include_directories(${MAIN} PRIVATE ${MARKO_INCLUDE_DIR})
# target_link_libraries(${MAIN} PRIVATE marko)
# target_link_directories(${MAIN} PRIVATE ${MARKO_LIB_DIR})
#
# set(IMU imu)
# add_executable(${IMU} imu.cpp)
# add_dependencies(${IMU} marko-proj serial-proj)
# target_include_directories(${IMU} PRIVATE ${MARKO_INCLUDE_DIR} ${SER_INCLUDE_DIR})
# target_link_libraries(${IMU}
# PRIVATE
# marko
# ${CMAKE_THREAD_LIBS_INIT}
# serialcomm)
# target_link_directories(${IMU} PRIVATE ${MARKO_LIB_DIR} ${SER_LIB_DIR})