Skip to content

Commit

Permalink
Merge branch 'modern-CMake-preprocessing' into 'development'
Browse files Browse the repository at this point in the history
Modern CMake preprocessing

See merge request damask/DAMASK!887
  • Loading branch information
MarDiehl committed Dec 29, 2023
2 parents 9ebb2d4 + e4e0840 commit ccf4867
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ else()
endif()
add_definitions("-D${DAMASK_SOLVER}")

set(CMAKE_Fortran_PREPROCESS "ON")

# EXPERIMENTAL: This might help to detect HDF5 and FFTW3 in the future if PETSc is not aware of them
set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/externalpackages:$ENV{PKG_CONFIG_PATH}")
pkg_check_modules(HDF5 hdf5)
Expand Down Expand Up @@ -91,27 +93,24 @@ if(CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
endif()


list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
include(Compiler-GNU)
set(Fortran_COMPILER_VERSION_MIN 9.1)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
include(Compiler-Intel)
set(Fortran_COMPILER_VERSION_MIN 19)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
include(Compiler-IntelLLVM)
set(Fortran_COMPILER_VERSION_MIN 19)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "LLVMFlang")
include(Compiler-LLVMFlang)
set(Fortran_COMPILER_VERSION_MIN 19)
else()
message(FATAL_ERROR "Compiler '${CMAKE_Fortran_COMPILER_ID}' not supported")
endif()

if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS Fortran_COMPILER_VERSION_MIN)
message(FATAL_ERROR "Version '${CMAKE_Fortran_COMPILER_VERSION}' of '${CMAKE_Fortran_COMPILER_ID}' is not supported")
endif()

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include("Compiler-${CMAKE_Fortran_COMPILER_ID}")

file(STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_EXTERNAL_LIB REGEX "PETSC_EXTERNAL_LIB_BASIC = .*$?")
string(REPLACE "PETSC_EXTERNAL_LIB_BASIC = " "" PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")
message("PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
Expand Down
3 changes: 0 additions & 3 deletions cmake/Compiler-GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ set (STANDARD_CHECK "-std=f2018 -pedantic-errors" )

#------------------------------------------------------------------------------------------------
# Fine tuning compilation options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -cpp")
# preprocessor

set (COMPILE_FLAGS "${COMPILE_FLAGS} -fPIE")
# position independent code

Expand Down
3 changes: 0 additions & 3 deletions cmake/Compiler-Intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ set (LINKER_FLAGS "${LINKER_FLAGS} -shared-intel")

#------------------------------------------------------------------------------------------------
# Fine tuning compilation options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp")
# preprocessor

set (COMPILE_FLAGS "${COMPILE_FLAGS} -no-ftz")
# disable flush underflow to zero, will be set if -O[1,2,3]

Expand Down
3 changes: 0 additions & 3 deletions cmake/Compiler-IntelLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ set (LINKER_FLAGS "${LINKER_FLAGS} -shared-intel -fc=ifx")

#------------------------------------------------------------------------------------------------
# Fine tuning compilation options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -fpp")
# preprocessor

set (COMPILE_FLAGS "${COMPILE_FLAGS} -no-ftz")
# disable flush underflow to zero, will be set if -O[1,2,3]

Expand Down
4 changes: 2 additions & 2 deletions cmake/Compiler-LLVMFlang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ if (OPENMP)
set (OPENMP_FLAGS "-fopenmp")
endif ()

set (STANDARD_CHECK "-std=f2018 -pedantic" )

#------------------------------------------------------------------------------------------------
# Fine tuning compilation options
set (COMPILE_FLAGS "${COMPILE_FLAGS} -cpp")
# preprocessor

0 comments on commit ccf4867

Please sign in to comment.