cmake_minimum_required(VERSION 3.18) project( versioned-map VERSION 0.0.1 DESCRIPTION "A data structure for mvcc reads on bitwise-lexicographically-ordered keys." HOMEPAGE_URL "https://git.weaselab.dev/weaselab/versioned-map" LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) file(WRITE ${CMAKE_BINARY_DIR}/version.txt ${PROJECT_VERSION}) include(CMakePushCheckState) include(CheckCXXSourceCompiles) set(DEFAULT_BUILD_TYPE "Release") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message( STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.") set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() add_compile_options(-fdata-sections -ffunction-sections -Wswitch-enum -Werror=switch-enum -fPIC) set(full_relro_flags "-pie;LINKER:-z,relro,-z,now,-z,noexecstack") cmake_push_check_state() list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${full_relro_flags}) check_cxx_source_compiles("int main(){}" HAS_FULL_RELRO FAIL_REGEX "warning:") if(HAS_FULL_RELRO) add_link_options(${full_relro_flags}) endif() cmake_pop_check_state() set(version_script_flags LINKER:--version-script=${CMAKE_SOURCE_DIR}/linker.map) cmake_push_check_state() list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${version_script_flags}) check_cxx_source_compiles("int main(){}" HAS_VERSION_SCRIPT FAIL_REGEX "warning:") cmake_pop_check_state() # This is encouraged according to # https://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/third_party/valgrind) if(APPLE) add_link_options(-Wl,-dead_strip) else() add_link_options(-Wl,--gc-sections) endif() set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") add_subdirectory(third_party) add_library(versioned_map VersionedMap.cpp) target_include_directories(versioned_map PUBLIC ${CMAKE_SOURCE_DIR}/include)