Skip to content

Commit 1b2de5a

Browse files
committed
Add support to turn 3rd party dependencies off
- By default, all the 3rd party dependencies are enabled. - A dependency can be turned off by adding the "-DWITHOUT_xxx=ON" to the call of vcbuild.bat - List of 3rd party dependencies and associated option to turn them off: - LMDB: WITHOUT_LMDB - LUA: WITHOUT_LUA - LibXML2: WITHOUT_LIBXML2 - MaxMind: WITHOUT_MAXMIND - cURL: WITHOUT_CURL
1 parent 6bf78f2 commit 1b2de5a

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

.github/workflows/ci.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ jobs:
8080
os: [windows-2022]
8181
platform: [x86_64]
8282
configuration: [Release]
83+
configure:
84+
- {label: "full", opt: "" }
85+
- {label: "wo lmdb", opt: "-DWITHOUT_LMDB=ON" }
86+
- {label: "wo lua", opt: "-DWITHOUT_LUA=ON" }
87+
- {label: "wo maxmind", opt: "-DWITHOUT_MAXMIND=ON" }
88+
- {label: "wo curl", opt: "-DWITHOUT_CURL=ON" }
8389
steps:
8490
- uses: actions/checkout@v4
8591
with:
@@ -89,9 +95,9 @@ jobs:
8995
pip3 install conan --upgrade
9096
conan profile detect
9197
- uses: ammaraskar/msvc-problem-matcher@master
92-
- name: Build ${{ matrix.configuration }} ${{ matrix.platform }}
98+
- name: Build ${{ matrix.configuration }} ${{ matrix.platform }} ${{ matrix.configure.label }}
9399
shell: cmd
94-
run: vcbuild.bat ${{ matrix.configuration }} ${{ matrix.platform }}
100+
run: vcbuild.bat ${{ matrix.configuration }} ${{ matrix.platform }} NO_ASAN "${{ matrix.configure.opt }}"
95101
- name: Set up test environment
96102
working-directory: build\win32\build\${{ matrix.configuration }}
97103
env:

build/win32/CMakeLists.txt

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
cmake_minimum_required(VERSION 3.15)
1+
cmake_minimum_required(VERSION 3.24)
22

33
set(BASE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
44

5-
set(USE_ASAN OFF CACHE BOOL "Build with Address Sanitizer")
5+
option(WITHOUT_LMDB "Include LMDB support" OFF)
6+
option(WITHOUT_LUA "Include LUA support" OFF)
7+
option(WITHOUT_LIBXML2 "Include LibXML2 support" OFF)
8+
option(WITHOUT_MAXMIND "Include MaxMind support" OFF)
9+
option(WITHOUT_CURL "Include CURL support" OFF)
10+
11+
option(USE_ASAN "Build with Address Sanitizer" OFF)
612

713
# common compiler settings
814

@@ -55,14 +61,23 @@ set(PACKAGE_VERSION "${PROJECT_VERSION}")
5561
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
5662
set(PACKAGE_TARNAME "${PACKAGE_NAME}")
5763

64+
set(HAVE_YAJL 1) # should always be one, mandatory dependency
5865
set(HAVE_GEOIP 0) # should always be zero, no conan package available
59-
set(HAVE_LMDB 1)
60-
set(HAVE_LUA 1)
61-
set(HAVE_LIBXML2 1)
62-
set(HAVE_MAXMIND 1)
6366
set(HAVE_SSDEEP 0) # should always be zero, no conan package available
64-
set(HAVE_YAJL 1) # should always be one, mandatory dependency
65-
set(HAVE_CURL 1)
67+
68+
macro(enable_feature flag option)
69+
if(${option})
70+
set(${flag} 0)
71+
else()
72+
set(${flag} 1)
73+
endif()
74+
endmacro()
75+
76+
enable_feature(HAVE_LMDB ${WITHOUT_LMDB})
77+
enable_feature(HAVE_LUA ${WITHOUT_LUA})
78+
enable_feature(HAVE_LIBXML2 ${WITHOUT_LIBXML2})
79+
enable_feature(HAVE_MAXMIND ${WITHOUT_MAXMIND})
80+
enable_feature(HAVE_CURL ${WITHOUT_CURL})
6681

6782
include(${CMAKE_CURRENT_LIST_DIR}/ConfigureChecks.cmake)
6883

vcbuild.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if "%3"=="USE_ASAN" (
2222
cd build\win32
2323
conan install . -s compiler.cppstd=17 %CI_ASAN% --output-folder=build --build=missing --settings=build_type=%build_type% --settings=arch=%arch%
2424
cd build
25-
cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DUSE_ASAN=%ASAN_FLAG%
25+
cmake --fresh .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DUSE_ASAN=%ASAN_FLAG% %4 %5 %6 %7 %8 %9
2626
cmake --build . --config %build_type%
2727

2828
popd

0 commit comments

Comments
 (0)