Skip to content

Commit

Permalink
Merge pull request #546 from gassmoeller/fix_cmake
Browse files Browse the repository at this point in the history
Improve and prettify cmake
  • Loading branch information
feathern authored Jun 21, 2024
2 parents f27a3e9 + 86473e7 commit 2491765
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,46 @@ cmake_minimum_required(VERSION 3.13)

project(rayleigh LANGUAGES C Fortran)

# load in version info and export it
file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION" RAYLEIGH_PACKAGE_VERSION LIMIT_COUNT 1)


message(STATUS "")
message(STATUS "====================================================")
message(STATUS "===== Configuring Rayleigh ${RAYLEIGH_PACKAGE_VERSION}")
message(STATUS "====================================================")
message(STATUS "")

# Set up CMAKE_BUILD_TYPE to Debug if it is not set by the user.
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING
"Choose the type of build, options are: Debug, Release, RelWithDebInfo, MinSizeRel."
FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()

message(STATUS "Configuring in \"" ${CMAKE_BUILD_TYPE} "\" mode.")
message(STATUS "")

# Set the default install directory, if run for the first time
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_SOURCE_DIR}")
endif()

message(STATUS "Installing executable in ${CMAKE_INSTALL_PREFIX}/bin")
message(STATUS "")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

message(STATUS "===== Configuring external libraries ===============")
message(STATUS "")

find_package(MPI COMPONENTS C REQUIRED Fortran REQUIRED)
find_package(LAPACK COMPONENTS Fortran REQUIRED)
find_package(FFTW REQUIRED)
Expand Down
2 changes: 0 additions & 2 deletions cmake/FindMKL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# MKL_PATH - root directory of the MKL installation
# MKL_ROOT - root directory of the MKL installation

option( MKL_PARALLEL "if mkl shoudl be parallel" OFF )

if( MKL_PARALLEL )

set( __mkl_lib_par MKL_LIB_INTEL_THREAD )
Expand Down
6 changes: 5 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ if (RAYLEIGH_CPU_OPTIMIZATIONS STREQUAL "native")
message(STATUS "enabling native optimizations")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
target_compile_options(rayleigh PRIVATE -xHost)
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
target_compile_options(rayleigh PRIVATE -xHost)
else()
message(FATAL_ERROR "For your compiler no native optimizations are automatically detected. Please specify compiler flags manually and set 'CPU_OPTIMIZATIONS' to 'none'")
endif()
Expand All @@ -70,4 +72,6 @@ target_link_libraries(rayleigh MPI::MPI_Fortran)
target_link_libraries(rayleigh LAPACK::LAPACK)
target_link_libraries(rayleigh FFTW::fftw3)

install(TARGETS rayleigh DESTINATION ${CMAKE_SOURCE_DIR}/bin)
message(STATUS "")

install(TARGETS rayleigh RUNTIME DESTINATION bin COMPONENT runtime)

0 comments on commit 2491765

Please sign in to comment.