Insane_DNS/CMakeLists.txt

55 lines
1.9 KiB
CMake

cmake_minimum_required(VERSION 3.0)
project(insane_dns)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
set(CMAKE_CXX_STANDARD 20)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
option(BUILD_PARSE OFF)
option(BUILD_PROFILING OFF)
option(BUILD_NBT OFF)
add_subdirectory(libraries/BLT)
include_directories(include/)
include_directories(libraries/asio-1.28.1/include)
file(GLOB_RECURSE PROJECT_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
#file(GLOB_RECURSE ASIO_BUILD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/libraries/asio-1.28.1/src/*.cpp")
#add_compile_definitions(ASIO_SEPARATE_COMPILATION)
add_executable(insane_dns ${PROJECT_BUILD_FILES})
target_link_libraries(insane_dns BLT)
target_link_libraries(insane_dns stdc++fs)
if(THREADS_HAVE_PTHREAD_ARG)
# annoying hack for asio on sandcastle
set_property(TARGET insane_dns PROPERTY COMPILE_OPTIONS "-pthread")
set_property(TARGET insane_dns PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread")
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(insane_dns "${CMAKE_THREAD_LIBS_INIT}")
endif()
#target_compile_options(insane_dns PRIVATE -Wall -Werror -Wpedantic -Werror=return-local-addr -Wno-comment -Wno-format)
#target_link_options(insane_dns PRIVATE -Wall -Werror -Wpedantic -Werror=return-local-addr -Wno-comment -Wno-format)
if (${ENABLE_ADDRSAN} MATCHES ON)
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
endif ()
if (${ENABLE_TSAN} MATCHES ON)
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
endif ()