blob: c79f61862907e57c4bcb2930be212741a7b216ae [file] [log] [blame]
Thomas Psota94addb92019-03-12 16:16:18 +01001###############################################
2### BaSyx C++ SDK ###
3###############################################
Thomas Psota94addb92019-03-12 16:16:18 +01004cmake_minimum_required(VERSION 3.13.0)
Thomas Psota94addb92019-03-12 16:16:18 +01005
6### CMake settings ###
Thomas Psota94addb92019-03-12 16:16:18 +01007list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
Thomas Psotab83ec3d2019-03-13 12:48:50 +01008include(build_source_group)
9include(diagnostics_print)
10include(enable_clang_format)
11include(enable_clang_tidy)
12include(enable_cppcheck)
Thomas Psota79a97d62019-11-25 15:33:10 +010013include(enable_testbed)
Tobias Klausmann08a53112019-12-04 14:55:58 +010014include(GNUInstallDirs)
15
16set (BASYX_PACKAGE_VERSION_MAJOR "0")
17set (BASYX_PACKAGE_VERSION_MINOR "1")
18set (BASYX_PACKAGE_VERSION_PATCH "0")
19
20set (PROJECT_NAME "BaSyx C++ SDK")
21set (PROJECT_SHORTNAME "BaSyx")
Tobias Klausmann08a53112019-12-04 14:55:58 +010022
23project (${PROJECT_NAME}
24 VERSION ${BASYX_PACKAGE_VERSION_MAJOR}.${BASYX_PACKAGE_VERSION_MINOR}.${BASYX_PACKAGE_VERSION_PATCH}
Tobias Klausmann08a53112019-12-04 14:55:58 +010025 )
Thomas Psota94addb92019-03-12 16:16:18 +010026
27set_property(GLOBAL PROPERTY USE_FOLDERS ON)
28set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
29set(CMAKE_ECLIPSE_MAKE_ARGUMENTS "-C ${CMAKE_BINARY_DIR} -j8" CACHE STRING "Make build arguments" FORCE)
30
31### Project settings ###
32
33message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
34message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
35message(STATUS "" )
36
37set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
38set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
39set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
40
Thomas Psotaec961812020-02-12 11:04:25 +010041### BaSyx directories ###
Thomas Psota94addb92019-03-12 16:16:18 +010042set(BASYX_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src")
Thomas Psota2319c812020-02-12 13:47:26 +010043set(BASYX_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include")
Thomas Psota94addb92019-03-12 16:16:18 +010044set(BASYX_TEST_DIR "${CMAKE_SOURCE_DIR}/regression")
45set(BASYX_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/lib")
46
47### Build options ###
48set(BASYX_BUILD_TESTS ON CACHE BOOL "Build unit tests")
49set(BASYX_BUILD_API ON CACHE BOOL "Build BaSyx API")
50set(BASYX_UTILITY_PROJECTS ON CACHE BOOL "Create utility targets")
51set(BASYX_DEBUG_PRINT_FRAMES OFF CACHE BOOL "Print BaSyx frames")
Thomas Psotaec961812020-02-12 11:04:25 +010052set(BASYX_INSTALL_SDK ON CACHE BOOL "Create install instructions for BaSyx SDK")
Thomas Psota94addb92019-03-12 16:16:18 +010053
Tobias Klausmannc6be3402019-11-29 11:08:36 +010054set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared (.so / .dll) instead of static libraries")
55
Tobias Klausmann9008db92020-01-22 16:43:32 +010056option(BASYX_USE_SYSTEM_LIBFMT "Wether to build external, yet included library libfmt" OFF)
Thomas Psota79a97d62019-11-25 15:33:10 +010057option(BASYX_USE_SYSTEM_ASIO "Use system supplied ASIO library." OFF)
Tobias Klausmanncb3d9f02020-01-10 12:00:06 +010058option(BASYX_USE_SYSTEM_JSON "Use system supplied nlohmann json library" OFF)
Thomas Psota94addb92019-03-12 16:16:18 +010059
Thomas Psotaec961812020-02-12 11:04:25 +010060### Compiler settings ###
Thomas Psota94addb92019-03-12 16:16:18 +010061set(CMAKE_CXX_STANDARD 11)
62
63### Compile Step Definitions ###
Tobias Klausmann08a53112019-12-04 14:55:58 +010064add_compile_definitions(BASYX_MAJOR_REV=${BASYX_PACKAGE_VERSION_MAJOR})
65add_compile_definitions(BASYX_MINOR_REV=${BASYX_PACKAGE_VERSION_MINOR})
66add_compile_definitions(BASYX_PATCH_REV=${BASYX_PACKAGE_VERSION_PATCH})
Thomas Psota94addb92019-03-12 16:16:18 +010067add_compile_definitions(WIN32_LEAN_AND_MEAN)
Thomas Psotab2e5cfe2019-09-16 16:48:57 +020068##add_compile_definitions(__USE_MINGW_ANSI_STDIO=0)
Thomas Psota94addb92019-03-12 16:16:18 +010069
70###############################################
71### Library Settings ###
72###############################################
73
74### Detect OS threading library ###
75find_package(Threads)
76
77###############################################
Tobias Klausmann80b097d2019-09-23 13:31:40 +020078### Library Directory ###
79###############################################
80
Tobias Klausmann9008db92020-01-22 16:43:32 +010081if(${BASYX_USE_SYSTEM_LIBFMT})
82 find_package(fmt REQUIRED)
83else()
Tobias Klausmann80b097d2019-09-23 13:31:40 +020084 add_subdirectory(lib/fmt)
85 add_library(lib::fmt ALIAS fmt)
86 add_library(lib::fmt-header-only ALIAS fmt-header-only)
Tobias Klausmann80b097d2019-09-23 13:31:40 +020087endif()
88
Thomas Psota79a97d62019-11-25 15:33:10 +010089if(${BASYX_USE_SYSTEM_ASIO})
90 find_package(asio REQUIRED)
91else()
Thomas Psota79a97d62019-11-25 15:33:10 +010092 add_subdirectory(lib/asio)
93endif()
94
Tobias Klausmanncb3d9f02020-01-10 12:00:06 +010095if(${BASYX_USE_SYSTEM_JSON})
96 find_package(nlohmann_json REQUIRED)
97else()
98 add_subdirectory(lib/json)
99endif()
Tobias Klausmann80b097d2019-09-23 13:31:40 +0200100
101if(${BASYX_BUILD_TESTS})
102 add_subdirectory(lib/gtest)
103 include(GoogleTest)
104endif()
105
106###############################################
Thomas Psota94addb92019-03-12 16:16:18 +0100107### Source Directory ###
108###############################################
Thomas Psota2319c812020-02-12 13:47:26 +0100109include_directories("${BASYX_INCLUDE_DIR}")
Tobias Klausmann405e8a72019-12-13 11:52:33 +0100110
Thomas Psota94addb92019-03-12 16:16:18 +0100111add_subdirectory(src/abstraction)
Thomas Psota0e3b3612019-05-14 11:45:32 +0200112add_subdirectory(src/logging)
Thomas Psotaab779072019-09-04 15:49:39 +0200113add_subdirectory(src/shared)
Thomas Psota94addb92019-03-12 16:16:18 +0100114add_subdirectory(src/utility)
Thomas Psotaab779072019-09-04 15:49:39 +0200115add_subdirectory(src/vab)
Thomas Psota79a97d62019-11-25 15:33:10 +0100116add_subdirectory(src/server)
Thomas Psota176a20c2019-11-27 11:52:28 +0100117add_subdirectory(src/submodel)
jwendelil4f7eede72020-03-25 18:35:15 +0100118add_subdirectory(src/aas)
Thomas Psota94addb92019-03-12 16:16:18 +0100119
120###############################################
Thomas Psota94addb92019-03-12 16:16:18 +0100121### Test Directory ###
122###############################################
123
124if(${BASYX_BUILD_TESTS})
125 include( CTest )
Thomas Psotaab779072019-09-04 15:49:39 +0200126 add_subdirectory(tests)
Thomas Psota94addb92019-03-12 16:16:18 +0100127endif()
128
129###############################################
130### Utility Projects ###
131###############################################
132
133if(${BASYX_UTILITY_PROJECTS})
134 enable_clang_format()
135 enable_clang_tidy()
136 enable_cppcheck()
Thomas Psota79a97d62019-11-25 15:33:10 +0100137 enable_testbed()
Thomas Psota94addb92019-03-12 16:16:18 +0100138endif()
Tobias Klausmann08a53112019-12-04 14:55:58 +0100139
Tobias Klausmann777c4882020-01-23 16:34:13 +0100140
Thomas Psota2319c812020-02-12 13:47:26 +0100141###############################################
142### Install section ###
143###############################################
144
Thomas Psotaec961812020-02-12 11:04:25 +0100145if(${BASYX_INSTALL_SDK})
Tobias Klausmann777c4882020-01-23 16:34:13 +0100146
Thomas Psota2319c812020-02-12 13:47:26 +0100147# Let the projects using our server infrastucure find asio (interally /
148# externally provided)
Tobias Klausmann777c4882020-01-23 16:34:13 +0100149
Thomas Psota2319c812020-02-12 13:47:26 +0100150install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/Findasio.cmake
151 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/BaSyxAsio
152)
Tobias Klausmann65ad31d2020-01-24 15:08:57 +0100153
Thomas Psota2319c812020-02-12 13:47:26 +0100154###############################################
155### Install overview ###
156###############################################
Tobias Klausmann65ad31d2020-01-24 15:08:57 +0100157
Thomas Psota2319c812020-02-12 13:47:26 +0100158message("")
159message("--------------------")
160message("Configuration:")
161message(" Library name and version: " "${PROJECT_NAME}, ${PROJECT_VERSION}" )
162message(" Library destination folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} )
163message(" Includes folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_SHORTNAME} )
164#message(" Pkgconfig folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig )
165message(" CMake folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_SHORTNAME} )
166message("")
167if(${BASYX_USE_SYSTEM_LIBFMT})
168message(" Using system supplied fmt")
169else()
170message(" Using contained fmt - Please check if this is necessary!")
171endif()
Tobias Klausmann65ad31d2020-01-24 15:08:57 +0100172
Thomas Psota2319c812020-02-12 13:47:26 +0100173if(${BASYX_USE_SYSTEM_ASIO})
174message(" Using system supplied asio")
175else()
176message(" Using contained asio - Please check if this is necessary!")
177endif()
Tobias Klausmann65ad31d2020-01-24 15:08:57 +0100178
Thomas Psota2319c812020-02-12 13:47:26 +0100179if(${BASYX_USE_SYSTEM_JSON})
180message(" Using system supplied nlohmann_json")
181else()
182message(" Using contained nlohmann_json - Please check if this is necessary!")
183endif()
Thomas Psotaec961812020-02-12 11:04:25 +0100184
Thomas Psota2319c812020-02-12 13:47:26 +0100185if ((NOT ${BASYX_USE_SYSTEM_LIBFMT}) OR (NOT ${BASYX_USE_SYSTEM_ASIO}) OR (NOT ${BASYX_USE_SYSTEM_JSON}))
186message("")
187message(" A contained external library will be installed while installing \
188BaSyx, please use distribution provided libraries if possible!")
189endif()
Thomas Psotaec961812020-02-12 11:04:25 +0100190
Thomas Psota2319c812020-02-12 13:47:26 +0100191endif() # ${BASYX_INSTALL_SDK}