Skip to content

Commit 3fbdbd2

Browse files
enable WITH_BENCHMARK and BUILD_DIR in the makefile (#1590)
Signed-off-by: Alexandr Guzhva <alexanderguzhva@gmail.com>
1 parent 9c76a70 commit 3fbdbd2

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
# or implied. See the License for the specific language governing permissions and limitations under the License.
1111

1212
PWD := $(shell pwd)
13-
BUILD_DIR := $(PWD)/build
13+
# BUILD_DIR is where conan + cmake put build outputs. Overridable from the
14+
# command line, e.g. `make BUILD_DIR=$(pwd)/build_asan WITH_ASAN=True`.
15+
# Binaries end up at $(BUILD_DIR)/$(BUILD_TYPE)/... (e.g. build/Release/...).
16+
BUILD_DIR ?= $(PWD)/build
1417
SHELL := /bin/bash
1518

1619
# Conan install-only flags (not valid for conan build)
@@ -20,6 +23,7 @@ CONAN_INSTALL_FLAGS := --update --build=missing
2023
# Usage: make WITH_GPU=True WITH_UT=True WITH_ASAN=True WITH_DEBUG=True
2124
WITH_GPU ?=
2225
WITH_UT ?=
26+
WITH_BENCHMARK ?=
2327
WITH_ASAN ?=
2428
WITH_SVS ?=
2529
WITH_CARDINAL ?=
@@ -31,7 +35,7 @@ CONAN_PROFILE ?=
3135
# variables such as WITH_ASAN to every sub-process, which causes the custom
3236
# folly recipe to pick up $ENV{WITH_ASAN} and compile folly itself with
3337
# -fsanitize=address — breaking the build on GCC.
34-
unexport WITH_GPU WITH_UT WITH_ASAN WITH_CARDINAL WITH_DEBUG
38+
unexport WITH_GPU WITH_UT WITH_BENCHMARK WITH_ASAN WITH_CARDINAL WITH_DEBUG
3539

3640
# ---------- Derived settings ----------
3741
ifdef WITH_DEBUG
@@ -72,6 +76,10 @@ ifdef WITH_UT
7276
CONAN_SETTINGS += -o with_ut=True
7377
endif
7478

79+
ifdef WITH_BENCHMARK
80+
CONAN_SETTINGS += -o with_benchmark=True
81+
endif
82+
7583
ifdef WITH_ASAN
7684
CONAN_SETTINGS += -o with_asan=True
7785
endif
@@ -97,13 +105,13 @@ all: build ## Default: CPU release build
97105

98106
# ---------- Build ----------
99107

100-
build: ## Build knowhere (use WITH_GPU=True, WITH_UT=True, WITH_ASAN=True)
108+
build: ## Build knowhere (use WITH_GPU=True, WITH_UT=True, WITH_BENCHMARK=True, WITH_ASAN=True)
101109
ifdef WITH_GPU
102110
@$(PWD)/scripts/prepare_gpu_build.sh
103111
endif
104112
@mkdir -p $(BUILD_DIR) && \
105-
conan install . $(CONAN_INSTALL_FLAGS) $(CONAN_SETTINGS) && \
106-
conan build . $(CONAN_SETTINGS)
113+
conan install . -of $(BUILD_DIR) $(CONAN_INSTALL_FLAGS) $(CONAN_SETTINGS) && \
114+
conan build . -of $(BUILD_DIR) $(CONAN_SETTINGS)
107115

108116
# ---------- Test ----------
109117

@@ -148,6 +156,7 @@ help: ## Show available targets
148156
@echo "Build flags:"
149157
@echo " WITH_GPU=True Enable GPU (cuVS) build"
150158
@echo " WITH_UT=True Enable unit tests"
159+
@echo " WITH_BENCHMARK=True Enable benchmarks build"
151160
@echo " WITH_ASAN=True Enable AddressSanitizer"
152161
@echo " WITH_SVS=True Enable SVS (Intel Scalable Vector Search, x86 only)"
153162
@echo " WITH_CARDINAL=True Enable Cardinal build"

conanfile.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@ def validate(self):
163163
)
164164

165165
def layout(self):
166-
cmake_layout(self)
166+
# build_folder="" places the cmake build dir directly at
167+
# <output_folder>/<build_type> instead of cmake_layout's default
168+
# <output_folder>/build/<build_type>. The Makefile always passes
169+
# -of <BUILD_DIR>, so final paths are $(BUILD_DIR)/Release/…
170+
# which matches the historical build/Release/ layout exactly.
171+
cmake_layout(self, build_folder="")
167172

168173
def generate(self):
169174
tc = CMakeToolchain(self)

0 commit comments

Comments
 (0)