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)
-fvisibility=hidden
or-fvisibility=internal
__attribute__((visibility("default")))
Example