cmake_minimum_required(VERSION 3.10) project(jay VERSION 0.0.1 LANGUAGES CXX ) option(JAY_ENABLE_ASAN "Enable Address Sanitizer" OFF) option(JAY_ENABLE_UBSAN "Enable Undefined Behavior Sanitizer" OFF) option(JAY_ENABLE_TSAN "Enable Thread Sanitizer" OFF) option(JAY_ENABLE_LTO "Enable Link Time Optimization" OFF) option(JAY_ENABLE_STATIC_ANALYSIS "Enable static analysis during build" OFF) option(JAY_ENABLE_COVERAGE "Enable coverage reporting" OFF) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build (Debug/Release)" FORCE) endif() message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}") set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options( -Wall -Wextra -Wpedantic ) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_options( -Werror -Wconversion -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wsign-conversion -Wnull-dereference -fno-omit-frame-pointer ) add_compile_options(-O0 -g3 -ggdb) endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-O3 -DNDEBUG) endif() if(JAY_ENABLE_ASAN) add_compile_options(-fsanitize=address) add_link_options(-fsanitize=address) endif() if(JAY_ENABLE_UBSAN) add_compile_options(-fsanitize=undefined) add_link_options(-fsanitize=undefined) endif() if(JAY_ENABLE_TSAN) add_compile_options(-fsanitize=thread) add_link_options(-fsanitize=thread) endif() endif() if(JAY_ENABLE_LTO) include(CheckIPOSupported) check_ipo_supported(RESULT supported OUTPUT error) if(supported) message(STATUS "IPO / LTO enabled") set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) else() message(STATUS "IPO / LTO not supported: <${error}>") endif() endif() if(JAY_ENABLE_STATIC_ANALYSIS) find_program(CLANG_TIDY NAMES clang-tidy) if(CLANG_TIDY) set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY}) endif() endif() if(JAY_ENABLE_COVERAGE) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options(--coverage) add_link_options(--coverage) endif() endif() cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0167 NEW) #FindBoost find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) find_package(yaml-cpp REQUIRED) find_package(Boost REQUIRED COMPONENTS log log_setup thread system) pkg_search_module(GLOOX REQUIRED gloox) pkg_check_modules(UUID REQUIRED uuid) set(EXEC_NAME "jay") add_subdirectory(src)