Browse Source

paozhu update

hzq 7 months ago
parent
commit
4b78e4b3be
1 changed files with 21 additions and 15 deletions
  1. 21 15
      frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt

+ 21 - 15
frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt

@@ -7,21 +7,27 @@ set(ENABLE_BOOST OFF CACHE BOOL "choose ON to enable")
 set(ENABLE_GD OFF CACHE BOOL "choose ON to enable")
 set(ENABLE_WIN_VCPKG OFF CACHE BOOL "choose ON to enable")
 
-if (ENABLE_GD STREQUAL "ON")
-    list(FIND VCPKG_MANIFEST_FEATURES "gd" index)
-    if (index EQUAL -1)
-        message(STATUS "Auto append features: gd")
-        list(APPEND VCPKG_MANIFEST_FEATURES "gd")
-    endif ()
-endif ()
+if(ENABLE_VCPKG)
+    set(vcpkg_root $ENV{VCPKG_ROOT})
+    if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND vcpkg_root)
+        set(CMAKE_TOOLCHAIN_FILE "${vcpkg_root}/scripts/buildsystems/vcpkg.cmake")
+    endif()
+endif()
 
-if (ENABLE_BOOST STREQUAL "ON")
-    list(FIND VCPKG_MANIFEST_FEATURES "boost" index)
-    if (index EQUAL -1)
-        message(STATUS "Auto append features: boost")
-        list(APPEND VCPKG_MANIFEST_FEATURES "boost")
-    endif ()
-endif ()
+macro(auto_enable_vcpkg_feature opt feature)
+    if(${opt})
+        list(FIND VCPKG_MANIFEST_FEATURES ${feature} index)
+        if(index EQUAL -1)
+            message(STATUS "Auto append features: ${feature}")
+            list(APPEND VCPKG_MANIFEST_FEATURES ${feature})
+        endif()
+    endif()
+endmacro()
+
+if(ENABLE_VCPKG)
+  auto_enable_vcpkg_feature(ENABLE_GD "gd")
+  auto_enable_vcpkg_feature(ENABLE_BOOST "boost")
+endif()
 
 PROJECT(Paozhu_web_framework)
 set(CMAKE_CXX_STANDARD 20)
@@ -602,4 +608,4 @@ endif ()
 if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    target_link_libraries(paozhu ws2_32)
    target_link_libraries(paozhu_cli ws2_32)
-endif ()
+endif ()