Skip to content
14 changes: 0 additions & 14 deletions cmake/SCHISM.local.conda
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,7 @@
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileContributor Carsten Lemmen <carsten.lemmen@hereon.de

message(WARNING "If you get an error 'Error copying Fortran module' with uppercase/lowercase mismatch, then try setting the CMAKE_C_PREPROCESS_FLAG to an empty string in cmake/SCHISMCompile.cmake")

set(CMAKE_Fortran_COMPILER $ENV{CONDA_PREFIX}/bin/mpifort CACHE PATH "Path to parallel Fortran compiler")
set(CMAKE_C_COMPILER $ENV{CONDA_PREFIX}/bin/mpicc CACHE PATH "Path to parallel C compiler")
set(CMAKE_CXX_COMPILER $ENV{CONDA_PREFIX}/bin/mpicxx CACHE PATH "Path to parallel C++ compiler")
set(PARMETIS_ROOT $ENV{CONDA_PREFIX} CACHE PATH "Root path for external (par)metis")

set_source_files_properties(
*.F90
PROPERTIES Fortran_PREPROCESS ON
)

# Fix gfortran/clang for conda environments
if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set( C_PREPROCESS_FLAG "" CACHE STRING "C Preprocessor Flag")
endif()
endif()
13 changes: 9 additions & 4 deletions cmake/SCHISMCompile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,15 @@ if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
set( CMAKE_Fortran_FLAGS_DEBUG_INIT "-g ${SCHISM_GFORTRAN_OPTIONS}")
set( CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g ${SCHISM_GFORTRAN_OPTIONS}")
unset( C_PREPROCESS_FLAG CACHE)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set( C_PREPROCESS_FLAG "--preprocess" CACHE STRING "C Preprocessor Flag")
elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
set( C_PREPROCESS_FLAG "--preprocess" CACHE STRING "C Preprocessor Flag")
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
Comment thread
PhilMiller marked this conversation as resolved.
Outdated
# gfortran cannot handle Clang's --preprocess flag, thus we need to
# remove it (Clang preprocesses by default, even without the flag)
# and enable Fortran preprocessing for .f90 and F90 files.
set( C_PREPROCESS_FLAG "" CACHE STRING "C Preprocessor Flag")
set_source_files_properties(
*.F90 *.f90
PROPERTIES Fortran_PREPROCESS ON
)
else()
set( C_PREPROCESS_FLAG "-cpp" CACHE STRING "C Preprocessor Flag")
endif()
Expand Down