Project reorganization
This commit is contained in:
parent
d6f95d89fa
commit
a1ec9f731d
38 changed files with 182 additions and 87 deletions
|
@ -1,12 +1,84 @@
|
|||
cmake_minimum_required(VERSION 3.10)
|
||||
project(jay
|
||||
VERSION 0.0.1
|
||||
LANGUAGES CXX
|
||||
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)
|
||||
|
@ -18,20 +90,4 @@ pkg_check_modules(UUID REQUIRED uuid)
|
|||
|
||||
set(EXEC_NAME "jay")
|
||||
|
||||
add_executable(${EXEC_NAME} main.cpp jay.cpp)
|
||||
|
||||
add_subdirectory(component)
|
||||
add_subdirectory(connection)
|
||||
add_subdirectory(module)
|
||||
add_subdirectory(shared)
|
||||
|
||||
target_include_directories(${EXEC_NAME} PRIVATE ${GLOOX_INCLUDE_DIRS})
|
||||
target_include_directories(${EXEC_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(${EXEC_NAME} PRIVATE ${UUID_INCLUDE_DIRS})
|
||||
target_link_libraries(${EXEC_NAME} PRIVATE
|
||||
${GLOOX_LIBRARIES}
|
||||
yaml-cpp
|
||||
${UUID_LIBRARIES}
|
||||
)
|
||||
|
||||
install(TARGETS ${EXEC_NAME} RUNTIME DESTINATION bin)
|
||||
add_subdirectory(src)
|
Loading…
Add table
Add a link
Reference in a new issue