Makefile: allow to set CMAKE_ARGS via CLI

This commit is contained in:
Beat Küng 2022-05-24 09:37:03 +02:00 committed by Daniel Agar
parent 4e940fab83
commit a9c1415337
1 changed files with 13 additions and 11 deletions

View File

@ -129,57 +129,59 @@ else
BUILD_DIR_SUFFIX := BUILD_DIR_SUFFIX :=
endif endif
CMAKE_ARGS ?=
# additional config parameters passed to cmake # additional config parameters passed to cmake
ifdef EXTERNAL_MODULES_LOCATION ifdef EXTERNAL_MODULES_LOCATION
CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION) override CMAKE_ARGS += -DEXTERNAL_MODULES_LOCATION:STRING=$(EXTERNAL_MODULES_LOCATION)
endif endif
ifdef PX4_CMAKE_BUILD_TYPE ifdef PX4_CMAKE_BUILD_TYPE
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${PX4_CMAKE_BUILD_TYPE} override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=${PX4_CMAKE_BUILD_TYPE}
else else
# Address Sanitizer # Address Sanitizer
ifdef PX4_ASAN ifdef PX4_ASAN
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=AddressSanitizer override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=AddressSanitizer
endif endif
# Memory Sanitizer # Memory Sanitizer
ifdef PX4_MSAN ifdef PX4_MSAN
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=MemorySanitizer override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=MemorySanitizer
endif endif
# Thread Sanitizer # Thread Sanitizer
ifdef PX4_TSAN ifdef PX4_TSAN
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=ThreadSanitizer override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=ThreadSanitizer
endif endif
# Undefined Behavior Sanitizer # Undefined Behavior Sanitizer
ifdef PX4_UBSAN ifdef PX4_UBSAN
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=UndefinedBehaviorSanitizer override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=UndefinedBehaviorSanitizer
endif endif
# Fuzz Testing # Fuzz Testing
ifdef PX4_FUZZ ifdef PX4_FUZZ
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=FuzzTesting override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=FuzzTesting
endif endif
endif endif
# Pick up specific Python path if set # Pick up specific Python path if set
ifdef PYTHON_EXECUTABLE ifdef PYTHON_EXECUTABLE
CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} override CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
endif endif
# Check if the microRTPS agent is to be built # Check if the microRTPS agent is to be built
ifdef BUILD_MICRORTPS_AGENT ifdef BUILD_MICRORTPS_AGENT
CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON override CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON
endif endif
# Functions # Functions
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# describe how to build a cmake config # describe how to build a cmake config
define cmake-build define cmake-build
$(eval CMAKE_ARGS += -DCONFIG=$(1)) $(eval override CMAKE_ARGS += -DCONFIG=$(1))
@$(eval BUILD_DIR = "$(SRC_DIR)/build/$(1)") @$(eval BUILD_DIR = "$(SRC_DIR)/build/$(1)")
@# check if the desired cmake configuration matches the cache then CMAKE_CACHE_CHECK stays empty @# check if the desired cmake configuration matches the cache then CMAKE_CACHE_CHECK stays empty
@$(call cmake-cache-check) @$(call cmake-cache-check)
@ -383,7 +385,7 @@ format:
.PHONY: rostest python_coverage .PHONY: rostest python_coverage
tests: tests:
$(eval CMAKE_ARGS += -DTESTFILTER=$(TESTFILTER)) $(eval override CMAKE_ARGS += -DTESTFILTER=$(TESTFILTER))
$(eval ARGS += test_results) $(eval ARGS += test_results)
$(eval ASAN_OPTIONS += color=always:check_initialization_order=1:detect_stack_use_after_return=1) $(eval ASAN_OPTIONS += color=always:check_initialization_order=1:detect_stack_use_after_return=1)
$(eval UBSAN_OPTIONS += color=always) $(eval UBSAN_OPTIONS += color=always)