Skip to content

Commit

Permalink
Patch issue with XCode 15.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetmatharu committed Dec 1, 2023
1 parent 40d23aa commit 5492f99
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ oomph_path_option(
# C++ files only
include(OomphAddCXXCompileDefinitions)

# FIXME: XCode 15.0 has a new linker implementation which breaks things; setting
# this values tells CMake to revert to the old linker
if(APPLE)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 15.0)
add_link_options("-Wl,-ld_classic")
endif()
endif()
endif()

# Let CMake take care of the famous -fPIC flag
if(BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand Down
13 changes: 13 additions & 0 deletions cmake/OomphAddExecutable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ function(oomph_add_executable)
# Link to the specified libraries
target_link_libraries(${NAME}_${PATH_HASH} PUBLIC ${LIBRARIES})

# FIXME: XCode 15.0 problems :(
if(APPLE)
include(CheckLinkerFlag)
foreach(FLAG IN ITEMS -no_warn_duplicate_libraries -ld_classic)
check_linker_flag(CXX FLAG IS_CXX_FLAG)
if(IS_CXX_FLAG)
target_link_options(${NAME}_${PATH_HASH} PRIVATE LINKER:${FLAG})
else()
message(STATUS "C++ linker flag ${FLAG} is not supported.")
endif()
endforeach()
endif()

# Provide access to the MPI libraries if we've built oomph-lib with MPI
if(OOMPH_HAS_MPI)
target_link_libraries(${NAME}_${PATH_HASH} PUBLIC MPI::MPI_CXX)
Expand Down

0 comments on commit 5492f99

Please sign in to comment.