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

Allow to call find_package(rerun_sdk) two or more times #5886

Merged
merged 1 commit into from
Apr 10, 2024
Merged
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
50 changes: 29 additions & 21 deletions rerun_cpp/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ include("${CMAKE_CURRENT_LIST_DIR}/rerun_sdkTargets.cmake")
set(RERUN_LIB_DIR "${CMAKE_CURRENT_LIST_DIR}/../..")

if(@RERUN_INSTALL_RERUN_C@)
# Setup `rerun_c` (imported libraries can't be exported!)
add_library(rerun_c STATIC IMPORTED GLOBAL)
get_filename_component(RERUN_C_LIB_NAME "@RERUN_C_LIB_LOCATION@" NAME)
set_target_properties(rerun_c PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_C_LIB_NAME}")
if(APPLE)
target_link_libraries(rerun_c INTERFACE "-framework CoreFoundation" "-framework IOKit")
elseif(UNIX) # if(LINUX) # CMake 3.25
target_link_libraries(rerun_c INTERFACE "-lm -ldl -pthread")
elseif(WIN32)
target_link_libraries(rerun_c INTERFACE ws2_32.dll Bcrypt.dll Userenv.dll ntdll.dll)
if(NOT TARGET rerun_c)
# Setup `rerun_c` (imported libraries can't be exported!)
add_library(rerun_c STATIC IMPORTED GLOBAL)
get_filename_component(RERUN_C_LIB_NAME "@RERUN_C_LIB_LOCATION@" NAME)
set_target_properties(rerun_c PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_C_LIB_NAME}")
if(APPLE)
target_link_libraries(rerun_c INTERFACE "-framework CoreFoundation" "-framework IOKit")
elseif(UNIX) # if(LINUX) # CMake 3.25
target_link_libraries(rerun_c INTERFACE "-lm -ldl -pthread")
elseif(WIN32)
target_link_libraries(rerun_c INTERFACE ws2_32.dll Bcrypt.dll Userenv.dll ntdll.dll)
endif()
endif()
endif()

Expand All @@ -23,15 +25,19 @@ endif()
if(@RERUN_DOWNLOAD_AND_BUILD_ARROW@ AND NOT @RERUN_ARROW_LINK_SHARED@)
message(STATUS "Rerun is using bundled arrow library.")

add_library(rerun_arrow_target STATIC IMPORTED GLOBAL)
get_filename_component(RERUN_ARROW_LIB_NAME "@RERUN_ARROW_LIBRARY_FILE@" NAME)
set_target_properties(rerun_arrow_target PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_ARROW_LIB_NAME}")
if(NOT TARGET rerun_arrow_target)
add_library(rerun_arrow_target STATIC IMPORTED GLOBAL)
get_filename_component(RERUN_ARROW_LIB_NAME "@RERUN_ARROW_LIBRARY_FILE@" NAME)
set_target_properties(rerun_arrow_target PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_ARROW_LIB_NAME}")
endif()

# We have to explicitly opt in the arrow bundled dependencies, otherwise we're missing the symbols for mimalloc.
add_library(arrow_targetBundledDeps STATIC IMPORTED)
get_filename_component(RERUN_ARROW_DEPS_LIB_NAME "@RERUN_ARROW_BUNDLED_DEPENDENCIES_FILE@" NAME)
set_target_properties(arrow_targetBundledDeps PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_ARROW_DEPS_LIB_NAME}")
target_link_libraries(rerun_arrow_target INTERFACE arrow_targetBundledDeps)
if(NOT TARGET arrow_targetBundledDeps)
add_library(arrow_targetBundledDeps STATIC IMPORTED)
get_filename_component(RERUN_ARROW_DEPS_LIB_NAME "@RERUN_ARROW_BUNDLED_DEPENDENCIES_FILE@" NAME)
set_target_properties(arrow_targetBundledDeps PROPERTIES IMPORTED_LOCATION "${RERUN_LIB_DIR}/${RERUN_ARROW_DEPS_LIB_NAME}")
target_link_libraries(rerun_arrow_target INTERFACE arrow_targetBundledDeps)
endif()
else()
if(@RERUN_DOWNLOAD_AND_BUILD_ARROW@ AND @RERUN_ARROW_LINK_SHARED@)
message(WARNING
Expand All @@ -45,9 +51,11 @@ else()

message(STATUS "Rerun is using a system installed libArrow.")

if(@RERUN_ARROW_LINK_SHARED@)
add_library(rerun_arrow_target ALIAS Arrow::arrow_shared)
else()
add_library(rerun_arrow_target ALIAS Arrow::arrow_static)
if(NOT TARGET rerun_arrow_target)
if(@RERUN_ARROW_LINK_SHARED@)
add_library(rerun_arrow_target ALIAS Arrow::arrow_shared)
else()
add_library(rerun_arrow_target ALIAS Arrow::arrow_static)
endif()
endif()
endif()
Loading