10000 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
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.3.2
22 changes: 18 additions & 4 deletions cmake/Modules/PTLBuildSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,24 @@ endif()
# -------------------------------------------------------------------------------------- #
ptl_add_option(BUILD_STATIC_LIBS "Build static library" ON)
ptl_add_option(BUILD_SHARED_LIBS "Build shared library" ON)
if((NOT BUILD_SHARED_LIBS) AND (NOT BUILD_STATIC_LIBS))
message(
FATAL_ERROR
"Neither BUILD_STATIC_LIBS nor BUILD_SHARED 8000 _LIBS are set. One must be ON")

if(NOT "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}")
ptl_add_option(BUILD_OBJECT_LIBS "Build object library (only valid as subproject)"
OFF)
set(PTL_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
set(PTL_BUILD_LIBS_ERROR_DESC
"BUILD_STATIC_LIBS, BUILD_SHARED_LIBS, and BUILD_OBJECT_LIBS are all OFF")
else()
set(BUILD_OBJECT_LIBS OFF)
set(PTL_EXCLUDE_FROM_ALL)
set(PTL_BUILD_LIBS_ERROR_DESC
"Neither BUILD_STATIC_LIBS nor BUILD_SHARED_LIBS are set")
endif()

if((NOT BUILD_SHARED_LIBS)
AND (NOT BUILD_STATIC_LIBS)
AND (NOT BUILD_OBJECT_LIBS))
message(FATAL_ERROR "${PTL_BUILD_LIBS_ERROR_DESC}. One must be ON")
endif()

# -------------------------------------------------------------------------------------- #
Expand Down
33 changes: 19 additions & 14 deletions cmake/Modules/PTLCMakeUtilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@ function(ptl_build_library)
set(LIB_OUTPUT_NAME ${LIB_TARGET_NAME})
endif()

add_library(${LIB_TARGET_NAME} ${LIB_TYPE} ${LIB_SOURCES})
add_library(${LIB_TARGET_NAME} ${LIB_TYPE} ${PTL_EXCLUDE_FROM_ALL})

add_library(${PROJECT_NAME}::${LIB_TARGET_NAME} ALIAS ${LIB_TARGET_NAME})

set_target_properties(
${LIB_TARGET_NAME}
PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME}
VERSION ${${PROJECT_NAME}_VERSION}
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
WINDOWS_EXPORT_ALL_SYMBOLS ON)
target_sources(${LIB_TARGET_NAME} PRIVATE ${LIB_SOURCES})

target_compile_definitions(${LIB_TARGET_NAME} PRIVATE $<$<CONFIG:Debug>:DEBUG>)

Expand All @@ -106,12 +102,21 @@ function(ptl_build_library)
$<$<COMPILE_LANGUAGE:CXX>:${${PROJECT_NAME}_CXX_FLAGS}>)
endif()

set_target_properties(
${LIB_TARGET_NAME}
PROPERTIES OUTPUT_NAME ${LIB_OUTPUT_NAME}
VERSION ${${PROJECT_NAME}_VERSION}
SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}
WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Install the targets and export libraries
install(
TARGETS ${LIB_TARGET_NAME}
EXPORT ${PROJECT_NAME}Targets
COMPONENT Development
ARCHIVE DESTINATION ${PTL_INSTALL_LIBDIR}
LIBRARY DESTINATION ${PTL_INSTALL_LIBDIR}
RUNTIME DESTINATION ${PTL_INSTALL_BINDIR})
if(NOT "${LIB_TYPE}" STREQUAL "OBJECT")
install(
TARGETS ${LIB_TARGET_NAME}
EXPORT ${PROJECT_NAME}Targets
COMPONENT Development
ARCHIVE DESTINATION ${PTL_INSTALL_LIBDIR}
LIBRARY DESTINATION ${PTL_INSTALL_LIBDIR}
RUNTIME DESTINATION ${PTL_INSTALL_BINDIR} OPTIONAL)
endif()
endfunction()
26 changes: 22 additions & 4 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -------------------------------------------------------------------------------------- #
# # General # #
# General
# -------------------------------------------------------------------------------------- #
# Locate sources and headers for this project - headers are included so they will show up
# in IDEs
Expand All @@ -8,7 +8,7 @@ file(GLOB_RECURSE ptl_headers ${CMAKE_CURRENT_LIST_DIR}/PTL/*.hh
file(GLOB_RECURSE ptl_sources ${CMAKE_CURRENT_LIST_DIR}/*.cc)

# -------------------------------------------------------------------------------------- #
# # Config, Version # #
# Config, Version
# -------------------------------------------------------------------------------------- #

configure_file(${PROJECT_SOURCE_DIR}/cmake/Templates/Config.hh.in
Expand All @@ -22,9 +22,27 @@ configure_file(${PROJECT_SOURCE_DIR}/cmake/Templates/Version.hh.in
list(APPEND ptl_headers ${CMAKE_CURRENT_BINARY_DIR}/PTL/Version.hh)

# -------------------------------------------------------------------------------------- #
# # PTL Library # #
# PTL Library
# -------------------------------------------------------------------------------------- #

if(BUILD_OBJECT_LIBS)

ptl_build_library(
TYPE OBJECT
TARGET_NAME ptl-object
OUTPUT_NAME ptl
SOURCES ${ptl_headers} ${ptl_sources})

target_link_libraries(ptl-object PUBLIC Threads::Threads)
if(PTL_USE_TBB)
target_link_libraries(ptl-object PUBLIC TBB::tbb)
endif()

target_include_directories(
ptl-object PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
endif()

if(BUILD_SHARED_LIBS)

ptl_build_library(
Expand Down Expand Up @@ -82,7 +100,7 @@ if(BUILD_STATIC_LIBS)
endif()

# -------------------------------------------------------------------------------------- #
# # Installation # #
# Installation
# -------------------------------------------------------------------------------------- #

if(PTL_INSTALL_CONFIG)
Expand Down
0