From 231db955f22d438fd7559d319d9bde5b3e328f74 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Jun 2024 13:12:09 +0200 Subject: [PATCH 1/5] Use `add_compile_options(...)` and `add_link_options(...)` instead of appending flags to CACHE variables. --- CMAKE/CheckLAPACKCompilerFlags.cmake | 354 +++++++++++---------------- CMakeLists.txt | 20 +- INSTALL/CMakeLists.txt | 8 + 3 files changed, 155 insertions(+), 227 deletions(-) diff --git a/CMAKE/CheckLAPACKCompilerFlags.cmake b/CMAKE/CheckLAPACKCompilerFlags.cmake index 653b817583..2cf62c18fa 100644 --- a/CMAKE/CheckLAPACKCompilerFlags.cmake +++ b/CMAKE/CheckLAPACKCompilerFlags.cmake @@ -10,34 +10,32 @@ # Copyright 2011 #============================================================================= -macro( CheckLAPACKCompilerFlags ) +macro(CheckLAPACKCompilerFlags) -set( FPE_EXIT FALSE ) - -# FORTRAN ILP default -set(FOPT_ILP64) -if( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) - if ( WIN32 ) - set(FOPT_ILP64 /integer-size:64) - else () - set(FOPT_ILP64 "-integer-size 64") + # FORTRAN ILP default + set(FOPT_ILP64) + if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + if(WIN32) + set(FOPT_ILP64 /integer-size:64) + else() + set(FOPT_ILP64 "-integer-size 64") endif() -elseif( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6 - (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8 + elseif((CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge") OR # CMake 2.6 + (CMAKE_Fortran_COMPILER_ID STREQUAL "XL")) # CMake 2.8 set(FOPT_ILP64 -qintsize=8) -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) - if ( WIN32 ) - set(FOPT_ILP64 /i8) - else () - set(FOPT_ILP64 -i8) + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") + if(WIN32) + set(FOPT_ILP64 /i8) + else() + set(FOPT_ILP64 -i8) endif() -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" ) - if ( WIN32 ) - set(FOPT_ILP64 /i8) - else () - set(FOPT_ILP64 -i8) + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") + if(WIN32) + set(FOPT_ILP64 /i8) + else() + set(FOPT_ILP64 -i8) endif() -else() + else() set(CPE_ENV $ENV{PE_ENV}) if(CPE_ENV STREQUAL "CRAY") set(FOPT_ILP64 -sinteger64) @@ -46,210 +44,148 @@ else() else() set(FOPT_ILP64 -fdefault-integer-8) endif() -endif() -if ( FORTRAN_ILP ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FOPT_ILP64}") -endif() - -# GNU Fortran -if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" ) - if( "${CMAKE_Fortran_FLAGS}" MATCHES "-ffpe-trap=[izoupd]") - set( FPE_EXIT TRUE ) - endif() - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-frecursive") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -frecursive" - CACHE STRING "Recursive flag must be set" FORCE) - endif() - -# Intel Fortran -elseif( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" ) - if( "${CMAKE_Fortran_FLAGS}" MATCHES "[-/]fpe(-all=|)0" ) - set( FPE_EXIT TRUE ) - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-recursive") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive" - CACHE STRING "Recursive flag must be set" FORCE) - endif() - - if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-fp-model[ \t]strict") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict") - endif() - -# SunPro F95 -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) - if( ("${CMAKE_Fortran_FLAGS}" MATCHES "-ftrap=") AND - NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-ftrap=(%|)none") ) - set( FPE_EXIT TRUE ) - elseif( NOT (CMAKE_Fortran_FLAGS MATCHES "-ftrap=") ) - message( STATUS "Disabling FPE trap handlers with -ftrap=%none" ) - set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ftrap=%none" - CACHE STRING "Flags for Fortran compiler." FORCE ) - endif() - - if(UNIX) - # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler. - # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin - string(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") - endif() - -# IBM XL Fortran -elseif( (CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge" ) OR # CMake 2.6 - (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" ) ) # CMake 2.8 - if( "${CMAKE_Fortran_FLAGS}" MATCHES "-qflttrap=[a-zA-Z:]:enable" ) - set( FPE_EXIT TRUE ) - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qrecur") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qrecur" - CACHE STRING "Recursive flag must be set" FORCE) endif() - - if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qnosave") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnosave") + if(FORTRAN_ILP) + add_compile_options("$<$:${FOPT_ILP64}>") endif() + # GNU Fortran + if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + set(FPE_EXIT_FLAG "-ffpe-trap=[izoupd]") - if( UNIX AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-qstrict") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qstrict") - endif() - -# HP Fortran -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "HP" ) - if( "${CMAKE_Fortran_FLAGS}" MATCHES "\\+fp_exception" ) - set( FPE_EXIT TRUE ) - endif() + add_compile_options("$<$:-frecursive>") - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "\\+fltconst_strict") ) - message( STATUS "Enabling strict float conversion with +fltconst_strict" ) - set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} +fltconst_strict" - CACHE STRING "Flags for Fortran compiler." FORCE ) - endif() - - # Most versions of cmake don't have good default options for the HP compiler - set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -g" - CACHE STRING "Flags used by the compiler during debug builds" FORCE ) - set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_MINSIZEREL} +Osize" - CACHE STRING "Flags used by the compiler during release minsize builds" FORCE ) - set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELEASE} +O2" - CACHE STRING "Flags used by the compiler during release builds" FORCE ) - set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_RELWITHDEBINFO} +O2 -g" - CACHE STRING "Flags used by the compiler during release with debug info builds" FORCE ) - -# NAG Fortran -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) - if( "${CMAKE_Fortran_FLAGS}" MATCHES "[-/]ieee=(stop|nonstd)" ) - set( FPE_EXIT TRUE ) - endif() + # Intel Fortran + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(FPE_EXIT_FLAG "[-/]fpe(-all=|)0") - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]ieee=full") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ieee=full") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]dcfuns") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -dcfuns") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]thread_safe") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -thread_safe") - endif() - - # Disable warnings - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]w=obs") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=obs") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]w=x77") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=x77") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]w=ques") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=ques") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]w=unused") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w=unused") - endif() - - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-recursive") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -recursive" - CACHE STRING "Recursive flag must be set" FORCE) - endif() + add_compile_options("$<$:-recursive>") + if(UNIX) + add_compile_options("$<$:-fp-model strict>") + endif() - # Suppress compiler banner and summary - include(CheckFortranCompilerFlag) - check_fortran_compiler_flag("-quiet" _quiet) - if( _quiet AND NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]quiet") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -quiet") - endif() + # SunPro F95 + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro") + set(FPE_EXIT_FLAG "-ftrap=") + set(FPE_DISABLE_FLAG "-ftrap=(%|)none") -# NVIDIA HPC SDK -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" ) - if( ("${CMAKE_Fortran_FLAGS}" MATCHES "-Ktrap=") AND - NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-Ktrap=none") ) - set( FPE_EXIT TRUE ) - endif() + message(STATUS "Disabling FPE trap handlers with -ftrap=%none") + add_compile_options("$<$:-ftrap=%none>") - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "[-/]Kieee") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Kieee") - endif() + if(UNIX) + # Delete libmtsk in linking sequence for Sun/Oracle Fortran Compiler. + # This library is not present in the Sun package SolarisStudio12.3-linux-x86-bin + string(REPLACE \;mtsk\; \; CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES + "${CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES}") + endif() - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-Mrecursive") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive" - CACHE STRING "Recursive flag must be set" FORCE) - endif() + # IBM XL Fortran + elseif((CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge") OR # CMake 2.6 + (CMAKE_Fortran_COMPILER_ID STREQUAL "XL")) # CMake 2.8 + set(FPE_EXIT_FLAG "-qflttrap=[a-zA-Z:]:enable") -# Flang Fortran -elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Flang" ) - if( NOT ("${CMAKE_Fortran_FLAGS}" MATCHES "-Mrecursive") ) - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mrecursive" - CACHE STRING "Recursive flag must be set" FORCE) - endif() + add_compile_options("$<$:-qrecur>") + if(UNIX) + add_compile_options("$<$:-qnosave>") + add_compile_options("$<$:-qstrict>") + endif() -# Compaq Fortran -elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq") - if(WIN32) - if(CMAKE_GENERATOR STREQUAL "NMake Makefiles") - get_filename_component(CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE) - message(STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM}") - set(cmd ${CMAKE_Fortran_COMPILER_CMDNAM}) - string(TOLOWER "${cmd}" cmdlc) - if(cmdlc STREQUAL "df") - message(STATUS "Assume the Compaq Visual Fortran Compiler is being used") - set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1) - set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1) - #This is a workaround that is needed to avoid forward-slashes in the - #filenames listed in response files from incorrectly being interpreted as - #introducing compiler command options - if(${BUILD_SHARED_LIBS}) - message(FATAL_ERROR "Making of shared libraries with CVF has not been tested.") + # HP Fortran + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "HP") + set(FPE_EXIT_FLAG "\\+fp_exception") + + message(STATUS "Enabling strict float conversion with +fltconst_strict") + add_compile_options("$<$:+fltconst_strict>") + + # Most versions of cmake don't have good default options for the HP compiler + add_compile_options("$<$,$>:-g>") + add_compile_options("$<$,$>:+Osize>") + add_compile_options("$<$,$>:+O2>") + add_compile_options("$<$,$>:+O2 -g>") + + # NAG Fortran + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NAG") + set(FPE_EXIT_FLAG "[-/]ieee=(stop|nonstd)") + + add_compile_options("$<$:-ieee=full>") + add_compile_options("$<$:-dcfuns>") + add_compile_options("$<$:-thread_safe>") + add_link_options("$<$:-thread_safe>") + add_compile_options("$<$:-recursive>") + + # Disable warnings + add_compile_options("$<$:-w=obs>") + add_compile_options("$<$:-w=x77>") + add_compile_options("$<$:-w=ques>") + add_compile_options("$<$:-w=unused>") + + # Suppress compiler banner and summary + include(CheckFortranCompilerFlag) + check_fortran_compiler_flag("-quiet" _quiet) + add_compile_options("$<$,$>:-quiet>") + add_link_options("$<$,$>:-quiet>") + + # NVIDIA HPC SDK + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") + set(FPE_EXIT_FLAG "-Ktrap=") + set(FPE_DISABLE_FLAG "-Ktrap=none") + + add_compile_options("$<$:-Kieee>") + add_compile_options("$<$:-Mrecursive>") + + # Flang Fortran + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") + add_compile_options("$<$:-Mrecursive>") + + # Compaq Fortran + elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Compaq") + if(WIN32) + if(CMAKE_GENERATOR STREQUAL "NMake Makefiles") + get_filename_component(CMAKE_Fortran_COMPILER_CMDNAM ${CMAKE_Fortran_COMPILER} NAME_WE) + message(STATUS "Using Compaq Fortran compiler with command name ${CMAKE_Fortran_COMPILER_CMDNAM}") + set(cmd ${CMAKE_Fortran_COMPILER_CMDNAM}) + string(TOLOWER "${cmd}" cmdlc) + if(cmdlc STREQUAL "df") + message(STATUS "Assume the Compaq Visual Fortran Compiler is being used") + set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 1) + set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_INCLUDES 1) + #This is a workaround that is needed to avoid forward-slashes in the + #filenames listed in response files from incorrectly being interpreted as + #introducing compiler command options + if(${BUILD_SHARED_LIBS}) + message(FATAL_ERROR "Making of shared libraries with CVF has not been tested.") + endif() + set(str "NMake version 9 or later should be used. NMake version 6.0 which is\n") + set(str "${str} included with the CVF distribution fails to build Lapack because\n") + set(str "${str} the number of source files exceeds the limit for NMake v6.0\n") + message(STATUS ${str}) + set(CMAKE_Fortran_LINK_EXECUTABLE "LINK /out: ") endif() - set(str "NMake version 9 or later should be used. NMake version 6.0 which is\n") - set(str "${str} included with the CVF distribution fails to build Lapack because\n") - set(str "${str} the number of source files exceeds the limit for NMake v6.0\n") - message(STATUS ${str}) - set(CMAKE_Fortran_LINK_EXECUTABLE "LINK /out: ") endif() endif() - endif() -else() - message(WARNING "Fortran local arrays should be allocated on the stack." - " Please use a compiler which guarantees that feature." - " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein.") -endif() + else() + message(WARNING "Fortran local arrays should be allocated on the stack." + " Please use a compiler which guarantees that feature." + " See https://github.com/Reference-LAPACK/lapack/pull/188 and references therein.") + endif() -if( "${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "O[3-9]" ) - message( STATUS "Reducing RELEASE optimization level to O2" ) - string( REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE - "${CMAKE_Fortran_FLAGS_RELEASE}" ) - set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" - CACHE STRING "Flags used by the compiler during release builds" FORCE ) -endif() + if("${CMAKE_Fortran_FLAGS_RELEASE}" MATCHES "O[3-9]") + message(STATUS "Reducing RELEASE optimization level to O2") + string(REGEX REPLACE "O[3-9]" "O2" CMAKE_Fortran_FLAGS_RELEASE + "${CMAKE_Fortran_FLAGS_RELEASE}") + endif() + # Get all flags added via `add_compile_options(...)` + get_directory_property(COMP_OPTIONS COMPILE_OPTIONS) -if( FPE_EXIT ) - message( FATAL_ERROR "Floating Point Exception (FPE) trap handlers are currently explicitly enabled in the compiler flags. LAPACK is designed to check for and handle these cases internally and enabling these traps will likely cause LAPACK to crash. Please re-configure with floating point exception trapping disabled." ) -endif() + if(("${CMAKE_Fortran_FLAGS};${COMP_OPTIONS}" MATCHES "${FPE_EXIT_FLAG}") AND NOT + ("${CMAKE_Fortran_FLAGS};${COMP_OPTIONS}" MATCHES "${FPE_DISABLE_FLAG}")) + message( FATAL_ERROR "Floating Point Exception (FPE) trap handlers are" + " currently explicitly enabled in the compiler flags. LAPACK is designed" + " to check for and handle these cases internally and enabling these traps" + " will likely cause LAPACK to crash. Please re-configure with floating" + " point exception trapping disabled.") + endif() endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 5baf8f446b..387e612fe9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,15 +265,7 @@ if(NOT BLAS_FOUND) add_subdirectory(BLAS) set(BLAS_LIBRARIES ${BLASLIB}) else() - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" - CACHE STRING "Linker flags for executables" FORCE) - set(CMAKE_MODULE_LINKER_FLAGS - "${CMAKE_MODULE_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" - CACHE STRING "Linker flags for modules" FORCE) - set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} ${BLAS_LINKER_FLAGS}" - CACHE STRING "Linker flags for shared libs" FORCE) + add_link_options(${BLAS_LINKER_FLAGS}) endif() @@ -355,15 +347,7 @@ if(NOT LATESTLAPACK_FOUND) add_subdirectory(SRC) else() - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_EXE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" - CACHE STRING "Linker flags for executables" FORCE) - set(CMAKE_MODULE_LINKER_FLAGS - "${CMAKE_MODULE_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" - CACHE STRING "Linker flags for modules" FORCE) - set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} ${LAPACK_LINKER_FLAGS}" - CACHE STRING "Linker flags for shared libs" FORCE) + add_link_options(${LAPACK_LINKER_FLAGS}) endif() if(BUILD_TESTING) diff --git a/INSTALL/CMakeLists.txt b/INSTALL/CMakeLists.txt index 51fe01f1e2..92524ebc5a 100644 --- a/INSTALL/CMakeLists.txt +++ b/INSTALL/CMakeLists.txt @@ -1,5 +1,13 @@ cmake_minimum_required(VERSION 3.6) project(TIMING Fortran) + +# Add the CMake directory for custom CMake modules +set(CMAKE_MODULE_PATH "${TIMING_SOURCE_DIR}/../CMAKE" ${CMAKE_MODULE_PATH}) + +# Check for any necessary platform specific compiler flags +include(CheckLAPACKCompilerFlags) +CheckLAPACKCompilerFlags() + add_executable(secondtst_NONE second_NONE.f secondtst.f) add_executable(secondtst_EXT_ETIME second_EXT_ETIME.f secondtst.f) add_executable(secondtst_EXT_ETIME_ second_EXT_ETIME_.f secondtst.f) From 0af92d8230f9904735360ed9af6f54d9bd25e4ad Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Jun 2024 13:13:38 +0200 Subject: [PATCH 2/5] Bump minimum CMake version to 3.13 --- CMakeLists.txt | 2 +- INSTALL/CMakeLists.txt | 2 +- LAPACKE/mangling/CMakeLists.txt | 2 +- lapack_build.cmake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 387e612fe9..7f6e2d804b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.13) project(LAPACK) diff --git a/INSTALL/CMakeLists.txt b/INSTALL/CMakeLists.txt index 92524ebc5a..5d34584ff1 100644 --- a/INSTALL/CMakeLists.txt +++ b/INSTALL/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.13) project(TIMING Fortran) # Add the CMake directory for custom CMake modules diff --git a/LAPACKE/mangling/CMakeLists.txt b/LAPACKE/mangling/CMakeLists.txt index 1b6b308e07..a3e20ab79a 100644 --- a/LAPACKE/mangling/CMakeLists.txt +++ b/LAPACKE/mangling/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.13) project(MANGLING C Fortran) add_executable(xintface Fintface.f Cintface.c) diff --git a/lapack_build.cmake b/lapack_build.cmake index 83f812460e..1460acaa28 100644 --- a/lapack_build.cmake +++ b/lapack_build.cmake @@ -4,7 +4,7 @@ ## HINTS: ctest -Ddashboard_model=Nightly -S $(pwd)/lapack/lapack_build.cmake ## -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.13) ################################################################### # The values in this section must always be provided ################################################################### From fe5c2529fe92c28b6dcbabe360d36f99e23b81f7 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Jun 2024 14:06:32 +0200 Subject: [PATCH 3/5] Set minimum CMake version for `INDEX64_EXT_API` to 3.18 due to the need of the `Fortran_PREPROCESS` target property --- CMakeLists.txt | 2 +- SRC/CMakeLists.txt | 1 + TESTING/MATGEN/CMakeLists.txt | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f6e2d804b..2dde033025 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,7 @@ else() endif() # By default build extended _64 API for supported compilers only set(INDEX64_EXT_API_COMPILERS "Intel|GNU") -option(BUILD_INDEX64_EXT_API "Build Index-64 API as extended API with _64 suffix" ON) +option(BUILD_INDEX64_EXT_API "Build Index-64 API as extended API with _64 suffix (needs CMake >= 3.18)" ON) message(STATUS "Build Index-64 API as extended API with _64 suffix: ${BUILD_INDEX64_EXT_API}") include(GNUInstallDirs) diff --git a/SRC/CMakeLists.txt b/SRC/CMakeLists.txt index a2f396bae2..869b1c8a28 100644 --- a/SRC/CMakeLists.txt +++ b/SRC/CMakeLists.txt @@ -541,6 +541,7 @@ if(BUILD_INDEX64_EXT_API) set(BUILD_INDEX64_EXT_API OFF) set(BUILD_INDEX64_EXT_API OFF PARENT_SCOPE) else() + cmake_minimum_required(VERSION 3.18) set(SOURCES_64) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${LAPACKLIB}_64_obj) file(COPY ${SOURCES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${LAPACKLIB}_64_obj) diff --git a/TESTING/MATGEN/CMakeLists.txt b/TESTING/MATGEN/CMakeLists.txt index 6d3a75ceb0..3866acc29c 100644 --- a/TESTING/MATGEN/CMakeLists.txt +++ b/TESTING/MATGEN/CMakeLists.txt @@ -61,6 +61,7 @@ if(BUILD_INDEX64_EXT_API) set(BUILD_INDEX64_EXT_API OFF) set(BUILD_INDEX64_EXT_API OFF PARENT_SCOPE) else() + cmake_minimum_required(VERSION 3.18) set(SOURCES_64) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${TMGLIB}_64_obj) file(COPY ${SOURCES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${TMGLIB}_64_obj) From d638ddba42b5ed076b0f9f6fcfe5fd4ed3244032 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Wed, 5 Jun 2024 14:13:25 +0200 Subject: [PATCH 4/5] Disable `BUILD_INDEX64_EXT_API` by default if the CMake version is less than 3.18.0 --- CMakeLists.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dde033025..f5ed2ba325 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,9 +107,18 @@ else() set(LAPACKELIB "lapacke") set(TMGLIB "tmglib") endif() -# By default build extended _64 API for supported compilers only + +# By default build extended _64 API for supported compilers only. This needs +# CMake >= 3.18! Let's disable it by default for CMake < 3.18. +if(CMAKE_VERSION VERSION_LESS "3.18") + set(INDEX64_EXT_API_DEFAULT OFF) +else() + set(INDEX64_EXT_API_DEFAULT ON) +endif() set(INDEX64_EXT_API_COMPILERS "Intel|GNU") -option(BUILD_INDEX64_EXT_API "Build Index-64 API as extended API with _64 suffix (needs CMake >= 3.18)" ON) +option(BUILD_INDEX64_EXT_API + "Build Index-64 API as extended API with _64 suffix (needs CMake >= 3.18)" + ${INDEX64_EXT_API_DEFAULT}) message(STATUS "Build Index-64 API as extended API with _64 suffix: ${BUILD_INDEX64_EXT_API}") include(GNUInstallDirs) From 7159cfb377c9855bbc2eab0c7027c907b2e9d310 Mon Sep 17 00:00:00 2001 From: Simon Maertens Date: Tue, 11 Jun 2024 15:56:46 +0100 Subject: [PATCH 5/5] Fix Intel compiler flags which contain a space --- CMAKE/CheckLAPACKCompilerFlags.cmake | 4 ++-- TESTING/MATGEN/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMAKE/CheckLAPACKCompilerFlags.cmake b/CMAKE/CheckLAPACKCompilerFlags.cmake index 2cf62c18fa..d727caff3f 100644 --- a/CMAKE/CheckLAPACKCompilerFlags.cmake +++ b/CMAKE/CheckLAPACKCompilerFlags.cmake @@ -18,7 +18,7 @@ macro(CheckLAPACKCompilerFlags) if(WIN32) set(FOPT_ILP64 /integer-size:64) else() - set(FOPT_ILP64 "-integer-size 64") + set(FOPT_ILP64 "SHELL:-integer-size 64") endif() elseif((CMAKE_Fortran_COMPILER_ID STREQUAL "VisualAge") OR # CMake 2.6 (CMAKE_Fortran_COMPILER_ID STREQUAL "XL")) # CMake 2.8 @@ -61,7 +61,7 @@ macro(CheckLAPACKCompilerFlags) add_compile_options("$<$:-recursive>") if(UNIX) - add_compile_options("$<$:-fp-model strict>") + add_compile_options("$<$:SHELL:-fp-model strict>") endif() # SunPro F95 diff --git a/TESTING/MATGEN/CMakeLists.txt b/TESTING/MATGEN/CMakeLists.txt index 3866acc29c..02e05a86d4 100644 --- a/TESTING/MATGEN/CMakeLists.txt +++ b/TESTING/MATGEN/CMakeLists.txt @@ -74,7 +74,7 @@ if(BUILD_INDEX64_EXT_API) endforeach() file(COPY matgen_64.h DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${TMGLIB}_64_obj) add_library(${TMGLIB}_64_obj OBJECT ${SOURCES_64}) - target_compile_options(${TMGLIB}_64_obj PRIVATE ${FOPT_ILP64} -DMATGEN_64) + target_compile_options(${TMGLIB}_64_obj PRIVATE "${FOPT_ILP64}" -DMATGEN_64) set_target_properties( ${TMGLIB}_64_obj PROPERTIES POSITION_INDEPENDENT_CODE ON