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: Only search for OpenACC if the corresponding option is active #60

Merged
merged 1 commit into from
Sep 25, 2024
Merged
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
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,22 @@ elseif( FYPP MATCHES FYPP-NOTFOUND )
endif()

## find OpenACC
### Workaround for CMake bug (fixed in CMake 3.25)
find_package(OpenACC COMPONENTS Fortran)
if( OpenACC_Fortran_FOUND )
set( OpenACC_FOUND ON )
if( ${CMAKE_VERSION} VERSION_LESS "3.25" )
if ( FIELD_API_ENABLE_ACC OR (NOT DEFINED FIELD_API_ENABLE_ACC AND (ENABLE_ACC OR NOT DEFINED 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()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT ON
CONDITION OpenACC_FOUND )
DEFAULT ON
DESCRIPTION "Support for using GPUs with OpenACC"
REQUIRED_PACKAGES "OpenACC COMPONENTS Fortran" )

## set general compiler flags
include(cmake/field_api_compile_options.cmake)
Expand Down
Loading