From 57ec87d38daa79b7f464a93468e116aecdcb104c Mon Sep 17 00:00:00 2001 From: An Tao Date: Thu, 9 Mar 2023 00:16:21 +0800 Subject: [PATCH] Add an option in CMakeLists.txt to set how to use trantor (#1520) --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb8a266e..5bcb5363 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(COZ_PROFILING "Use coz for profiling" OFF) option(BUILD_SHARED_LIBS "Build drogon as a shared lib" OFF) option(BUILD_DOC "Build Doxygen documentation" OFF) option(BUILD_BROTLI "Build Brotli" ON) +option(USE_SUBMODULE "Use trantor as a submodule" ON) include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(BUILD_POSTGRESQL "Build with postgresql support" ON "BUILD_ORM" OFF) @@ -99,14 +100,18 @@ elseif (HAS_ANY AND HAS_STRING_VIEW) else () set(DROGON_CXX_STANDARD 14) endif () - +if(USE_SUBMODULE) + target_include_directories( + ${PROJECT_NAME} + PUBLIC + $) +endif() target_include_directories( ${PROJECT_NAME} PUBLIC $ $ $ $ - $ $ $) @@ -116,9 +121,13 @@ if (WIN32) PRIVATE $) endif (WIN32) +if(USE_SUBMODULE) add_subdirectory(trantor) - target_link_libraries(${PROJECT_NAME} PUBLIC trantor) +else() +find_package(Trantor CONFIG REQUIRED) +target_link_libraries(${PROJECT_NAME} PUBLIC Trantor::Trantor) +endif() if(${CMAKE_SYSTEM_NAME} STREQUAL "Haiku") target_link_libraries(${PROJECT_NAME} PRIVATE network)