From 3cbef821c0ec472a446ac701df8408b3776c16ea Mon Sep 17 00:00:00 2001 From: Sergey Bronnikov Date: Wed, 17 May 2023 19:44:04 +0300 Subject: [PATCH] [cmake] Enable static building OSS Fuzz strongly recommends static linking for tests [1]. Patch enables static linking for a fuzzing test added in commit 2ad14696124b5a7689a323f56859efb329a3d25c ("Add fuzzer for certificate_data_set_pem()"). 1. https://google.github.io/oss-fuzz/further-reading/fuzzer-environment/#runtime-dependencies --- cmake/ConfigOptions.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/ConfigOptions.cmake b/cmake/ConfigOptions.cmake index 7bf8e2c00..e36d67415 100644 --- a/cmake/ConfigOptions.cmake +++ b/cmake/ConfigOptions.cmake @@ -199,6 +199,11 @@ if (BUILD_FUZZERS) set(BUILD_TESTING ON) + if (BUILD_SHARED_LIBS STREQUAL "OFF") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}") + endif() + # A special target with fuzzer and sanitizer flags. add_library(fuzzer_config INTERFACE)