2019-06-30 14:14:43 +02:00
|
|
|
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
2017-08-04 23:50:35 +02:00
|
|
|
|
2018-07-31 11:33:35 +02:00
|
|
|
# Layout of project is inspired by: https://youtu.be/6sWec7b0JIc?t=20m50s
|
|
|
|
# This top level CMakeLists should be used for development
|
2017-09-01 16:15:31 +02:00
|
|
|
|
2019-12-29 15:00:20 +01:00
|
|
|
project(EventBusDev LANGUAGES CXX)
|
2017-08-04 23:50:35 +02:00
|
|
|
|
2019-03-30 15:28:17 +01:00
|
|
|
option(ENABLE_TEST "Enable test" ON)
|
|
|
|
option(ENABLE_PERFORMANCE "Enable performance subproject" OFF)
|
2020-01-02 12:48:14 +01:00
|
|
|
option(ENABLE_LIBCXX "Enable build with libc++" OFF)
|
2019-03-30 15:28:17 +01:00
|
|
|
|
2019-06-30 14:14:43 +02:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-12-29 15:00:20 +01:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
2018-09-08 19:31:05 +02:00
|
|
|
|
2019-12-29 15:02:03 +01:00
|
|
|
if(ENABLE_LIBCXX)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
2020-01-02 12:48:14 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
2019-12-29 15:02:03 +01:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++abi")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "C++ compiler should be set to clang")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Build Types
|
|
|
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE}
|
|
|
|
CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel tsan asan lsan msan ubsan"
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
# ThreadSanitizer
|
|
|
|
set(CMAKE_C_FLAGS_TSAN
|
|
|
|
"-fsanitize=thread -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C compiler during ThreadSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_TSAN
|
|
|
|
"-fsanitize=thread -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C++ compiler during ThreadSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
# AddressSanitize
|
|
|
|
set(CMAKE_C_FLAGS_ASAN
|
|
|
|
"-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C compiler during AddressSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_ASAN
|
|
|
|
"-fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C++ compiler during AddressSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
# LeakSanitizer
|
|
|
|
set(CMAKE_C_FLAGS_LSAN
|
|
|
|
"-fsanitize=leak -fno-omit-frame-pointer -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C compiler during LeakSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_LSAN
|
|
|
|
"-fsanitize=leak -fno-omit-frame-pointer -g -O1"
|
|
|
|
CACHE STRING "Flags used by the C++ compiler during LeakSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
# Remember to switch lib: https://stackoverflow.com/questions/20617788/using-memory-sanitizer-with-libstdc/20784130#20784130
|
|
|
|
# use ENABLE_LIBCXX
|
|
|
|
# MemorySanitizer
|
|
|
|
set(CMAKE_C_FLAGS_MSAN
|
|
|
|
"-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O2"
|
|
|
|
CACHE STRING "Flags used by the C compiler during MemorySanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_MSAN
|
|
|
|
"-fsanitize=memory -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer -g -O2"
|
|
|
|
CACHE STRING "Flags used by the C++ compiler during MemorySanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
# UndefinedBehaviour
|
|
|
|
set(CMAKE_C_FLAGS_UBSAN
|
|
|
|
"-fsanitize=undefined"
|
|
|
|
CACHE STRING "Flags used by the C compiler during UndefinedBehaviourSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
set(CMAKE_CXX_FLAGS_UBSAN
|
|
|
|
"-fsanitize=undefined"
|
|
|
|
CACHE STRING "Flags used by the C++ compiler during UndefinedBehaviourSanitizer builds."
|
|
|
|
FORCE)
|
|
|
|
|
2018-07-31 11:33:35 +02:00
|
|
|
add_subdirectory(lib/)
|
2019-12-27 11:21:43 +01:00
|
|
|
add_subdirectory(use_case/)
|
2017-08-04 23:50:35 +02:00
|
|
|
|
2019-03-30 15:28:17 +01:00
|
|
|
if(ENABLE_TEST)
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(test/)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ENABLE_PERFORMANCE)
|
|
|
|
add_subdirectory(performance/)
|
|
|
|
endif()
|
2017-08-04 23:50:35 +02:00
|
|
|
|
2021-05-06 12:11:21 -04:00
|
|
|
target_compile_options(EventBus PRIVATE
|
2019-03-30 15:28:17 +01:00
|
|
|
-Wall -pedantic
|
|
|
|
-Wnon-virtual-dtor
|
|
|
|
-Werror
|
|
|
|
-Wno-error=deprecated-declarations
|
|
|
|
)
|