@@ -3,8 +3,10 @@ project(trantor)
33
44option (BUILD_DOC "Build Doxygen documentation" OFF )
55option (BUILD_C-ARES "Build C-ARES" ON )
6+ option (BUILD_TESTING "Build tests" OFF )
67option (BUILD_SHARED_LIBS "Build trantor as a shared lib" OFF )
78option (TRANTOR_USE_TLS "TLS provider for trantor. Valid options are 'openssl', 'botan' or '' (let the build scripr decide)" "" )
9+ option (USE_SPDLOG "Allow using the spdlog logging library" OFF )
810
911list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake_modules/)
1012
@@ -45,6 +47,13 @@ if(BUILD_SHARED_LIBS)
4547 endif ()
4648endif (BUILD_SHARED_LIBS )
4749
50+ # Tells Visual Studio 2017 (15.7+) and newer to correctly set the value of the standard __cplusplus macro,
51+ # instead of leaving it to 199711L and settings the effective c++ version in _MSVC_LANG
52+ # Dropping support for older versions of VS would allow to only rely on __cplusplus
53+ if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
54+ add_compile_options (/Zc:__cplusplus)
55+ endif (MSVC )
56+
4857if (NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" AND CMAKE_CXX_COMPILER_ID MATCHES Clang|GNU)
4958 target_compile_options (${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
5059endif ()
@@ -188,6 +197,19 @@ endif()
188197message (STATUS "Trantor using SSL library: ${TRANTOR_TLS_PROVIDER} " )
189198target_compile_definitions (${PROJECT_NAME} PRIVATE TRANTOR_TLS_PROVIDER=${TRANTOR_TLS_PROVIDER} )
190199
200+ set (HAVE_SPDLOG NO )
201+ if (USE_SPDLOG)
202+ find_package (spdlog CONFIG)
203+ if (spdlog_FOUND)
204+ message (STATUS "spdlog found!" )
205+ set (HAVE_SPDLOG TRUE )
206+ endif (spdlog_FOUND)
207+ endif (USE_SPDLOG)
208+ if (HAVE_SPDLOG)
209+ target_link_libraries (${PROJECT_NAME} PUBLIC spdlog::spdlog_header_only)
210+ target_compile_definitions (${PROJECT_NAME} PUBLIC TRANTOR_SPDLOG_SUPPORT SPDLOG_FMT_EXTERNAL FMT_HEADER_ONLY)
211+ endif (HAVE_SPDLOG)
212+
191213set (HAVE_C-ARES NO )
192214if (BUILD_C-ARES)
193215 find_package (c-ares)
@@ -206,7 +228,9 @@ if(HAVE_C-ARES)
206228 ${private_headers}
207229 trantor/net/inner/AresResolver.h)
208230 if (APPLE )
209- target_link_libraries (${PROJECT_NAME} PRIVATE resolv)
231+ target_link_libraries (${PROJECT_NAME} PRIVATE resolv)
232+ elseif (WIN32 )
233+ target_link_libraries (${PROJECT_NAME} PRIVATE Iphlpapi)
210234 endif ()
211235else ()
212236 set (TRANTOR_SOURCES
0 commit comments