Skip to content

Commit

Permalink
Merge bitcoin#28258: bitcoin-tidy: fix macOS build
Browse files Browse the repository at this point in the history
bb3263d bitcoin-tidy: fix macOS build (Cory Fields)

Pull request description:

  [LLVM uses these options](https://github.com/llvm/llvm-project/blob/main/llvm/cmake/modules/HandleLLVMOptions.cmake#L178) for building as well, so there's precedent.

  Also fix the shared library extension which was incorrectly being set to dylib.

  Thanks to jonatack for reporting and debugging.

ACKs for top commit:
  jonatack:
    ACK bb3263d tested with arm64 macos 13.5, llvm 16.0.6 and cmake 3.27.2

Tree-SHA512: de7bfd497f38f1565a14d217d0b057cbfa788bdda702b5942b7f0b55947ae5e1c05af13e7d6a073ed036bc4db57035868f180034508b6e084ab9b901a5baaf2f
  • Loading branch information
fanquake committed Aug 14, 2023
2 parents 3654d84 + bb3263d commit 6c508ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion contrib/devtools/bitcoin-tidy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ else()
target_compile_options(bitcoin-tidy PRIVATE -fno-exceptions)
endif()

if(CMAKE_HOST_APPLE)
# ld64 expects no undefined symbols by default
target_link_options(bitcoin-tidy PRIVATE -Wl,-flat_namespace)
target_link_options(bitcoin-tidy PRIVATE -Wl,-undefined -Wl,suppress)
endif()

# Add warnings
if (MSVC)
target_compile_options(bitcoin-tidy PRIVATE /W4)
Expand All @@ -33,7 +39,12 @@ else()
target_compile_options(bitcoin-tidy PRIVATE -Wextra)
endif()

set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--load=${CMAKE_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}bitcoin-tidy${CMAKE_SHARED_LIBRARY_SUFFIX}" "-checks=-*,bitcoin-*")
if(CMAKE_VERSION VERSION_LESS 3.27)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--load=${CMAKE_BINARY_DIR}/${CMAKE_SHARED_MODULE_PREFIX}bitcoin-tidy${CMAKE_SHARED_MODULE_SUFFIX}" "-checks=-*,bitcoin-*")
else()
# CLANG_TIDY_COMMAND supports generator expressions as of 3.27
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "--load=$<TARGET_FILE:bitcoin-tidy>" "-checks=-*,bitcoin-*")
endif()

# Create a dummy library that runs clang-tidy tests as a side-effect of building
add_library(bitcoin-tidy-tests OBJECT EXCLUDE_FROM_ALL example_logprintf.cpp)
Expand Down

0 comments on commit 6c508ac

Please sign in to comment.