Skip to content

Commit

Permalink
apacheGH-41652: [C++][CMake][Windows] Don't build needless object lib…
Browse files Browse the repository at this point in the history
…raries
  • Loading branch information
kou committed Jun 6, 2024
1 parent 164be48 commit fbd80c5
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,22 +200,29 @@ function(arrow_add_object_library PREFIX)
set(SOURCES ${ARGN})
string(TOLOWER "${PREFIX}" prefix)
if(WIN32)
add_library(${prefix}_shared OBJECT ${SOURCES})
add_library(${prefix}_static OBJECT ${SOURCES})
set_target_properties(${prefix}_shared PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(${prefix}_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${prefix}_shared PRIVATE ARROW_EXPORTING)
target_compile_definitions(${prefix}_static PRIVATE ARROW_STATIC)
target_compile_features(${prefix}_shared PRIVATE cxx_std_17)
target_compile_features(${prefix}_static PRIVATE cxx_std_17)
set(${PREFIX}_TARGET_SHARED
${prefix}_shared
PARENT_SCOPE)
set(${PREFIX}_TARGET_STATIC
${prefix}_static
PARENT_SCOPE)
set(targets)
if(ARROW_BUILD_SHARED)
add_library(${prefix}_shared OBJECT ${SOURCES})
set_target_properties(${prefix}_shared PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${prefix}_shared PRIVATE ARROW_EXPORTING)
target_compile_features(${prefix}_shared PRIVATE cxx_std_17)
set(${PREFIX}_TARGET_SHARED
${prefix}_shared
PARENT_SCOPE)
list(APPEND targets ${prefix}_shared)
endif()
if(ARROW_BUILD_STATIC)
add_library(${prefix}_static OBJECT ${SOURCES})
set_target_properties(${prefix}_static PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_compile_definitions(${prefix}_static PRIVATE ARROW_STATIC)
target_compile_features(${prefix}_static PRIVATE cxx_std_17)
set(${PREFIX}_TARGET_STATIC
${prefix}_static
PARENT_SCOPE)
list(APPEND targets ${prefix}_static)
endif()
set(${PREFIX}_TARGETS
${prefix}_shared ${prefix}_static
${targets}
PARENT_SCOPE)
else()
add_library(${prefix} OBJECT ${SOURCES})
Expand Down

0 comments on commit fbd80c5

Please sign in to comment.