gemini-server/CMakeLists.txt

80 lines
2.3 KiB
CMake

cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
project(GeminiServer CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
# options for spdlog
set(SPDLOG_ENABLE_PCH ON CACHE BOOL "Build static or shared library using precompiled header to speed up compilation time")
set(SPDLOG_BUILD_WARNINGS ON CACHE BOOL "Enable compiler warnings")
set(SPDLOG_FMT_EXTERNAL ON CACHE BOOL "Use external fmt library instead of bundled")
set(SPDLOG_PREVENT_CHILD_FD ON CACHE BOOL "Prevent from child processes to inherit log file descriptors")
set(SPDLOG_NO_THREAD_ID ON CACHE BOOL "prevent spdlog from querying the thread id on each log call if thread id is not needed")
set(SPDLOG_NO_TLS ON CACHE BOOL "prevent spdlog from using thread local storage")
add_subdirectory(external/spdlog)
# end
find_package(Boost REQUIRED COMPONENTS system)
find_package(OpenSSL REQUIRED)
find_package(OpenMP REQUIRED)
include_directories(${Boost_INCLUDE_DIR} ${OpenSSL_INCLUDE_DIR})
set(COMPILE_DEFINITIONS
$<$<CONFIG:DEBUG>:_LIBCPP_DEBUG>
BOOST_ASIO_NO_DEPRECATED
BOOST_ASIO_NO_TS_EXECUTORS
#[[_FORTIFY_SOURCE=2]]
)
set(COMPILE_FLAGS
-pipe
-march=skylake # change to native or your architecture.
-mtune=skylake # same as above
-mrdseed # be careful about this, this is linked to the x86 architecture.
-mrdrnd # same as above
-stdlib=libc++
-Wpedantic
-Wall
-Wextra
-Wmove
-Wopenmp
-funroll-loops
-flto=thin -fwhole-program-vtables
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
)
set(LINKER_OPTIONS
PRIVATE -Wl,--sort-common,--as-needed
-stdlib=libc++
-flto=thin
-fwhole-program-vtables
-fuse-ld=gold
)
set(LINKER_FLAGS
jemalloc
${Boost_LIBRARIES}
OpenSSL::SSL
OpenMP::OpenMP_CXX
)
file(GLOB HEADERS includes/*.hpp)
set(FILES
main.cpp
src/network.cpp
include/information.hpp
src/cache_files.cpp
include/cache_files.hpp
src/simdjson.cpp
include/simdjson.h
)
add_executable(GeminiServer ${FILES})
target_precompile_headers(GeminiServer PRIVATE ${HEADERS})
target_compile_definitions(GeminiServer PRIVATE ${COMPILE_DEFINITIONS})
target_compile_options(GeminiServer PRIVATE ${COMPILE_FLAGS})
target_link_options(GeminiServer ${LINKER_OPTIONS})
target_link_libraries(GeminiServer ${LINKER_FLAGS} spdlog::spdlog)