8000 Support for BUILD_OBJECT_LIBS by jrmadsen · Pull Request #28 · jrmadsen/PTL · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support for BUILD_OBJECT_LIBS #28

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

Merged
merged 1 commit into from
Mar 3, 2022
Merged

Support for BUILD_OBJECT_LIBS #28

merged 1 commit into from
Mar 3, 2022

Conversation

jrmadsen
Copy link
Owner
@jrmadsen jrmadsen commented Mar 3, 2022
  • when PTL is a cmake subproject, it can be useful to build an object library so that compiled translation units can be treated as part of the library using PTL
    • E.g. when parent cmake project compiles with -fvisibility=hidden or -fvisibility=internal
    • In subproject mode, this eliminates the need to compile all of PTL with default visibility or decorating PTL functions/classes with __attribute__((visibility("default")))
  • Bump version to 2.3.2

Example

set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

# ...

# these will be propagated down to PTL
set(BUILD_SHARED_LIBS OFF)
set(BUILD_STATIC_LIBS OFF)
set(BUILD_OBJECT_LIBS ON)

add_subdirectory(external/PTL)

# create an interface lib for using PTL
add_library(foo-ptl INTERFACE)
# provide ptl object files as sources
target_sources(foo-ptl INTERFACE $<TARGET_OBJECTS:PTL::ptl-object>)
# propagate the include dirs, etc.
target_link_libraries(foo-ptl INTERFACE PTL::ptl-object)

# ...

add_library(foo SHARED)
target_link_libraries(foo PRIVATE foo-ptl)

- when PTL is a subproject, it can be useful to build an object library
  which can be directly linked into code
- this is useful when parent project compiles with -fvisibility=hidden
- Bump version to 2.3.2
@jrmadsen jrmadsen merged commit 4afd2bd into master Mar 3, 2022
@jrmadsen jrmadsen deleted the build-object-libs branch March 3, 2022 20:56
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

Successfully merging this pull request may close these issues.

1 participant
0