Skip to content

Commit

Permalink
Reorganize install commands: move to respective add_library command.
Browse files Browse the repository at this point in the history
Since the install command needs library-specific knowledge, such as the
install path of the public header files, in the end, I think that's the
better place to put them.
  • Loading branch information
ingomueller-net committed Mar 16, 2024
1 parent 0ed4fb7 commit 4b3a564
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 18 deletions.
22 changes: 4 additions & 18 deletions export/planloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,10 @@ add_library(planloader SHARED planloader.cpp)
add_dependencies(planloader substrait_io)
target_link_libraries(planloader substrait_io)

install(
TARGETS planloader
substrait_io
substrait_common
substrait_proto
substrait_textplan_converter
substrait_textplan_loader
substrait_base_proto_visitor
symbol_table
error_listener
substrait_type
substrait_expression
textplan_grammar
EXPORT SubstraitTargets)
install(FILES ../../include/substrait/common/Io.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/common")
install(EXPORT SubstraitTargets DESTINATION lib/cmake/Substrait)

if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS planloader EXPORT SubstraitTargets)

install(EXPORT SubstraitTargets DESTINATION lib/cmake/Substrait)
9 changes: 9 additions & 0 deletions src/substrait/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ add_library(substrait_common Exceptions.cpp)
target_link_libraries(substrait_common fmt::fmt-header-only)

add_library(substrait_io STATIC Io.cpp)
set_target_properties(
substrait_io PROPERTIES PUBLIC_HEADER ../../../include/substrait/common/Io.h)

add_dependencies(
substrait_io
substrait_proto
Expand All @@ -27,3 +30,9 @@ endif()
add_executable(plantransformer PlanTransformerTool.cpp)

target_link_libraries(plantransformer substrait_io)

install(
TARGETS substrait_common substrait_io
EXPORT SubstraitTargets
LIBRARY
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/common")
2 changes: 2 additions & 0 deletions src/substrait/expression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ target_link_libraries(substrait_expression substrait_proto absl::numeric
if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_expression EXPORT SubstraitTargets)
2 changes: 2 additions & 0 deletions src/substrait/function/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ target_link_libraries(substrait_function substrait_type yaml-cpp)
if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_function EXPORT SubstraitTargets)
7 changes: 7 additions & 0 deletions src/substrait/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ endforeach()
# Add the generated protobuf C++ files to our exported library.
add_library(substrait_proto ${PROTO_SRCS} ${PROTO_HDRS} ProtoUtils.cpp
ProtoUtils.h)
set_target_properties(substrait_proto PROPERTIES PUBLIC_HEADER "${PROTO_HDRS}")

# Include the protobuf library as a dependency to use this class.
target_link_libraries(substrait_proto protobuf::libprotobuf)
Expand All @@ -90,3 +91,9 @@ target_include_directories(
$<INSTALL_INTERFACE:include>
PUBLIC $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)

install(
TARGETS substrait_proto
EXPORT SubstraitTargets
LIBRARY
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/proto")
3 changes: 3 additions & 0 deletions src/substrait/textplan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ target_include_directories(
if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS error_listener parse_result symbol_table
EXPORT SubstraitTargets)
3 changes: 3 additions & 0 deletions src/substrait/textplan/converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ add_library(substrait_textplan_normalizer ${NORMALIZER_SRCS})

target_link_libraries(substrait_textplan_normalizer
substrait_textplan_converter)

install(TARGETS substrait_textplan_converter substrait_base_proto_visitor
substrait_textplan_normalizer EXPORT SubstraitTargets)
2 changes: 2 additions & 0 deletions src/substrait/textplan/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ target_link_libraries(planparser substrait_textplan_loader error_listener)
if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_textplan_loader EXPORT SubstraitTargets)
2 changes: 2 additions & 0 deletions src/substrait/textplan/parser/grammar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ target_include_directories(
PUBLIC $<BUILD_INTERFACE:${GRAMMAR_DIR}/antlr4cpp_generated_src>)

target_link_libraries(textplan_grammar antlr4_static)

install(TARGETS textplan_grammar EXPORT SubstraitTargets)
2 changes: 2 additions & 0 deletions src/substrait/type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ target_link_libraries(substrait_type substrait_common)
if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_type EXPORT SubstraitTargets)
4 changes: 4 additions & 0 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: Apache-2.0

# Ensure `option()` in subdirectories honors normal variables set here.
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

set(ABSL_ENABLE_INSTALL ON)
if(NOT ${ABSL_INCLUDED_WITH_PROTOBUF})
set(ABSL_PROPAGATE_CXX_STD ON)
Expand Down Expand Up @@ -27,6 +30,7 @@ set(BUILD_TESTING OFF)
add_subdirectory(protobuf-matchers)
set(BUILD_TESTING ${PREVIOUS_BUILD_TESTING})

set(YAML_CPP_INSTALL ON)
set(YAML_CPP_BUILD_TESTS
OFF
CACHE BOOL "Enable testing")
Expand Down

0 comments on commit 4b3a564

Please sign in to comment.