Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 1 | ############################################### |
| 2 | ### BaSyx C++ SDK ### |
| 3 | ############################################### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 4 | cmake_minimum_required(VERSION 3.13.0) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 5 | |
| 6 | ### CMake settings ### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") |
Thomas Psota | b83ec3d | 2019-03-13 12:48:50 +0100 | [diff] [blame] | 8 | include(build_source_group) |
| 9 | include(diagnostics_print) |
| 10 | include(enable_clang_format) |
| 11 | include(enable_clang_tidy) |
| 12 | include(enable_cppcheck) |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 13 | include(enable_testbed) |
Tobias Klausmann | 08a5311 | 2019-12-04 14:55:58 +0100 | [diff] [blame] | 14 | include(GNUInstallDirs) |
| 15 | |
| 16 | set (BASYX_PACKAGE_VERSION_MAJOR "0") |
| 17 | set (BASYX_PACKAGE_VERSION_MINOR "1") |
| 18 | set (BASYX_PACKAGE_VERSION_PATCH "0") |
| 19 | |
| 20 | set (PROJECT_NAME "BaSyx C++ SDK") |
| 21 | set (PROJECT_SHORTNAME "BaSyx") |
Tobias Klausmann | 08a5311 | 2019-12-04 14:55:58 +0100 | [diff] [blame] | 22 | |
| 23 | project (${PROJECT_NAME} |
| 24 | VERSION ${BASYX_PACKAGE_VERSION_MAJOR}.${BASYX_PACKAGE_VERSION_MINOR}.${BASYX_PACKAGE_VERSION_PATCH} |
Tobias Klausmann | 08a5311 | 2019-12-04 14:55:58 +0100 | [diff] [blame] | 25 | ) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 26 | |
| 27 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 28 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 29 | set(CMAKE_ECLIPSE_MAKE_ARGUMENTS "-C ${CMAKE_BINARY_DIR} -j8" CACHE STRING "Make build arguments" FORCE) |
| 30 | |
| 31 | ### Project settings ### |
| 32 | |
| 33 | message(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}") |
| 34 | message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") |
| 35 | message(STATUS "" ) |
| 36 | |
| 37 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 38 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 39 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 40 | |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 41 | ### BaSyx directories ### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 42 | set(BASYX_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 43 | set(BASYX_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/include") |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 44 | set(BASYX_TEST_DIR "${CMAKE_SOURCE_DIR}/regression") |
| 45 | set(BASYX_LIBRARY_DIR "${CMAKE_SOURCE_DIR}/lib") |
| 46 | |
| 47 | ### Build options ### |
| 48 | set(BASYX_BUILD_TESTS ON CACHE BOOL "Build unit tests") |
| 49 | set(BASYX_BUILD_API ON CACHE BOOL "Build BaSyx API") |
| 50 | set(BASYX_UTILITY_PROJECTS ON CACHE BOOL "Create utility targets") |
| 51 | set(BASYX_DEBUG_PRINT_FRAMES OFF CACHE BOOL "Print BaSyx frames") |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 52 | set(BASYX_INSTALL_SDK ON CACHE BOOL "Create install instructions for BaSyx SDK") |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 53 | |
Tobias Klausmann | c6be340 | 2019-11-29 11:08:36 +0100 | [diff] [blame] | 54 | set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared (.so / .dll) instead of static libraries") |
| 55 | |
Tobias Klausmann | 9008db9 | 2020-01-22 16:43:32 +0100 | [diff] [blame] | 56 | option(BASYX_USE_SYSTEM_LIBFMT "Wether to build external, yet included library libfmt" OFF) |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 57 | option(BASYX_USE_SYSTEM_ASIO "Use system supplied ASIO library." OFF) |
Tobias Klausmann | cb3d9f0 | 2020-01-10 12:00:06 +0100 | [diff] [blame] | 58 | option(BASYX_USE_SYSTEM_JSON "Use system supplied nlohmann json library" OFF) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 59 | |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 60 | ### Compiler settings ### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 61 | set(CMAKE_CXX_STANDARD 11) |
| 62 | |
| 63 | ### Compile Step Definitions ### |
Tobias Klausmann | 08a5311 | 2019-12-04 14:55:58 +0100 | [diff] [blame] | 64 | add_compile_definitions(BASYX_MAJOR_REV=${BASYX_PACKAGE_VERSION_MAJOR}) |
| 65 | add_compile_definitions(BASYX_MINOR_REV=${BASYX_PACKAGE_VERSION_MINOR}) |
| 66 | add_compile_definitions(BASYX_PATCH_REV=${BASYX_PACKAGE_VERSION_PATCH}) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 67 | add_compile_definitions(WIN32_LEAN_AND_MEAN) |
Thomas Psota | b2e5cfe | 2019-09-16 16:48:57 +0200 | [diff] [blame] | 68 | ##add_compile_definitions(__USE_MINGW_ANSI_STDIO=0) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 69 | |
| 70 | ############################################### |
| 71 | ### Library Settings ### |
| 72 | ############################################### |
| 73 | |
| 74 | ### Detect OS threading library ### |
| 75 | find_package(Threads) |
| 76 | |
| 77 | ############################################### |
Tobias Klausmann | 80b097d | 2019-09-23 13:31:40 +0200 | [diff] [blame] | 78 | ### Library Directory ### |
| 79 | ############################################### |
| 80 | |
Tobias Klausmann | 9008db9 | 2020-01-22 16:43:32 +0100 | [diff] [blame] | 81 | if(${BASYX_USE_SYSTEM_LIBFMT}) |
| 82 | find_package(fmt REQUIRED) |
| 83 | else() |
Tobias Klausmann | 80b097d | 2019-09-23 13:31:40 +0200 | [diff] [blame] | 84 | add_subdirectory(lib/fmt) |
| 85 | add_library(lib::fmt ALIAS fmt) |
| 86 | add_library(lib::fmt-header-only ALIAS fmt-header-only) |
Tobias Klausmann | 80b097d | 2019-09-23 13:31:40 +0200 | [diff] [blame] | 87 | endif() |
| 88 | |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 89 | if(${BASYX_USE_SYSTEM_ASIO}) |
| 90 | find_package(asio REQUIRED) |
| 91 | else() |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 92 | add_subdirectory(lib/asio) |
| 93 | endif() |
| 94 | |
Tobias Klausmann | cb3d9f0 | 2020-01-10 12:00:06 +0100 | [diff] [blame] | 95 | if(${BASYX_USE_SYSTEM_JSON}) |
| 96 | find_package(nlohmann_json REQUIRED) |
| 97 | else() |
| 98 | add_subdirectory(lib/json) |
| 99 | endif() |
Tobias Klausmann | 80b097d | 2019-09-23 13:31:40 +0200 | [diff] [blame] | 100 | |
| 101 | if(${BASYX_BUILD_TESTS}) |
| 102 | add_subdirectory(lib/gtest) |
| 103 | include(GoogleTest) |
| 104 | endif() |
| 105 | |
| 106 | ############################################### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 107 | ### Source Directory ### |
| 108 | ############################################### |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 109 | include_directories("${BASYX_INCLUDE_DIR}") |
Tobias Klausmann | 405e8a7 | 2019-12-13 11:52:33 +0100 | [diff] [blame] | 110 | |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 111 | add_subdirectory(src/abstraction) |
Thomas Psota | 0e3b361 | 2019-05-14 11:45:32 +0200 | [diff] [blame] | 112 | add_subdirectory(src/logging) |
Thomas Psota | ab77907 | 2019-09-04 15:49:39 +0200 | [diff] [blame] | 113 | add_subdirectory(src/shared) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 114 | add_subdirectory(src/utility) |
Thomas Psota | ab77907 | 2019-09-04 15:49:39 +0200 | [diff] [blame] | 115 | add_subdirectory(src/vab) |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 116 | add_subdirectory(src/server) |
Thomas Psota | 176a20c | 2019-11-27 11:52:28 +0100 | [diff] [blame] | 117 | add_subdirectory(src/submodel) |
jwendelil4 | f7eede7 | 2020-03-25 18:35:15 +0100 | [diff] [blame] | 118 | add_subdirectory(src/aas) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 119 | |
| 120 | ############################################### |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 121 | ### Test Directory ### |
| 122 | ############################################### |
| 123 | |
| 124 | if(${BASYX_BUILD_TESTS}) |
| 125 | include( CTest ) |
Thomas Psota | ab77907 | 2019-09-04 15:49:39 +0200 | [diff] [blame] | 126 | add_subdirectory(tests) |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 127 | endif() |
| 128 | |
| 129 | ############################################### |
| 130 | ### Utility Projects ### |
| 131 | ############################################### |
| 132 | |
| 133 | if(${BASYX_UTILITY_PROJECTS}) |
| 134 | enable_clang_format() |
| 135 | enable_clang_tidy() |
| 136 | enable_cppcheck() |
Thomas Psota | 79a97d6 | 2019-11-25 15:33:10 +0100 | [diff] [blame] | 137 | enable_testbed() |
Thomas Psota | 94addb9 | 2019-03-12 16:16:18 +0100 | [diff] [blame] | 138 | endif() |
Tobias Klausmann | 08a5311 | 2019-12-04 14:55:58 +0100 | [diff] [blame] | 139 | |
Tobias Klausmann | 777c488 | 2020-01-23 16:34:13 +0100 | [diff] [blame] | 140 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 141 | ############################################### |
| 142 | ### Install section ### |
| 143 | ############################################### |
| 144 | |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 145 | if(${BASYX_INSTALL_SDK}) |
Tobias Klausmann | 777c488 | 2020-01-23 16:34:13 +0100 | [diff] [blame] | 146 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 147 | # Let the projects using our server infrastucure find asio (interally / |
| 148 | # externally provided) |
Tobias Klausmann | 777c488 | 2020-01-23 16:34:13 +0100 | [diff] [blame] | 149 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 150 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/Findasio.cmake |
| 151 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/BaSyxAsio |
| 152 | ) |
Tobias Klausmann | 65ad31d | 2020-01-24 15:08:57 +0100 | [diff] [blame] | 153 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 154 | ############################################### |
| 155 | ### Install overview ### |
| 156 | ############################################### |
Tobias Klausmann | 65ad31d | 2020-01-24 15:08:57 +0100 | [diff] [blame] | 157 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 158 | message("") |
| 159 | message("--------------------") |
| 160 | message("Configuration:") |
| 161 | message(" Library name and version: " "${PROJECT_NAME}, ${PROJECT_VERSION}" ) |
| 162 | message(" Library destination folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ) |
| 163 | message(" Includes folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_SHORTNAME} ) |
| 164 | #message(" Pkgconfig folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig ) |
| 165 | message(" CMake folder: " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_SHORTNAME} ) |
| 166 | message("") |
| 167 | if(${BASYX_USE_SYSTEM_LIBFMT}) |
| 168 | message(" Using system supplied fmt") |
| 169 | else() |
| 170 | message(" Using contained fmt - Please check if this is necessary!") |
| 171 | endif() |
Tobias Klausmann | 65ad31d | 2020-01-24 15:08:57 +0100 | [diff] [blame] | 172 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 173 | if(${BASYX_USE_SYSTEM_ASIO}) |
| 174 | message(" Using system supplied asio") |
| 175 | else() |
| 176 | message(" Using contained asio - Please check if this is necessary!") |
| 177 | endif() |
Tobias Klausmann | 65ad31d | 2020-01-24 15:08:57 +0100 | [diff] [blame] | 178 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 179 | if(${BASYX_USE_SYSTEM_JSON}) |
| 180 | message(" Using system supplied nlohmann_json") |
| 181 | else() |
| 182 | message(" Using contained nlohmann_json - Please check if this is necessary!") |
| 183 | endif() |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 184 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 185 | if ((NOT ${BASYX_USE_SYSTEM_LIBFMT}) OR (NOT ${BASYX_USE_SYSTEM_ASIO}) OR (NOT ${BASYX_USE_SYSTEM_JSON})) |
| 186 | message("") |
| 187 | message(" A contained external library will be installed while installing \ |
| 188 | BaSyx, please use distribution provided libraries if possible!") |
| 189 | endif() |
Thomas Psota | ec96181 | 2020-02-12 11:04:25 +0100 | [diff] [blame] | 190 | |
Thomas Psota | 2319c81 | 2020-02-12 13:47:26 +0100 | [diff] [blame] | 191 | endif() # ${BASYX_INSTALL_SDK} |