From 81bd1f4951e1557a687f1c416b355c5a36aa5982 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Tue, 24 Sep 2024 11:37:34 +0200 Subject: [PATCH 1/2] Use Fortran linker for ectrans_test_setup_trans0 --- tests/CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6fa0e061..9ba9cfe5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,7 +32,7 @@ if( HAVE_TESTS ) endif() if( NOT HAVE_DOUBLE_PRECISION ) list( APPEND _test_args "-DCOMPONENTS=single" ) - endif() + endif() add_test( NAME ectrans_test_install COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-install.sh ${_test_args} ) @@ -46,10 +46,11 @@ if( HAVE_TESTS ) endif() ecbuild_add_executable( - TARGET ectrans_test_setup_trans0 - SOURCES trans/test_setup_trans0.F90 - LIBS ectrans_common - NOINSTALL) + TARGET ectrans_test_setup_trans0 + SOURCES trans/test_setup_trans0.F90 + LIBS ectrans_common + LINKER_LANGUAGE Fortran + NOINSTALL) set( ntasks 0 ) if( HAVE_MPI ) list( APPEND ntasks 1 2 ) From c3db3f6ab32bc484a96199934515b604ab63ac26 Mon Sep 17 00:00:00 2001 From: Balthasar Reuter Date: Tue, 24 Sep 2024 11:37:57 +0200 Subject: [PATCH 2/2] Search for OpenACC only if explicitly enabled --- CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1da7151a..e2c5b8e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,14 +34,16 @@ ecbuild_add_option( FEATURE OMP DESCRIPTION "Support for OpenMP shared memory parallelism" REQUIRED_PACKAGES "OpenMP COMPONENTS Fortran" ) -if( ${CMAKE_VERSION} VERSION_LESS "3.25" AND (NOT DEFINED ENABLE_ACC OR ENABLE_ACC ) ) - # See https://gitlab.kitware.com/cmake/cmake/-/issues/23691, fixed in CMake 3.25 - # (TL;DR: FindOpenACC sets OpenACC__FOUND correctly but does not set - # OpenACC_FOUND unless all three C, CXX, and Fortran have been found - even if - # only one language has been requested via COMPONENTS) - find_package( OpenACC COMPONENTS Fortran ) - if( OpenACC_Fortran_FOUND ) - set( OpenACC_FOUND ON ) +if( ${CMAKE_VERSION} VERSION_LESS "3.25" ) + if ( ECTRANS_ENABLE_ACC OR (NOT DEFINED ECTRANS_ENABLE_ACC AND ENABLE_ACC) ) + # See https://gitlab.kitware.com/cmake/cmake/-/issues/23691, fixed in CMake 3.25 + # (TL;DR: FindOpenACC sets OpenACC__FOUND correctly but does not set + # OpenACC_FOUND unless all three C, CXX, and Fortran have been found - even if + # only one language has been requested via COMPONENTS) + find_package( OpenACC COMPONENTS Fortran ) + if( OpenACC_Fortran_FOUND ) + set( OpenACC_FOUND ON ) + endif() endif() endif()