mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 11:55:51 +00:00 
			
		
		
		
	
							
								
								
									
										142
									
								
								CMakeLists.txt
									
									
									
									
									
								
							
							
						
						
									
										142
									
								
								CMakeLists.txt
									
									
									
									
									
								
							@@ -1,45 +1,51 @@
 | 
			
		||||
cmake_minimum_required(VERSION 3.16.3)
 | 
			
		||||
project(clio)
 | 
			
		||||
 | 
			
		||||
# ==================================================== #
 | 
			
		||||
#                       Options                        #
 | 
			
		||||
# ==================================================== #
 | 
			
		||||
option(verbose   "Verbose build"                FALSE) 
 | 
			
		||||
option(tests     "Build tests"                  FALSE)
 | 
			
		||||
option(docs      "Generate doxygen docs"        FALSE)
 | 
			
		||||
option(coverage  "Build test coverage report"   FALSE)
 | 
			
		||||
option(packaging "Create distribution packages" FALSE)
 | 
			
		||||
# ==================================================== #
 | 
			
		||||
# ========================================================================== #
 | 
			
		||||
#                                   Options                                  #
 | 
			
		||||
# ========================================================================== #
 | 
			
		||||
option (verbose   "Verbose build"                                     FALSE) 
 | 
			
		||||
option (tests     "Build tests"                                       FALSE)
 | 
			
		||||
option (docs      "Generate doxygen docs"                             FALSE)
 | 
			
		||||
option (coverage  "Build test coverage report"                        FALSE)
 | 
			
		||||
option (packaging "Create distribution packages"                      FALSE)
 | 
			
		||||
# ========================================================================== #
 | 
			
		||||
set (san "" CACHE STRING "Add sanitizer instrumentation")
 | 
			
		||||
set_property (CACHE san PROPERTY STRINGS ";undefined;memory;address;thread")
 | 
			
		||||
# ========================================================================== #
 | 
			
		||||
 | 
			
		||||
if(verbose)
 | 
			
		||||
  set(CMAKE_VERBOSE_MAKEFILE TRUE)
 | 
			
		||||
endif()
 | 
			
		||||
# Include required modules
 | 
			
		||||
include (CheckCXXCompilerFlag)
 | 
			
		||||
 | 
			
		||||
if(packaging)
 | 
			
		||||
  add_definitions(-DPKG=1)
 | 
			
		||||
endif()
 | 
			
		||||
if (verbose)
 | 
			
		||||
  set (CMAKE_VERBOSE_MAKEFILE TRUE)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
add_library(clio)
 | 
			
		||||
if (packaging)
 | 
			
		||||
  add_definitions (-DPKG=1)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
add_library (clio)
 | 
			
		||||
 | 
			
		||||
# Clio tweaks and checks
 | 
			
		||||
include(CMake/CheckCompiler.cmake)
 | 
			
		||||
include(CMake/Settings.cmake)
 | 
			
		||||
include(CMake/ClioVersion.cmake)
 | 
			
		||||
include(CMake/SourceLocation.cmake)
 | 
			
		||||
include (CMake/CheckCompiler.cmake)
 | 
			
		||||
include (CMake/Settings.cmake)
 | 
			
		||||
include (CMake/ClioVersion.cmake)
 | 
			
		||||
include (CMake/SourceLocation.cmake)
 | 
			
		||||
 | 
			
		||||
# Clio deps
 | 
			
		||||
include(CMake/deps/libxrpl.cmake)
 | 
			
		||||
include(CMake/deps/Boost.cmake)
 | 
			
		||||
include(CMake/deps/OpenSSL.cmake)
 | 
			
		||||
include(CMake/deps/Threads.cmake)
 | 
			
		||||
include(CMake/deps/libfmt.cmake)
 | 
			
		||||
include(CMake/deps/cassandra.cmake)
 | 
			
		||||
include (CMake/deps/libxrpl.cmake)
 | 
			
		||||
include (CMake/deps/Boost.cmake)
 | 
			
		||||
include (CMake/deps/OpenSSL.cmake)
 | 
			
		||||
include (CMake/deps/Threads.cmake)
 | 
			
		||||
