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

Improve the way we describe the way to create plugin libraries. #5926

Open
bangerth opened this issue Jun 19, 2024 · 0 comments
Open

Improve the way we describe the way to create plugin libraries. #5926

bangerth opened this issue Jun 19, 2024 · 0 comments

Comments

@bangerth
Copy link
Contributor

Working on #5836 shows that we create plugins in, let's say, an awkward way. In the user's CMakeLists.txt, we do

ADD_LIBRARY(${TARGET} SHARED prescribed_velocity_ascii_data.cc)
ASPECT_SETUP_PLUGIN(${TARGET})

and then (after #5836) we have to wire up the so-created library a second time in AspectConfig.cmake:

  # We create lib${_target}.debug.so, lib${_target}.release.so, or both
  # depending on the compilation mode of ASPECT. Note that the user already
  # created the target under the name ${_target}, so we only need to create
  # a second target in the third case above.
  # Note that you can not rename a target or change its filename, but you can
  # modify the suffix. :-)

  if(${ASPECT_BUILD_DEBUG} MATCHES "ON")
    message(STATUS "  setting up DEBUG variant")
    deal_ii_setup_target(${_target} DEBUG)
    set_target_properties(${_target} PROPERTIES SUFFIX ".debug.so")

    list(APPEND _target_libs ${_target})
  endif()

  if(${ASPECT_BUILD_RELEASE} MATCHES "ON")
    message(STATUS "  setting up RELEASE variant")
    add_library(${_target}.release SHARED $<TARGET_PROPERTY:${_target},SOURCES>)      # ***************
    deal_ii_setup_target(${_target}.release RELEASE)
    set_target_properties(${_target}.release PROPERTIES SUFFIX ".so")

    list(APPEND _target_libs ${_target}.release)
  endif()

  ... much more...

The issue is with the marked line: We have to create a second library, having previously assumed that the first library created in user space is actually the debug one. That may not be true with CMAKE_BUILD_TYPE=Release when called in the user directory.

A much better approach would have been to create a macro ASPECT_SETUP_PLUGIN_LIBRARY(_target _source_files) that automatically decides what the library (or libraries) should be called, what its (their) properties should be, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant