Skip to content
Open
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
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ add_subdirectory(src)

## determine lib type
cmake_dependent_option(BUILD_SHARED_LIBS "Dynamically link field_api" ON "NOT (HAVE_ACC OR HAVE_OMP_OFFLOAD)" OFF)
if( HAVE_ACC OR HAVE_OMP_OFFLOAD )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @pmarguinaud for testing and contributing this, it's great to be able to have shared libs with offload enabled. This is ok in principle, but it removes the ability for the user to manually ask for static builds. I propose something like this instead:

set( SHARED_LIBS_FOR_OFFLOAD_DEFAULT OFF )
if( CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC" AND
    CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 25.7.0)
    set( SHARED_LIBS_FOR_OFFLOAD_DEFAULT ON )
endif()
cmake_dependent_option(BUILD_SHARED_LIBS "Dynamically link field_api" ON "NOT (HAVE_ACC OR HAVE_OMP_OFFLOAD)" ${SHARED_LIBS_FOR_OFFLOAD_DEFAULT})

if( (HAVE_ACC OR HAVE_OMP_OFFLOAD) AND NOT ${SHARED_LIBS_FOR_OFFLOAD_DEFAULT} )
  ecbuild_warn("Enabling GPU offload forces static linking.")
endif()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello Ahmad,

I agree with you, what you propose makes sense. Do you want me to change my pull request, or will you arrange that yourself ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Philippe,

Thanks for the feedback, I'm happy to fix it myself.

if (CMAKE_Fortran_COMPILER_ID MATCHES "PGI|NVHPC")
if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 25.7.0)
ecbuild_warn ("NVHPC >= 25.7.0 can build shared libraries with OpenACC")
set (BUILD_SHARED_LIBS ON)
endif ()
endif ()

if( NOT BUILD_SHARED_LIBS )
ecbuild_warn("Enabling GPU offload forces static linking.")
endif()

Expand Down
Loading