Skip to content

Commit 4b78e4b

Browse files
committed
paozhu update
1 parent 57dfce0 commit 4b78e4b

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

frameworks/C++/paozhu/paozhu_benchmark/CMakeLists.txt

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ set(ENABLE_BOOST OFF CACHE BOOL "choose ON to enable")
77
set(ENABLE_GD OFF CACHE BOOL "choose ON to enable")
88
set(ENABLE_WIN_VCPKG OFF CACHE BOOL "choose ON to enable")
99

10-
if (ENABLE_GD STREQUAL "ON")
11-
list(FIND VCPKG_MANIFEST_FEATURES "gd" index)
12-
if (index EQUAL -1)
13-
message(STATUS "Auto append features: gd")
14-
list(APPEND VCPKG_MANIFEST_FEATURES "gd")
15-
endif ()
16-
endif ()
10+
if(ENABLE_VCPKG)
11+
set(vcpkg_root $ENV{VCPKG_ROOT})
12+
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND vcpkg_root)
13+
set(CMAKE_TOOLCHAIN_FILE "${vcpkg_root}/scripts/buildsystems/vcpkg.cmake")
14+
endif()
15+
endif()
1716

18-
if (ENABLE_BOOST STREQUAL "ON")
19-
list(FIND VCPKG_MANIFEST_FEATURES "boost" index)
20-
if (index EQUAL -1)
21-
message(STATUS "Auto append features: boost")
22-
list(APPEND VCPKG_MANIFEST_FEATURES "boost")
23-
endif ()
24-
endif ()
17+
macro(auto_enable_vcpkg_feature opt feature)
18+
if(${opt})
19+
list(FIND VCPKG_MANIFEST_FEATURES ${feature} index)
20+
if(index EQUAL -1)
21+
message(STATUS "Auto append features: ${feature}")
22+
list(APPEND VCPKG_MANIFEST_FEATURES ${feature})
23+
endif()
24+
endif()
25+
endmacro()
26+
27+
if(ENABLE_VCPKG)
28+
auto_enable_vcpkg_feature(ENABLE_GD "gd")
29+
auto_enable_vcpkg_feature(ENABLE_BOOST "boost")
30+
endif()
2531

2632
PROJECT(Paozhu_web_framework)
2733
set(CMAKE_CXX_STANDARD 20)
@@ -602,4 +608,4 @@ endif ()
602608
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
603609
target_link_libraries(paozhu ws2_32)
604610
target_link_libraries(paozhu_cli ws2_32)
605-
endif ()
611+
endif ()

0 commit comments

Comments
 (0)