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 (apache#41658)

### Rationale for this change

* We don't need an object library for a shared library with `ARROW_BUILD_SHARED=OFF`.
* We don't need an object library for a static library with `ARROW_BUILD_STATIC=OFF`.

### What changes are included in this PR?

Don't build needless object libraries based on `ARROW_BUILD_SHARED`/`ARROW_BUILD_STATIC`.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#41652

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Jun 7, 2024
1 parent a708fab commit 290e606
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 290e606

Please sign in to comment.