Compare commits

..

2 Commits

Author SHA1 Message Date
portersky 6227ddf5df fix: clear Unity INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
CI / macOS (push) Has been cancelled
CI / Windows / Clang (push) Has been cancelled
Unity sets INTERFACE_SYSTEM_INCLUDE_DIRECTORIES to a path inside
the build tree, which CMake rejects on newer versions. Clear it
after FetchContent; the path remains in INTERFACE_INCLUDE_DIRECTORIES.
2026-05-10 01:38:49 +02:00
portersky 8df5eaa4e8 fix: use xcrun for llvm-cov on AppleClang
AppleClang ships llvm-cov inside Xcode and it is not on PATH,
so find_program fails. Use xcrun llvm-cov gcov via a wrapper
script instead.
2026-05-10 01:35:38 +02:00
2 changed files with 19 additions and 7 deletions
+12 -2
View File
@@ -21,13 +21,23 @@ if (ENABLE_COVERAGE)
find_program(GCOVR_EXE gcovr REQUIRED) find_program(GCOVR_EXE gcovr REQUIRED)
if (CMAKE_C_COMPILER_ID MATCHES "Clang") if (CMAKE_C_COMPILER_ID MATCHES "Clang")
find_program(LLVM_COV_EXE llvm-cov REQUIRED)
# gcovr needs a single-token gcov executable. Wrap llvm-cov gcov in a # gcovr needs a single-token gcov executable. Wrap llvm-cov gcov in a
# script placed in the build dir (guaranteed no spaces in path). # script placed in the build dir (guaranteed no spaces in path).
# AppleClang ships llvm-cov inside Xcode, reached only via xcrun.
if (WIN32) if (WIN32)
find_program(LLVM_COV_EXE llvm-cov REQUIRED)
set(GCOV_EXECUTABLE "${CMAKE_BINARY_DIR}/llvm-gcov.bat") set(GCOV_EXECUTABLE "${CMAKE_BINARY_DIR}/llvm-gcov.bat")
file(WRITE "${GCOV_EXECUTABLE}" "@echo off\r\n\"${LLVM_COV_EXE}\" gcov %*\r\n") file(WRITE "${GCOV_EXECUTABLE}" "@echo off\r\n\"${LLVM_COV_EXE}\" gcov %*\r\n")
elseif (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
find_program(XCRUN_EXE xcrun REQUIRED)
set(GCOV_EXECUTABLE "${CMAKE_BINARY_DIR}/llvm-gcov.sh")
file(WRITE "${GCOV_EXECUTABLE}" "#!/bin/sh\nexec xcrun llvm-cov gcov \"$@\"\n")
file(CHMOD "${GCOV_EXECUTABLE}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
else() else()
find_program(LLVM_COV_EXE llvm-cov REQUIRED)
set(GCOV_EXECUTABLE "${CMAKE_BINARY_DIR}/llvm-gcov.sh") set(GCOV_EXECUTABLE "${CMAKE_BINARY_DIR}/llvm-gcov.sh")
file(WRITE "${GCOV_EXECUTABLE}" "#!/bin/sh\nexec \"${LLVM_COV_EXE}\" gcov \"$@\"\n") file(WRITE "${GCOV_EXECUTABLE}" "#!/bin/sh\nexec \"${LLVM_COV_EXE}\" gcov \"$@\"\n")
file(CHMOD "${GCOV_EXECUTABLE}" file(CHMOD "${GCOV_EXECUTABLE}"
@@ -35,7 +45,7 @@ if (ENABLE_COVERAGE)
GROUP_READ GROUP_EXECUTE GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE) WORLD_READ WORLD_EXECUTE)
endif() endif()
message(STATUS "Coverage: enabled (gcovr: ${GCOVR_EXE}, gcov: ${LLVM_COV_EXE} gcov)") message(STATUS "Coverage: enabled (gcovr: ${GCOVR_EXE}, gcov: llvm-cov gcov)")
else() else()
set(GCOV_EXECUTABLE "gcov") set(GCOV_EXECUTABLE "gcov")
message(STATUS "Coverage: enabled (gcovr: ${GCOVR_EXE})") message(STATUS "Coverage: enabled (gcovr: ${GCOVR_EXE})")
+7 -5
View File
@@ -36,6 +36,13 @@ FetchContent_Declare(
FetchContent_MakeAvailable(unity) FetchContent_MakeAvailable(unity)
# Unity sets INTERFACE_SYSTEM_INCLUDE_DIRECTORIES to a path inside the build
# tree, which CMake rejects on newer versions. The path stays in
# INTERFACE_INCLUDE_DIRECTORIES so headers are still found.
if (TARGET unity)
set_target_properties(unity PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "")
endif()
if (NOT TARGET Unity::Unity) if (NOT TARGET Unity::Unity)
if (TARGET unity) if (TARGET unity)
add_library(Unity::Unity ALIAS unity) add_library(Unity::Unity ALIAS unity)
@@ -49,11 +56,6 @@ set(Unity_LIBRARIES Unity::Unity)
set(Unity_VERSION "${UNITY_VERSION}") set(Unity_VERSION "${UNITY_VERSION}")
set(Unity_INCLUDE_DIR "${unity_SOURCE_DIR}/src") set(Unity_INCLUDE_DIR "${unity_SOURCE_DIR}/src")
if (Unity_INCLUDE_DIR AND TARGET unity)
set_target_properties(unity PROPERTIES
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Unity_INCLUDE_DIR}"
)
endif()
if (TARGET unity) if (TARGET unity)
target_compile_definitions(unity PUBLIC target_compile_definitions(unity PUBLIC