Skip to content

Add a check before using -fno-define-target-os-macros #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions MultiSource/Applications/ClamAV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,15 @@ if(TARGET_OS STREQUAL "Linux")
find_package(Intl REQUIRED)
target_link_libraries(clamscan ${Intl_LIBRARIES})
endif()
# zlib fails to build with correctly defined target OS macros.
# (https://github.com/madler/zlib/pull/895)
# Disable the compiler extension to workaround the build failure until a zlib
# source update with the fix.
target_compile_options(clamscan PRIVATE -fno-define-target-os-macros)

include(CheckCCompilerFlag)
check_c_compiler_flag(-fno-define-target-os-macros
COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
if (COMPILER_HAS_NO_DEFINE_TARGET_OS_MACROS)
# zlib fails to build with correctly defined target OS macros.
# (https://github.com/madler/zlib/pull/895)
# Disable the compiler extension to workaround the build failure until a zlib
# source update with the fix.
target_compile_options(clamscan PRIVATE -fno-define-target-os-macros)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use CheckCXXCompilerFlag, since there are versions of clang out there that don't support this flag.

https://cmake.org/cmake/help/latest/module/CheckCXXCompilerFlag.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your suggestion! This is indeed a better solution.

endif()
llvm_test_data(clamscan ${INPUT} dbdir)