cmake_minimum_required(VERSION 3.10) project(jay VERSION 0.0.1 LANGUAGES CXX ) # Build type options 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_STRICT "Enable strict compiler warnings" OFF) option(JAY_ENABLE_LTO "Enable Link Time Optimization" OFF) # Set default build type if not specified 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) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") add_compile_options( -Wall -Wextra -Wpedantic ) if(JAY_ENABLE_STRICT) add_compile_options( -Werror -Wconversion -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wsign-conversion -Wnull-dereference ) endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") 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 -fno-omit-frame-pointer) 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() # Link Time Optimization 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() cmake_policy(SET CMP0076 NEW) find_package(PkgConfig REQUIRED) pkg_search_module(GLOOX REQUIRED gloox) find_package(yaml-cpp REQUIRED) pkg_check_modules(UUID REQUIRED uuid) set(EXEC_NAME "jay") add_subdirectory(src)