mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-03 04:01:01 +00:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
76 lines
2.7 KiB
CMake
76 lines
2.7 KiB
CMake
#[===================================================================[
|
|
sanity checks
|
|
#]===================================================================]
|
|
|
|
include(CompilationEnv)
|
|
|
|
get_property(is_multiconfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
|
|
if(NOT is_multiconfig)
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
message(STATUS "Build type not specified - defaulting to Release")
|
|
set(CMAKE_BUILD_TYPE Release CACHE STRING "build type" FORCE)
|
|
elseif(
|
|
NOT (CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL Release)
|
|
)
|
|
# for simplicity, these are the only two config types we care about. Limiting the build types simplifies dealing
|
|
# with external project builds especially
|
|
message(
|
|
FATAL_ERROR
|
|
" *** Only Debug or Release build types are currently supported ***"
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
if(is_clang) # both Clang and AppleClang
|
|
if(
|
|
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"
|
|
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16.0
|
|
)
|
|
message(FATAL_ERROR "This project requires clang 16 or later")
|
|
endif()
|
|
elseif(is_gcc)
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)
|
|
message(FATAL_ERROR "This project requires GCC 12 or later")
|
|
endif()
|
|
endif()
|
|
|
|
# A Nix compiler is only meant to be used from a managed environment: the xrpld
|
|
# dev shell (which exports XRPL_DEVSHELL) or the CI image. Using one from a bare
|
|
# shell usually means a leaked toolchain (picked up via PATH or a Conan profile)
|
|
# and leads to confusing breakage, so fail early with guidance.
|
|
if(is_nix_compiler AND NOT is_ci_image AND NOT DEFINED ENV{XRPL_DEVSHELL})
|
|
message(
|
|
FATAL_ERROR
|
|
"A Nix compiler (${CMAKE_CXX_COMPILER}) is being used outside the xrpld "
|
|
"dev shell. Enter it with `nix develop` (see docs/build/nix.md) before "
|
|
"configuring the build."
|
|
)
|
|
endif()
|
|
|
|
# check for in-source build and fail
|
|
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
|
message(
|
|
FATAL_ERROR
|
|
"Builds (in-source) are not allowed in "
|
|
"${CMAKE_CURRENT_SOURCE_DIR}. Please remove CMakeCache.txt and the CMakeFiles "
|
|
"directory from ${CMAKE_CURRENT_SOURCE_DIR} and try building in a separate directory."
|
|
)
|
|
endif()
|
|
|
|
if(MSVC AND CMAKE_GENERATOR_PLATFORM STREQUAL "Win32")
|
|
message(FATAL_ERROR "Visual Studio 32-bit build is not supported.")
|
|
endif()
|
|
|
|
if(voidstar AND NOT is_amd64)
|
|
message(
|
|
FATAL_ERROR
|
|
"The voidstar library only supported on amd64/x86_64. Detected archictecture was: ${CMAKE_SYSTEM_PROCESSOR}"
|
|
)
|
|
endif()
|
|
|
|
if(APPLE AND NOT HOMEBREW)
|
|
find_program(HOMEBREW brew)
|
|
endif()
|