2021-11-16 07:59:13 +00:00
|
|
|
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
|
|
|
set(PROJECT_CONTACT romange@gmail.com)
|
|
|
|
|
2023-05-22 02:21:01 +00:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
2021-11-16 07:59:13 +00:00
|
|
|
enable_testing()
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
|
|
|
|
|
|
|
# Set targets in folders
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
project(DRAGONFLY C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
2023-05-22 02:21:01 +00:00
|
|
|
# Disabled because it has false positives with ref-counted intrusive pointers.
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-Wuse-after-free" HAS_USE_AFTER_FREE_WARN)
|
|
|
|
if (HAS_USE_AFTER_FREE_WARN)
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wno-use-after-free ${CMAKE_CXX_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
2024-08-26 15:22:38 +00:00
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wthread-safety ${CMAKE_CXX_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
2024-02-05 08:29:11 +00:00
|
|
|
# We can not use here CHECK_CXX_COMPILER_FLAG because systems that do not support sanitizers
|
|
|
|
# fail during linking time.
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
|
|
|
|
check_cxx_source_compiles("int main() { return 0; }" SUPPORT_ASAN)
|
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-fsanitize=undefined")
|
|
|
|
check_cxx_source_compiles("int main() { return 0; }" SUPPORT_USAN)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "")
|
|
|
|
|
2021-11-16 07:59:13 +00:00
|
|
|
# We must define all the required variables from the root cmakefile, otherwise
|
|
|
|
# they just disappear.
|
2021-11-18 15:14:05 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/helio/cmake" ${CMAKE_MODULE_PATH})
|
2021-11-16 07:59:13 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
2022-06-15 16:19:59 +00:00
|
|
|
option(DF_USE_SSL "Provide support for SSL connections" ON)
|
2021-11-16 07:59:13 +00:00
|
|
|
|
2023-04-07 05:38:12 +00:00
|
|
|
find_package(OpenSSL)
|
|
|
|
|
2024-03-04 09:00:46 +00:00
|
|
|
option(WITH_ASAN "Enable -fsanitize=address" OFF)
|
|
|
|
if (SUPPORT_ASAN AND WITH_ASAN)
|
|
|
|
message(STATUS "address sanitizer enabled")
|
2024-02-06 09:57:26 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
|
2024-02-05 08:29:11 +00:00
|
|
|
endif()
|
|
|
|
|
2024-03-04 09:00:46 +00:00
|
|
|
option(WITH_USAN "Enable -fsanitize=undefined" OFF)
|
|
|
|
if (SUPPORT_USAN AND WITH_USAN)
|
|
|
|
message(STATUS "ub sanitizer enabled")
|
2024-02-06 09:57:26 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
|
2024-02-05 08:29:11 +00:00
|
|
|
endif()
|
|
|
|
|
2021-11-16 07:59:13 +00:00
|
|
|
include(third_party)
|
2022-05-30 05:49:16 +00:00
|
|
|
include(internal)
|
2021-11-16 07:59:13 +00:00
|
|
|
|
2022-02-25 08:03:42 +00:00
|
|
|
include_directories(src)
|
2021-11-18 15:14:05 +00:00
|
|
|
include_directories(helio)
|
2021-11-16 07:59:13 +00:00
|
|
|
|
2021-11-18 15:14:05 +00:00
|
|
|
add_subdirectory(helio)
|
2022-02-25 08:03:42 +00:00
|
|
|
add_subdirectory(src)
|