From 5492f9943a0bd9e602bcd2676edd10cd4453b52d Mon Sep 17 00:00:00 2001 From: Puneet Matharu Date: Fri, 1 Dec 2023 17:57:37 +0000 Subject: [PATCH] Patch issue with XCode 15.0. --- CMakeLists.txt | 10 ++++++++++ cmake/OomphAddExecutable.cmake | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c56e82a28422..6462c8ce4fc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/OomphAddExecutable.cmake b/cmake/OomphAddExecutable.cmake index 89b5b7a24e23..559e3076552c 100644 --- a/cmake/OomphAddExecutable.cmake +++ b/cmake/OomphAddExecutable.cmake @@ -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)