Skip to content

Commit

Permalink
feat: Make main target installable.
Browse files Browse the repository at this point in the history
This allows to run `cmake --install .` to install the project to a
system such that it can be consumed with `find_package()`. This required
the following changes:

* Include all targets in the `install(TARGETS ...)` command.
* Export these targets to an export set.
* `install(EXPORT ...)` that export set.
* Provide install-time paths for several `target_include_directories()`,
  some of which are empty because the headers are not installed.
  • Loading branch information
ingomueller-net committed Mar 15, 2024
1 parent 579d884 commit e0848a9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/substrait/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
set(ADDITIONAL_CLEAN_FILES
"${CMAKE_ARCHIVE_OUTPUT_DIRECTORY};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")

add_subdirectory(common)
add_subdirectory(type)
add_subdirectory(expression)
add_subdirectory(function)
add_subdirectory(proto)
add_subdirectory(textplan)
add_subdirectory(common)
16 changes: 15 additions & 1 deletion src/substrait/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,23 @@ if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_io LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(
TARGETS 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
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT SubstraitTargets)
install(FILES ../../../include/substrait/common/Io.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/common")
install(EXPORT SubstraitTargets DESTINATION lib/cmake/Substrait)

add_executable(plantransformer PlanTransformerTool.cpp)

Expand Down
6 changes: 4 additions & 2 deletions src/substrait/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,7 @@ target_link_libraries(substrait_proto protobuf::libprotobuf)
# Make sure we can see our own generated include files.
target_include_directories(
substrait_proto
PUBLIC "${PROTO_OUTPUT_TOPLEVEL_DIR}/src"
PUBLIC "${protobuf_SOURCE_DIR}/src")
PUBLIC $<BUILD_INTERFACE:${PROTO_OUTPUT_TOPLEVEL_DIR}/src>
$<INSTALL_INTERFACE:include>
PUBLIC $<BUILD_INTERFACE:${protobuf_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>)
4 changes: 2 additions & 2 deletions src/substrait/textplan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ target_link_libraries(
date::date)

# Provide access to the generated protobuffer headers hierarchy.
target_include_directories(symbol_table
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/../..")
target_include_directories(
symbol_table PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../..>)

if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
Expand Down
5 changes: 3 additions & 2 deletions src/substrait/textplan/parser/grammar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ add_library(textplan_grammar ${ANTLR_SubstraitPlanLexer_CXX_OUTPUTS}

message(STATUS "generated dir: ${GRAMMAR_DIR}/antlr4cpp_generated_src")

target_include_directories(textplan_grammar
PUBLIC "${GRAMMAR_DIR}/antlr4cpp_generated_src")
target_include_directories(
textplan_grammar
PUBLIC $<BUILD_INTERFACE:${GRAMMAR_DIR}/antlr4cpp_generated_src>)

target_link_libraries(textplan_grammar antlr4_static)

0 comments on commit e0848a9

Please sign in to comment.