Skip to content

Commit

Permalink
Fix a bug containing trailing whitespace when using Clang on macOS (#674
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ken-matsui authored Aug 12, 2022
1 parent 8e712ec commit 786460c
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cmake/ConfigRelease.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_ARCHIVE_FINISH true)
enable_ipo()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (APPLE)
# For nix, ref: https://github.com/NixOS/nixpkgs/issues/166205
set(STATIC_FLAG " -lc++abi")
endif ()

if (${CMAKE_CXX_COMPILER} MATCHES "-[0-9]+$")
string(REGEX REPLACE [[.*clang\+\+(-[0-9]+)$]] [[lld\1]] LINKER ${CMAKE_CXX_COMPILER})
set(STATIC_LINK_FLAG "-fuse-ld=${LINKER}${STATIC_FLAG}")
set(STATIC_LINK_FLAG "-fuse-ld=${LINKER}")
else ()
find_program(lld_EXECUTABLE lld)
if (lld_EXECUTABLE)
set(STATIC_LINK_FLAG "-fuse-ld=lld${STATIC_FLAG}")
set(STATIC_LINK_FLAG "-fuse-ld=lld")
else ()
set(STATIC_LINK_FLAG "") # use `ld`
endif ()
endif ()

# For nix, ref: https://github.com/NixOS/nixpkgs/issues/166205
if (APPLE)
if (STATIC_LINK_FLAG STREQUAL "")
set(STATIC_LINK_FLAG "-lc++abi")
else ()
set(STATIC_LINK_FLAG "${STATIC_FLAG}") # use `ld`
set(STATIC_LINK_FLAG "${STATIC_LINK_FLAG} -lc++abi")
endif ()
endif ()

Expand Down

0 comments on commit 786460c

Please sign in to comment.