From 5881ab88e0663f64bc29d0410ccf2de066251f2f Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Fri, 21 Jun 2024 12:03:10 -0600 Subject: [PATCH 1/3] Fix and prettify cmake --- CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ cmake/FindMKL.cmake | 2 -- src/CMakeLists.txt | 6 +++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b97a9ce..101d420b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 + "Debug" + CACHE STRING + "Choose the type of build, options are: Debug, Release." + FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release") +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) diff --git a/cmake/FindMKL.cmake b/cmake/FindMKL.cmake index 09a1feb7..b8f5fb4e 100644 --- a/cmake/FindMKL.cmake +++ b/cmake/FindMKL.cmake @@ -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 ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e45db9a..01255ad4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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() @@ -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) From ed78554de3d7c9074c7d284b29e5aebf063c008f Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Fri, 21 Jun 2024 12:43:45 -0600 Subject: [PATCH 2/3] Change default build type to release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 101d420b..c4aa94bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ 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 - "Debug" + "Release" CACHE STRING "Choose the type of build, options are: Debug, Release." FORCE) From 86473e7a88d9a7a994d4aefbfd32f4561c2fad0d Mon Sep 17 00:00:00 2001 From: Rene Gassmoeller Date: Fri, 21 Jun 2024 14:59:17 -0400 Subject: [PATCH 3/3] Update CMakeLists.txt Co-authored-by: Philipp Edelmann --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4aa94bc..e66b50be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,11 +36,11 @@ if ("${CMAKE_BUILD_TYPE}" STREQUAL "") set(CMAKE_BUILD_TYPE "Release" CACHE STRING - "Choose the type of build, options are: Debug, Release." + "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") + "Debug" "Release" "RelWithDebInfo" "MinSizeRel") endif() message(STATUS "Configuring in \"" ${CMAKE_BUILD_TYPE} "\" mode.")