1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:37:42 +00:00

Meta: Add BUILD_SHARED_LIBS option for Lagom builds

This standard CMake option controls whether add_library() calls will
use STATIC or SHARED by default. The flag is set to on by default
since that's what we want for normal CI jobs and local builds and the
test262 runner, but disabled for oss-fuzz builds.

This should finally fix the oss-fuzz build after it was broken in #9017

oss-fuzz un-breakage was verified by running the following commands in
the oss-fuzz repo:

python infra/helper.py build_image serenity
python infra/helper.py build_fuzzers --sanitizer address --engine afl \
    --architecture x86_64 serenity /path/to/local/checkout/Meta/Lagom
python infra/helper.py check_build --sanitizer address --engine afl \
    --architecture x86_64 serenity
This commit is contained in:
Andrew Kaster 2021-08-01 04:37:28 -06:00 committed by Gunnar Beutner
parent 845d403b8c
commit 40b0767d88

View file

@ -8,6 +8,11 @@ project(
LANGUAGES C CXX
)
option(BUILD_SHARED_LIBS "Build shared libraries instead of static libraries" ON)
if (ENABLE_OSS_FUZZ)
set(BUILD_SHARED_LIBS OFF) # Don't use shared libraries on oss-fuzz, for ease of integration with their infrastructure
endif()
# This is required for CMake (when invoked for a Lagom-only build) to
# ignore any files downloading during the build, e.g. UnicodeData.txt.
# https://cmake.org/cmake/help/latest/policy/CMP0058.html
@ -142,10 +147,8 @@ endif()
function(lagom_lib library fs_name)
cmake_parse_arguments(LAGOM_LIBRARY "" "" "SOURCES;LIBS" ${ARGN})
# FIXME: Consider whether to care about -DBUILD_SHARED_LIBS=OFF
# Possibly a cmake presets value?
set(target_name "Lagom${library}")
add_library(${target_name} SHARED ${LAGOM_LIBRARY_SOURCES})
add_library(${target_name} ${LAGOM_LIBRARY_SOURCES})
# alias for pretty exports
add_library(Lagom::${library} ALIAS ${target_name})
@ -422,7 +425,6 @@ if (BUILD_LAGOM)
list(FILTER LIBTEST_SOURCES EXCLUDE REGEX ".*Main.cpp$")
add_library(
LagomTest
SHARED
${LIBTEST_SOURCES}
)
target_link_libraries(LagomTest LagomCore)