include (CMake/deps/libfmt.cmake)
 | 
			
		||||
include (CMake/deps/cassandra.cmake)
 | 
			
		||||
 | 
			
		||||
# TODO: Include directory will be wrong when installed.
 | 
			
		||||
target_include_directories(clio PUBLIC src)
 | 
			
		||||
target_compile_features(clio PUBLIC cxx_std_20)
 | 
			
		||||
target_include_directories (clio PUBLIC src)
 | 
			
		||||
target_compile_features (clio PUBLIC cxx_std_20)
 | 
			
		||||
 | 
			
		||||
target_link_libraries(clio
 | 
			
		||||
target_link_libraries (clio
 | 
			
		||||
  PUBLIC Boost::boost
 | 
			
		||||
  PUBLIC Boost::coroutine
 | 
			
		||||
  PUBLIC Boost::program_options
 | 
			
		||||
@@ -55,12 +61,12 @@ target_link_libraries(clio
 | 
			
		||||
  INTERFACE Threads::Threads
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 | 
			
		||||
if (is_gcc)
 | 
			
		||||
  # FIXME: needed on gcc for now
 | 
			
		||||
  target_compile_definitions(clio PUBLIC BOOST_ASIO_DISABLE_CONCEPTS)
 | 
			
		||||
endif()
 | 
			
		||||
  target_compile_definitions (clio PUBLIC BOOST_ASIO_DISABLE_CONCEPTS)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
target_sources(clio PRIVATE
 | 
			
		||||
target_sources (clio PRIVATE
 | 
			
		||||
  ## Main
 | 
			
		||||
  src/main/impl/Build.cpp
 | 
			
		||||
  ## Backend
 | 
			
		||||
@@ -83,6 +89,8 @@ target_sources(clio PRIVATE
 | 
			
		||||
  src/etl/impl/ForwardCache.cpp
 | 
			
		||||
  ## Feed
 | 
			
		||||
  src/feed/SubscriptionManager.cpp
 | 
			
		||||
  ## Web
 | 
			
		||||
  src/web/IntervalSweepHandler.cpp
 | 
			
		||||
  ## RPC
 | 
			
		||||
  src/rpc/Errors.cpp
 | 
			
		||||
  src/rpc/Factories.cpp
 | 
			
		||||
@@ -126,13 +134,13 @@ target_sources(clio PRIVATE
 | 
			
		||||
  src/util/Taggable.cpp)
 | 
			
		||||
 | 
			
		||||
# Clio server
 | 
			
		||||
add_executable(clio_server src/main/Main.cpp)
 | 
			
		||||
target_link_libraries(clio_server PUBLIC clio)
 | 
			
		||||
add_executable (clio_server src/main/Main.cpp)
 | 
			
		||||
target_link_libraries (clio_server PUBLIC clio)
 | 
			
		||||
 | 
			
		||||
# Unittesting
 | 
			
		||||
if(tests)
 | 
			
		||||
  set(TEST_TARGET clio_tests)
 | 
			
		||||
  add_executable(${TEST_TARGET}
 | 
			
		||||
if (tests)
 | 
			
		||||
  set (TEST_TARGET clio_tests)
 | 
			
		||||
  add_executable (${TEST_TARGET}
 | 
			
		||||
    # Common
 | 
			
		||||
    unittests/Main.cpp
 | 
			
		||||
    unittests/Playground.cpp
 | 
			
		||||
@@ -206,38 +214,50 @@ if(tests)
 | 
			
		||||
    unittests/web/WhitelistHandlerTests.cpp
 | 
			
		||||
    unittests/web/SweepHandlerTests.cpp)
 | 
			
		||||
 | 
			
		||||
  include(CMake/deps/gtest.cmake)
 | 
			
		||||
  include (CMake/deps/gtest.cmake)
 | 
			
		||||
 | 
			
		||||
  # See https://github.com/google/googletest/issues/3475
 | 
			
		||||
  gtest_discover_tests(clio_tests DISCOVERY_TIMEOUT 10)
 | 
			
		||||
  gtest_discover_tests (clio_tests DISCOVERY_TIMEOUT 10)
 | 
			
		||||
 | 
			
		||||
  # Fix for dwarf5 bug on ci 
 | 
			
		||||
  target_compile_options(clio PUBLIC -gdwarf-4)
 | 
			
		||||
  target_compile_options (clio PUBLIC -gdwarf-4)
 | 
			
		||||
 | 
			
		||||
  # TODO: support sanitizers properly
 | 
			
		||||
  # Tmp: uncomment for TSAN
 | 
			
		||||
  # target_compile_options(${TEST_TARGET} PRIVATE -fsanitize=thread)
 | 
			
		||||
  # target_link_options(${TEST_TARGET} PRIVATE -fsanitize=thread)
 | 
			
		||||
 | 
			
		||||
  target_compile_definitions(${TEST_TARGET} PUBLIC UNITTEST_BUILD)
 | 
			
		||||
  target_include_directories(${TEST_TARGET} PRIVATE unittests)
 | 
			
		||||
  target_link_libraries(${TEST_TARGET} PUBLIC clio gtest::gtest)
 | 
			
		||||
  target_compile_definitions (${TEST_TARGET} PUBLIC UNITTEST_BUILD)
 | 
			
		||||
  target_include_directories (${TEST_TARGET} PRIVATE unittests)
 | 
			
		||||
  target_link_libraries (${TEST_TARGET} PUBLIC clio gtest::gtest)
 | 
			
		||||
 | 
			
		||||
  # Generate `clio_tests-ccov` if coverage is enabled
 | 
			
		||||
  # Note: use `make clio_tests-ccov` to generate report
 | 
			
		||||
  if(coverage)
 | 
			
		||||
    include(CMake/Coverage.cmake)
 | 
			
		||||
    add_coverage(${TEST_TARGET})
 | 
			
		||||
  endif()
 | 
			
		||||
endif()
 | 
			
		||||
  if (coverage)
 | 
			
		||||
    include (CMake/Coverage.cmake)
 | 
			
		||||
    add_coverage (${TEST_TARGET})
 | 
			
		||||
  endif ()
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
# Enable selected sanitizer if enabled via `san`
 | 
			
		||||
if (san)
 | 
			
		||||
  target_compile_options (clio
 | 
			
		||||
    PUBLIC
 | 
			
		||||
      # Sanitizers recommend minimum of -O1 for reasonable performance
 | 
			
		||||
      $<$<CONFIG:Debug>:-O1>
 | 
			
		||||
      ${SAN_FLAG}
 | 
			
		||||
      -fno-omit-frame-pointer)
 | 
			
		||||
  target_compile_definitions (clio
 | 
			
		||||
    PUBLIC
 | 
			
		||||
      $<$<STREQUAL:${san},address>:SANITIZER=ASAN>
 | 
			
		||||
      $<$<STREQUAL:${san},thread>:SANITIZER=TSAN>
 | 
			
		||||
      $<$<STREQUAL:${san},memory>:SANITIZER=MSAN>
 | 
			
		||||
      $<$<STREQUAL:${san},undefined>:SANITIZER=UBSAN>)
 | 
			
		||||
  target_link_libraries (clio INTERFACE ${SAN_FLAG} ${SAN_LIB})
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
# Generate `docs` target for doxygen documentation if enabled
 | 
			
		||||
# Note: use `make docs` to generate the documentation
 | 
			
		||||
if(docs)
 | 
			
		||||
  include(CMake/Docs.cmake)
 | 
			
		||||
endif()
 | 
			
		||||
if (docs)
 | 
			
		||||
  include (CMake/Docs.cmake)
 | 
			
		||||
endif ()
 | 
			
		||||
 | 
			
		||||
include(CMake/install/install.cmake)
 | 
			
		||||
if(packaging)
 | 
			
		||||
  include(CMake/packaging.cmake) # This file exists only in build runner
 | 
			
		||||
endif()
 | 
			
		||||
include (CMake/install/install.cmake)
 | 
			
		||||
if (packaging)
 | 
			
		||||
  include (CMake/packaging.cmake) # This file exists only in build runner
 | 
			
		||||
endif ()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user