Skip to content

Commit 1e9540f

Browse files
committed
Make: Apple's libSystem contains Blocks runtime
1 parent a21ac35 commit 1e9540f

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

.github/workflows/prerelease.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,23 @@ jobs:
176176
brew update
177177
brew reinstall cmake llvm@${{ matrix.llvm }}
178178
179-
- name: Configure (CMake)
179+
- name: Build C/C++
180180
run: |
181181
cmake -S . -B build_artifacts -D CMAKE_BUILD_TYPE=${{ matrix.config }} -D CMAKE_CXX_COMPILER=$(brew --prefix llvm@${{ matrix.llvm }})/bin/clang++
182+
cmake --build build_artifacts --config ${{ matrix.config }} --parallel
182183
183-
- name: Build
184-
run: cmake --build build_artifacts --config ${{ matrix.config }} --parallel
185-
186-
- name: Run C++ tests
184+
- name: Test C++
187185
run: |
188186
set -euxo pipefail
189187
build_artifacts/fork_union_test_cpp17
190188
build_artifacts/fork_union_test_cpp20
191189
build_artifacts/fork_union_test_cpp23
192190
193-
- name: Run C API tests
191+
- name: Test C
194192
run: |
195193
set -euxo pipefail
196194
build_artifacts/fork_union_test_c11
195+
build_artifacts/fork_union_test_c_clang_blocks
197196
198197
test_windows:
199198
name: Windows

scripts/CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ function (set_target_properties_for_fork_union_script target_name)
1212
if (CMAKE_BUILD_TYPE STREQUAL "Release")
1313
message(STATUS "Enabling optimizations for ${target_name}")
1414
target_compile_options(
15-
${target_name}
16-
PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-O3 -march=native -mtune=native>
17-
$<$<CXX_COMPILER_ID:MSVC>:/O2 /Ob3>
15+
${target_name} PRIVATE $<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-O3 -march=native -mtune=native>
16+
$<$<CXX_COMPILER_ID:MSVC>:/O2 /Ob3>
1817
)
1918
endif ()
2019

@@ -111,7 +110,7 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
111110
endif ()
112111

113112
# Clang blocks extension test
114-
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
113+
if (CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
115114
add_executable(fork_union_test_c_clang_blocks test.c)
116115
set_target_properties(
117116
fork_union_test_c_clang_blocks
@@ -124,10 +123,10 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
124123
target_link_libraries(fork_union_test_c_clang_blocks PRIVATE fork_union_static)
125124
add_test(NAME fork_union_test_c_clang_blocks COMMAND fork_union_test_c_clang_blocks)
126125

127-
if (UNIX AND NOT APPLE)
126+
if (APPLE)
127+
# Apple's `libSystem` already ships the Blocks runtime, so no extra linkage is required
128+
elseif (UNIX)
128129
target_link_libraries(fork_union_test_c_clang_blocks PRIVATE -latomic -lBlocksRuntime)
129-
else ()
130-
target_link_libraries(fork_union_test_c_clang_blocks PRIVATE -lBlocksRuntime)
131130
endif ()
132131
endif ()
133132

@@ -150,8 +149,7 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STR
150149
execute_process(
151150
COMMAND ${BREW_EXECUTABLE} --prefix libomp
152151
OUTPUT_VARIABLE LIBOMP_PREFIX
153-
OUTPUT_STRIP_TRAILING_WHITESPACE
154-
ERROR_QUIET
152+
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
155153
)
156154
if (LIBOMP_PREFIX AND EXISTS "${LIBOMP_PREFIX}/include/omp.h")
157155
message(STATUS "Enabling OpenMP for fork_union_nbody on Clang with Homebrew libomp")

0 commit comments

Comments
 (0)