Skip to content

Commit f6d39db

Browse files
committed
Fix macos gcc linkage error in myproj test
1 parent 2961369 commit f6d39db

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Utilities.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ function(detect_architecture arch)
125125
endif()
126126
endfunction()
127127

128+
function(detect_macos_version version)
129+
find_program(SW_VERS_EXECUTABLE sw_vers)
130+
execute_process(
131+
COMMAND "${SW_VERS_EXECUTABLE}" -productVersion
132+
OUTPUT_VARIABLE MACOS_VERSION
133+
)
134+
set(${version} "${MACOS_VERSION}" PARENT_SCOPE)
135+
endfunction()
136+
128137
# convert semicolons in generator expression to $<SEMICOLON>
129138
function(convert_genex_semicolons genex output)
130139
set(result)

tests/myproj/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ project_options(
8383
# Executable
8484
add_executable(main ./src/main/main.cpp)
8585
target_link_libraries(main PRIVATE myproj_project_options myproj_project_warnings)
86+
if(APPLE)
87+
detect_macos_version(apple_version)
88+
if (apple_version VERSION_GREATER_EQUAL 13)
89+
# workaround for linkage error as described in https://github.com/Homebrew/homebrew-core/issues/145991
90+
target_link_options(main PRIVATE -ld_classic)
91+
endif()
92+
endif()
8693

8794
## dependencies
8895
set(DEPENDENCIES_CONFIGURED fmt Eigen3 docopt)

0 commit comments

Comments
 (0)