Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | # Disable in-source builds to prevent source tree corruption. |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 2 | if(" ${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL " ${CMAKE_CURRENT_BINARY_DIR}") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 3 | message(FATAL_ERROR " |
| 4 | FATAL: In-source builds are not allowed. |
| 5 | You should create a separate directory for build files. |
| 6 | ") |
| 7 | endif() |
| 8 | |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 9 | if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") |
| 10 | set(CMAKE_SYSTEM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE) |
| 11 | set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE) |
| 12 | endif() |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 13 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 14 | cmake_minimum_required(VERSION 3.11) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 15 | project(allwpilib) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 16 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") |
| 17 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 18 | # Make timestamps of extracted files from FetchContent the time of extraction |
| 19 | if (POLICY CMP0135) |
| 20 | cmake_policy(SET CMP0135 NEW) |
| 21 | endif() |
| 22 | |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 23 | message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") |
| 24 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 25 | set(WPILIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 26 | |
| 27 | INCLUDE(CPack) |
| 28 | |
| 29 | set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) |
| 30 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 31 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 32 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/lib) |
| 33 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/lib) |
| 34 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/bin) |
| 35 | set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${WPILIB_BINARY_DIR}/jar) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 36 | |
| 37 | # use, i.e. don't skip the full RPATH for the build tree |
| 38 | SET(CMAKE_SKIP_BUILD_RPATH FALSE) |
| 39 | |
| 40 | # when building, don't use the install RPATH already |
| 41 | # (but later on when installing) |
| 42 | SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
| 43 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 44 | SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 45 | |
| 46 | # add the automatically determined parts of the RPATH |
| 47 | # which point to directories outside the build tree to the install RPATH |
| 48 | SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| 49 | |
| 50 | # the RPATH to be used when installing, but only if it's not a system directory |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 51 | LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 52 | IF("${isSystemDir}" STREQUAL "-1") |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 53 | SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 54 | ENDIF("${isSystemDir}" STREQUAL "-1") |
| 55 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 56 | # Options for building certain parts of the repo. Everything is built by default. |
| 57 | option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 58 | option(WITH_JAVA "Include Java and JNI in the build" ON) |
| 59 | option(WITH_JAVA_SOURCE "Build Java source jars" ON) |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 60 | option(WITH_CSCORE "Build cscore (needs OpenCV)" ON) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 61 | option(WITH_NTCORE "Build ntcore" ON) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 62 | option(WITH_WPIMATH "Build wpimath" ON) |
| 63 | option(WITH_WPILIB "Build hal, wpilibc/j, and myRobot (needs OpenCV)" ON) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 64 | option(WITH_EXAMPLES "Build examples" OFF) |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 65 | option(WITH_TESTS "Build unit tests (requires internet connection)" ON) |
| 66 | option(WITH_GUI "Build GUI items" ON) |
| 67 | option(WITH_SIMULATION_MODULES "Build simulation modules" ON) |
| 68 | |
| 69 | # Options for external HAL. |
| 70 | option(WITH_EXTERNAL_HAL "Use a separately built HAL" OFF) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 71 | set(EXTERNAL_HAL_FILE "" CACHE FILEPATH "Location to look for an external HAL CMake File") |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 72 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 73 | # Options for using a package manager (e.g., vcpkg) for certain dependencies. |
| 74 | option(USE_SYSTEM_FMTLIB "Use system fmtlib" OFF) |
| 75 | option(USE_SYSTEM_LIBUV "Use system libuv" OFF) |
| 76 | option(USE_SYSTEM_EIGEN "Use system eigen" OFF) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 77 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 78 | # Options for installation. |
| 79 | option(WITH_FLAT_INSTALL "Use a flat install directory" OFF) |
| 80 | |
| 81 | # Options for location of OpenCV Java. |
| 82 | set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file") |
| 83 | |
| 84 | # Set default build type to release with debug info (i.e. release mode optimizations |
| 85 | # are performed, but debug info still exists). |
| 86 | if (NOT CMAKE_BUILD_TYPE) |
| 87 | set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE) |
| 88 | endif() |
| 89 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 90 | if (WITH_JAVA AND NOT BUILD_SHARED_LIBS) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 91 | message(FATAL_ERROR " |
| 92 | FATAL: Cannot build static libs with Java enabled. |
| 93 | Static libs requires both BUILD_SHARED_LIBS=OFF and |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 94 | WITH_JAVA=OFF |
| 95 | ") |
| 96 | endif() |
| 97 | |
| 98 | if (WITH_SIMULATION_MODULES AND NOT BUILD_SHARED_LIBS) |
| 99 | message(FATAL_ERROR " |
| 100 | FATAL: Cannot build static libs with simulation modules enabled. |
| 101 | Static libs requires both BUILD_SHARED_LIBS=OFF and |
| 102 | WITH_SIMULATION_MODULES=OFF |
| 103 | ") |
| 104 | endif() |
| 105 | |
| 106 | if (NOT WITH_JAVA OR NOT WITH_CSCORE) |
| 107 | if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "") |
| 108 | message(WARNING " |
| 109 | WARNING: OpenCV Java dir set but java is not enabled! |
| 110 | It will be ignored. |
| 111 | ") |
| 112 | endif() |
| 113 | endif() |
| 114 | |
| 115 | if (NOT WITH_WPILIB AND WITH_SIMULATION_MODULES) |
| 116 | message(FATAL_ERROR " |
| 117 | FATAL: Cannot build simulation modules with wpilib disabled. |
| 118 | Enable wpilib by setting WITH_WPILIB=ON |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 119 | ") |
| 120 | endif() |
| 121 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 122 | if (NOT WITH_NTCORE AND WITH_CSCORE) |
| 123 | message(FATAL_ERROR " |
| 124 | FATAL: Cannot build cameraserver without ntcore. |
| 125 | Enable ntcore by setting WITH_NTCORE=ON |
| 126 | ") |
| 127 | endif() |
| 128 | |
| 129 | if (NOT WITH_NTCORE AND WITH_GUI) |
| 130 | message(FATAL_ERROR " |
| 131 | FATAL: Cannot build GUI modules without ntcore. |
| 132 | Enable ntcore by setting WITH_NTCORE=ON |
| 133 | ") |
| 134 | endif() |
| 135 | |
| 136 | if (NOT WITH_NTCORE AND WITH_SIMULATION_MODULES) |
| 137 | message(FATAL_ERROR " |
| 138 | FATAL: Cannot build simulation modules without ntcore. |
| 139 | Enable ntcore by setting WITH_NTCORE=ON |
| 140 | ") |
| 141 | endif() |
| 142 | |
| 143 | if (NOT WITH_NTCORE AND WITH_WPILIB) |
| 144 | message(FATAL_ERROR " |
| 145 | FATAL: Cannot build wpilib without ntcore. |
| 146 | Enable ntcore by setting WITH_NTCORE=ON |
| 147 | ") |
| 148 | endif() |
| 149 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 150 | if (NOT WITH_WPIMATH AND WITH_WPILIB) |
| 151 | message(FATAL_ERROR " |
| 152 | FATAL: Cannot build wpilib without wpimath. |
| 153 | Enable wpimath by setting WITH_WPIMATH=ON |
| 154 | ") |
| 155 | endif() |
| 156 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 157 | set( wpilib_dest "") |
| 158 | set( include_dest include ) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 159 | set( java_lib_dest java ) |
| 160 | set( jni_lib_dest jni ) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 161 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 162 | if (WITH_FLAT_INSTALL) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 163 | set (wpilib_config_dir ${wpilib_dest}) |
| 164 | else() |
| 165 | set (wpilib_config_dir share/wpilib) |
| 166 | endif() |
| 167 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 168 | if (USE_SYSTEM_LIBUV) |
| 169 | set (LIBUV_SYSTEM_REPLACE " |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 170 | find_dependency(libuv CONFIG) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 171 | ") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 172 | endif() |
| 173 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 174 | if (USE_SYSTEM_EIGEN) |
| 175 | set (EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 176 | endif() |
| 177 | |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 178 | find_package(LIBSSH 0.7.1) |
| 179 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 180 | find_package(Protobuf REQUIRED) |
| 181 | find_program(Quickbuf_EXECUTABLE |
| 182 | NAMES protoc-gen-quickbuf |
| 183 | DOC "The Quickbuf protoc plugin" |
| 184 | ) |
| 185 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 186 | if (WITH_FLAT_INSTALL) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 187 | set(WPIUTIL_DEP_REPLACE "include($\{SELF_DIR\}/wpiutil-config.cmake)") |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 188 | set(WPINET_DEP_REPLACE "include($\{SELF_DIR\}/wpinet-config.cmake)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 189 | set(NTCORE_DEP_REPLACE "include($\{SELF_DIR\}/ntcore-config.cmake)") |
| 190 | set(CSCORE_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cscore-config.cmake)") |
| 191 | set(CAMERASERVER_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cameraserver-config.cmake)") |
| 192 | set(HAL_DEP_REPLACE_IMPL "include(\${SELF_DIR}/hal-config.cmake)") |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 193 | set(WPIMATH_DEP_REPLACE "include($\{SELF_DIR\}/wpimath-config.cmake)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 194 | set(WPILIBC_DEP_REPLACE_IMPL "include(\${SELF_DIR}/wpilibc-config.cmake)") |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 195 | set(WPILIBNEWCOMMANDS_DEP_REPLACE "include(\${SELF_DIR}/wpilibNewcommands-config.cmake)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 196 | else() |
| 197 | set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)") |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 198 | set(WPINET_DEP_REPLACE "find_dependency(wpinet)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 199 | set(NTCORE_DEP_REPLACE "find_dependency(ntcore)") |
| 200 | set(CSCORE_DEP_REPLACE_IMPL "find_dependency(cscore)") |
| 201 | set(CAMERASERVER_DEP_REPLACE_IMPL "find_dependency(cameraserver)") |
| 202 | set(HAL_DEP_REPLACE_IMPL "find_dependency(hal)") |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 203 | set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 204 | set(WPILIBC_DEP_REPLACE_IMPL "find_dependency(wpilibc)") |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 205 | set(WPILIBNEWCOMMANDS_DEP_REPLACE "find_dependency(wpilibNewCommands)") |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 206 | endif() |
| 207 | |
| 208 | set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)") |
| 209 | set(SELF_DIR "$\{SELF_DIR\}") |
| 210 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 211 | get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) |
| 212 | |
| 213 | if(isMultiConfig) |
| 214 | if(NOT "Asan" IN_LIST CMAKE_CONFIGURATION_TYPES) |
| 215 | list(APPEND CMAKE_CONFIGURATION_TYPES Asan) |
| 216 | endif() |
| 217 | if(NOT "Tsan" IN_LIST CMAKE_CONFIGURATION_TYPES) |
| 218 | list(APPEND CMAKE_CONFIGURATION_TYPES Tsan) |
| 219 | endif() |
| 220 | if(NOT "Ubsan" IN_LIST CMAKE_CONFIGURATION_TYPES) |
| 221 | list(APPEND CMAKE_CONFIGURATION_TYPES Ubsan) |
| 222 | endif() |
| 223 | else() |
| 224 | set(allowedBuildTypes Asan Tsan Ubsan Debug Release RelWithDebInfo MinSizeRel) |
| 225 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowedBuildTypes}") |
| 226 | |
| 227 | if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE IN_LIST allowedBuildTypes) |
| 228 | message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}") |
| 229 | endif() |
| 230 | endif() |
| 231 | |
| 232 | set(CMAKE_C_FLAGS_ASAN |
| 233 | "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING |
| 234 | "Flags used by the C compiler for Asan build type or configuration." FORCE) |
| 235 | |
| 236 | set(CMAKE_CXX_FLAGS_ASAN |
| 237 | "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING |
| 238 | "Flags used by the C++ compiler for Asan build type or configuration." FORCE) |
| 239 | |
| 240 | set(CMAKE_EXE_LINKER_FLAGS_ASAN |
| 241 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING |
| 242 | "Linker flags to be used to create executables for Asan build type." FORCE) |
| 243 | |
| 244 | set(CMAKE_SHARED_LINKER_FLAGS_ASAN |
| 245 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING |
| 246 | "Linker lags to be used to create shared libraries for Asan build type." FORCE) |
| 247 | |
| 248 | set(CMAKE_C_FLAGS_TSAN |
| 249 | "${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING |
| 250 | "Flags used by the C compiler for Tsan build type or configuration." FORCE) |
| 251 | |
| 252 | set(CMAKE_CXX_FLAGS_TSAN |
| 253 | "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING |
| 254 | "Flags used by the C++ compiler for Tsan build type or configuration." FORCE) |
| 255 | |
| 256 | set(CMAKE_EXE_LINKER_FLAGS_TSAN |
| 257 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING |
| 258 | "Linker flags to be used to create executables for Tsan build type." FORCE) |
| 259 | |
| 260 | set(CMAKE_SHARED_LINKER_FLAGS_TSAN |
| 261 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING |
| 262 | "Linker lags to be used to create shared libraries for Tsan build type." FORCE) |
| 263 | |
| 264 | set(CMAKE_C_FLAGS_UBSAN |
| 265 | "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING |
| 266 | "Flags used by the C compiler for Ubsan build type or configuration." FORCE) |
| 267 | |
| 268 | set(CMAKE_CXX_FLAGS_UBSAN |
| 269 | "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING |
| 270 | "Flags used by the C++ compiler for Ubsan build type or configuration." FORCE) |
| 271 | |
| 272 | set(CMAKE_EXE_LINKER_FLAGS_UBSAN |
| 273 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all" CACHE STRING |
| 274 | "Linker flags to be used to create executables for Ubsan build type." FORCE) |
| 275 | |
| 276 | set(CMAKE_SHARED_LINKER_FLAGS_UBSAN |
| 277 | "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined" CACHE STRING |
| 278 | "Linker lags to be used to create shared libraries for Ubsan build type." FORCE) |
| 279 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 280 | if (WITH_TESTS) |
| 281 | enable_testing() |
| 282 | add_subdirectory(googletest) |
| 283 | include(GoogleTest) |
| 284 | endif() |
| 285 | |
| 286 | add_subdirectory(wpiutil) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 287 | |
| 288 | if (WITH_NTCORE) |
| 289 | add_subdirectory(wpinet) |
| 290 | add_subdirectory(ntcore) |
| 291 | endif() |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 292 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 293 | if (WITH_WPIMATH) |
| 294 | add_subdirectory(wpimath) |
| 295 | endif() |
| 296 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 297 | if (WITH_GUI) |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 298 | add_subdirectory(fieldImages) |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 299 | add_subdirectory(imgui) |
| 300 | add_subdirectory(wpigui) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 301 | add_subdirectory(glass) |
| 302 | add_subdirectory(outlineviewer) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 303 | add_subdirectory(sysid) |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 304 | if (LIBSSH_FOUND) |
| 305 | add_subdirectory(roborioteamnumbersetter) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 306 | add_subdirectory(datalogtool) |
Austin Schuh | 75263e3 | 2022-02-22 18:05:32 -0800 | [diff] [blame] | 307 | endif() |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 308 | endif() |
| 309 | |
| 310 | if (WITH_WPILIB OR WITH_SIMULATION_MODULES) |
| 311 | set(HAL_DEP_REPLACE ${HAL_DEP_REPLACE_IMPL}) |
| 312 | add_subdirectory(hal) |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 313 | endif() |
| 314 | |
| 315 | if (WITH_CSCORE) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 316 | set(CSCORE_DEP_REPLACE ${CSCORE_DEP_REPLACE_IMPL}) |
| 317 | set(CAMERASERVER_DEP_REPLACE ${CAMERASERVER_DEP_REPLACE_IMPL}) |
| 318 | add_subdirectory(cscore) |
| 319 | add_subdirectory(cameraserver) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 320 | endif() |
| 321 | |
| 322 | if (WITH_WPILIB) |
| 323 | set(WPILIBC_DEP_REPLACE ${WPILIBC_DEP_REPLACE_IMPL}) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 324 | add_subdirectory(apriltag) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 325 | add_subdirectory(wpilibj) |
| 326 | add_subdirectory(wpilibc) |
| 327 | add_subdirectory(wpilibNewCommands) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 328 | add_subdirectory(romiVendordep) |
| 329 | add_subdirectory(xrpVendordep) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 330 | if (WITH_EXAMPLES) |
| 331 | add_subdirectory(wpilibcExamples) |
| 332 | endif() |
| 333 | add_subdirectory(myRobot) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 334 | endif() |
| 335 | |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 336 | if (WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 337 | add_subdirectory(simulation) |
| 338 | endif() |
| 339 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 340 | configure_file(wpilib-config.cmake.in ${WPILIB_BINARY_DIR}/wpilib-config.cmake ) |
| 341 | install(FILES ${WPILIB_BINARY_DIR}/wpilib-config.cmake DESTINATION ${wpilib_config_dir}) |