2024-04-25 02:15:50 +00:00
cmake_minimum_required ( VERSION 3.18 )
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
message ( FATAL_ERROR "Do not build in-source. Please remove CMakeCache.txt and the CMakeFiles/ directory. Then build out-of-source." )
endif ( )
2024-04-25 02:18:00 +00:00
project ( noidb
2024-04-25 02:15:50 +00:00
V E R S I O N 0 . 1 . 0
L A N G U A G E S C C X X )
set ( CMAKE_EXPORT_COMPILE_COMMANDS ON )
set ( CMAKE_CXX_STANDARD 20 )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
set ( Seastar_CXX_DIALECT "gnu++20" CACHE STRING "" )
if ( APPLE )
add_compile_options ( -mmacosx-version-min=10.15 )
endif ( )
############################
## Modules and scripts ##
############################
# Standard CMake modules
include ( CTest ) # Must be called before adding tests but after calling project(). This automatically calls enable_testing() and configures ctest targets when using Make/Ninja
include ( CMakeDependentOption ) # This is a really useful scripts that creates options that depends on other options. It can even be used with generator expressions !
include ( GNUInstallDirs ) # This will define the default values for installation directories (all platforms even if named GNU)
include ( InstallRequiredSystemLibraries ) # Tell CMake that the `install` target needs to install required system libraries (eg: Windows SDK)
include ( CMakePackageConfigHelpers ) # Helper to create relocatable packages
find_program ( CCACHE_FOUND ccache )
if ( CCACHE_FOUND )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
endif ( CCACHE_FOUND )
# Custom modules and scripts
list ( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake" ) # Make our cmake scripts available
####################
## Dependencies ##
####################
2024-05-01 15:44:32 +00:00
find_package ( Boost REQUIRED COMPONENTS system )
if ( Boost_FOUND )
include_directories ( ${ Boost_INCLUDE_DIRS } )
endif ( )
2024-04-25 02:15:50 +00:00
###############
## Options ##
###############
option ( ENABLE_INSTALL
" S h o u l d $ { P R O J E C T _ N A M E } b e a d d e d t o t h e i n s t a l l l i s t ? U s e f u l i f i n c l u d e d u s i n g a d d _ s u b d i r e c t o r y . " O N )
set ( ${ PROJECT_NAME } _INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
C A C H E S T R I N G " P a t h t o i n s t a l l $ { P R O J E C T _ N A M E } C o n f i g * . c m a k e f i l e s t o . " )
###############
## Targets ##
###############
# Use the project root to find includes
include_directories ( ${ PROJECT_SOURCE_DIR } )
add_subdirectory ( seastar )
add_subdirectory ( src )
###############
## Packaging ##
###############
if ( ENABLE_INSTALL )
# Use version checking helper provided by CMake so that users can
# safely use a version number in their find_package calls
write_basic_package_version_file (
$ { P R O J E C T _ N A M E } C o n f i g V e r s i o n . c m a k e
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y S a m e M a j o r V e r s i o n )
configure_package_config_file (
$ { P R O J E C T _ S O U R C E _ D I R } / c m a k e / C o n f i g . c m a k e . i n
$ { P R O J E C T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } C o n f i g . c m a k e
I N S T A L L _ D E S T I N A T I O N $ { $ { P R O J E C T _ N A M E } _ I N S T A L L _ C M A K E D I R }
N O _ S E T _ A N D _ C H E C K _ M A C R O
N O _ C H E C K _ R E Q U I R E D _ C O M P O N E N T S _ M A C R O )
install (
2024-04-25 02:18:00 +00:00
T A R G E T S n o i d b
2024-04-25 02:15:50 +00:00
E X P O R T $ { P R O J E C T _ N A M E } _ T a r g e t s
I N C L U D E S D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } )
install ( DIRECTORY ${ PROJECT_NAME }
D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
F I L E S _ M A T C H I N G P A T T E R N * . h )
# This time, install all the exported targets under the
# ${PROJECT_NAME}_Targets name.
install (
E X P O R T $ { P R O J E C T _ N A M E } _ T a r g e t s
N A M E S P A C E $ { P R O J E C T _ N A M E } : :
F I L E $ { P R O J E C T _ N A M E } T a r g e t s . c m a k e
D E S T I N A T I O N $ { $ { P R O J E C T _ N A M E } _ I N S T A L L _ C M A K E D I R } )
# So far we only installed the exported targets, now install the package config files.
#
# If you do not list headers in the PUBLIC_HEADER property, you will need to copy them using
# `install(FILES)` or `install(DIRECTORY)` too.
#
# In that case, you can use CMAKE_INSTALL_INCLUDEDIR as the base destination path.
install ( FILES
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } C o n f i g . c m a k e
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } C o n f i g V e r s i o n . c m a k e
D E S T I N A T I O N $ { $ { P R O J E C T _ N A M E } _ I N S T A L L _ C M A K E D I R } )
endif ( )