From 43d41e5800ce174fc4a311ec81e77db74c8df51b Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 7 Feb 2022 20:44:56 +0000 Subject: [PATCH 1/2] Update for compiling on Apple. Fixes #620. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3657c8ade..cad5da7b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,13 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS_DEBUG "-O1 -ggdb -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") endif() +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() + if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -traceback") set(CMAKE_C_FLAGS_RELEASE "-O2") From 0d72db3d382e679f1c26b6833030b3316656550a Mon Sep 17 00:00:00 2001 From: George Gayno Date: Mon, 7 Feb 2022 20:52:41 +0000 Subject: [PATCH 2/2] Update should be for Intel only. Fixes #620. --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cad5da7b6..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) @@ -41,13 +47,6 @@ elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$") set(CMAKE_Fortran_FLAGS_DEBUG "-O1 -ggdb -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls") endif() -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() - if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -traceback") set(CMAKE_C_FLAGS_RELEASE "-O2")