forked from Mobsya/aseba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
197 lines (154 loc) · 6.6 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# emacs: -*- CMake -*-
# kate: replace-tabs off; tab-width 4; indent-width 4; tab-indents true; indent-mode normal
# vim: ts=4:sw=4:noexpandtab
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum osx version")
cmake_policy(SET CMP0071 NEW)
cmake_policy(SET CMP0020 NEW)
project(ThymioSuite)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
# ensure a minimal version of CMake
cmake_minimum_required(VERSION 3.5)
include(FeatureSummary)
include(InstallRequiredSystemLibraries)
# additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
include(CMakeModules/ParseVersion.cmake)
include(CMakeModules/cpp_features.cmake)
include(CMakeModules/workarounds.cmake)
include(CMakeModules/aseba_conf.cmake)
include(CMakeModules/codesign.cmake)
include(CMakeModules/dashel.cmake)
include(CMakeModules/deployqt.cmake)
include(CMakeModules/CMakeQuery.cmake)
if(NOT ANDROID)
include(CMakeModules/boost.cmake)
include(CMakeModules/enki.cmake)
find_package(Threads REQUIRED)
endif()
if(ANDROID)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/android/qt-android-cmake/)
include(android/qt-android-cmake/AddQtAndroidApk.cmake)
endif()
add_subdirectory(third_party/catch2 EXCLUDE_FROM_ALL)
add_subdirectory(third_party/libusb EXCLUDE_FROM_ALL)
add_subdirectory(third_party/qtzeroconf EXCLUDE_FROM_ALL)
add_subdirectory(third_party/spdlog EXCLUDE_FROM_ALL)
add_subdirectory(third_party/expected EXCLUDE_FROM_ALL)
add_subdirectory(third_party/fmt EXCLUDE_FROM_ALL)
add_subdirectory(third_party/qt-solutions EXCLUDE_FROM_ALL)
add_subdirectory(third_party/quazip EXCLUDE_FROM_ALL)
SET(BUILD_SHARED_LIBS_CACHED ${BUILD_SHARED_LIBS} CACHE BOOL "" FORCE)
SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/pugixml EXCLUDE_FROM_ALL)
SET(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_CACHED} CACHE BOOL "" FORCE)
SET(RANGE_V3_TESTS OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/range-v3 EXCLUDE_FROM_ALL)
add_library(mpark_variant INTERFACE)
target_include_directories(mpark_variant INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party/mpark.variant/include>
$<INSTALL_INTERFACE:include>)
if (ANDROID)
set(FLATBUFFERS_BUILD_FLATC OFF CACHE BOOL "FLATBUFFERS_BUILD_FLATC" FORCE)
endif()
set(FLATBUFFERS_BUILD_TESTS OFF CACHE BOOL "FLATBUFFERS_BUILD_TESTS" FORCE)
add_subdirectory(third_party/flatbuffers EXCLUDE_FROM_ALL)
if (NOT TARGET flatc)
include( ExternalProject )
list(APPEND CMAKE_ARGS "-DFLATBUFFERS_BUILD_FLATLIB=OFF")
list(APPEND CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release")
list(APPEND CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/flatc")
ExternalProject_Add(flatc_build
SOURCE_DIR ${PROJECT_SOURCE_DIR}/third_party/flatbuffers/
CMAKE_ARGS "${CMAKE_ARGS}"
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/flatc/bin/flatc
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/flatc
)
add_executable(flatc IMPORTED GENERATED)
set_property(TARGET flatc PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/flatc/bin/flatc)
add_dependencies(flatc flatc_build)
endif()
# testing and defines
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin")
cmake_policy(SET CMP0020 NEW)
if(CREATE_QT_CONF_FILE)
#create an empty qt.conf file
file(WRITE ${CMAKE_BINARY_DIR}/bin/qt.conf "")
install(FILES ${CMAKE_BINARY_DIR}/bin/qt.conf DESTINATION bin)
endif()
# Qt and Qwt
find_package(Qt5 OPTIONAL_COMPONENTS Core Gui Widgets OpenGL Network Concurrent Xml Svg Test LinguistTools Charts)
if (NOT ANDROID)
find_package(Qt5Help)
find_package(Qwt)
endif()
if (UNIX AND NOT APPLE AND NOT ANDROID)
find_package(Qt5X11Extras)
find_package(Qt5DBus)
endif ()
# Zeroconf
if (NOT ANDROID)
include(CMakeModules/zeroconf.cmake)
add_subdirectory(third_party/aware)
endif()
# Aseba itself
set(LIB_INSTALL_DIR lib CACHE FILEPATH "Where to install libraries")
set(LIB_VERSION_MAJOR 3) # Must be bumped for incompatible ABI changes
set(LIB_VERSION_MINOR 0)
set(LIB_VERSION_PATCH 0)
set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
if(WIN32)
add_subdirectory(third_party/bonjour)
set(ASEBA_SOURCE_DIRECTORY "${PROJECT_SOURCE_DIR}")
set(CPACK_MODULE_PATH ${PROJECT_SOURCE_DIR}/windows ${CPACK_MODULE_PATH})
set(CPACK_MONOLITHIC_INSTALL 1)
configure_file(
${PROJECT_SOURCE_DIR}/windows/NSIS.definitions.nsh.in
${CMAKE_CURRENT_BINARY_DIR}/resources/NSIS.definitions.nsh
)
endif()
set(CPACK_BUNDLE_NAME ThymioSuite)
set(CPACK_BUNDLE_PLIST ${PROJECT_SOURCE_DIR}/osx/Info.plist)
set(CPACK_BUNDLE_ICON ${PROJECT_SOURCE_DIR}/menu/osx/asebastudio.icns)
macro(install_symlink filepath sympath)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${filepath} ${sympath})")
install(CODE "message(\"-- Created symlink: ${sympath} -> ${filepath}\")")
endmacro(install_symlink)
SET(CPACK_PACKAGE_VERSION_MAJOR "${ASEBA_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${ASEBA_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${ASEBA_VERSION_PATCH}")
include(CPack)
add_subdirectory(aseba)
add_subdirectory(js)
if(NOT ANDROID)
# Unit tests
add_subdirectory(tests)
endif()
# User entries
if (UNIX)
add_subdirectory(menu)
endif()
find_package(Python3)
if(Python3_EXECUTABLE)
find_package(Qt5LinguistTools REQUIRED)
configure_file(
"${PROJECT_SOURCE_DIR}/maintainer/translations/langs.py"
"${CMAKE_CURRENT_BINARY_DIR}/langs.py")
add_custom_target("update-trads")
add_custom_command(TARGET "update-trads" COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/langs.py)
endif()
if(FLAT_PACK_BUILD)
SET(MOBSYA_WEBAPPS_ROOT_DIR "share/")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/scratch/index.html)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scratch/ DESTINATION "${MOBSYA_WEBAPPS_ROOT_DIR}scratch")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/scratch/ DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MOBSYA_WEBAPPS_ROOT_DIR}scratch")
endif()
if(EXISTS ${PROJECT_SOURCE_DIR}/thymio_blockly/index.html)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thymio_blockly/ DESTINATION "${MOBSYA_WEBAPPS_ROOT_DIR}thymio_blockly")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/thymio_blockly/ DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${MOBSYA_WEBAPPS_ROOT_DIR}thymio_blockly")
endif()
feature_summary( WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND ENABLED_FEATURES DISABLED_FEATURES)