diff --git a/CMakeLists.txt b/CMakeLists.txt index 3657c8ade..519a17200 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,12 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback") set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model precise") set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -check -check noarg_temp_created -check nopointer -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv") + if(APPLE) + # The linker on macOS does not include `common symbols` by default. + # Passing the -c flag includes them and fixes an error with undefined symbols. + set(CMAKE_Fortran_ARCHIVE_FINISH " -c ") + set(CMAKE_C_ARCHIVE_FINISH " -c ") + endif() elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -fbacktrace") if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)