Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake fixes for test linker and OpenACC search #156

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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_<LANG>_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_<LANG>_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()

Expand Down
11 changes: 6 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
Expand All @@ -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 )
Expand Down
Loading