Skip to content

Commit

Permalink
Use FILE_SET everywhere. Install missing headers and executables..
Browse files Browse the repository at this point in the history
This commit makes the PR more consistent and complete by:

* using the `FILE_SET` mechanism to install header files everywhere,
* installing all header files in the `include` folder (instead of only
  those used in the `export` folder),
* installing all targets added by `add_executable`,
* moving the `install(EXPORTS ...)` command to the top-level CMake file,
* fixing the installation path of the protobuf headers.
  • Loading branch information
ingomueller-net committed Mar 17, 2024
1 parent 8347198 commit 5075bf0
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@ if(${SUBSTRAIT_CPP_BUILD_TESTING})
enable_testing()
endif()

install(EXPORT SubstraitTargets DESTINATION lib/cmake/Substrait)

add_subdirectory(src/substrait)
add_subdirectory(export)
2 changes: 0 additions & 2 deletions export/planloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@ if(${SUBSTRAIT_CPP_BUILD_TESTING})
endif()

install(TARGETS planloader EXPORT SubstraitTargets)

install(EXPORT SubstraitTargets DESTINATION lib/cmake/Substrait)
12 changes: 7 additions & 5 deletions src/substrait/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# SPDX-License-Identifier: Apache-2.0

add_library(substrait_common Exceptions.cpp)
target_sources(
substrait_common PUBLIC FILE_SET HEADERS BASE_DIRS ../../../include/ FILES
../../../include/substrait/common/Exceptions.h)
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)
target_sources(substrait_io PUBLIC FILE_SET HEADERS BASE_DIRS ../../../include/
FILES ../../../include/substrait/common/Io.h)

add_dependencies(
substrait_io
Expand All @@ -32,7 +35,6 @@ add_executable(plantransformer PlanTransformerTool.cpp)
target_link_libraries(plantransformer substrait_io)

install(
TARGETS substrait_common substrait_io
TARGETS substrait_common substrait_io plantransformer
EXPORT SubstraitTargets
LIBRARY
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/common")
LIBRARY FILE_SET HEADERS)
9 changes: 8 additions & 1 deletion src/substrait/expression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# SPDX-License-Identifier: Apache-2.0

add_library(substrait_expression DecimalLiteral.cpp)
target_sources(
substrait_expression
PUBLIC FILE_SET HEADERS BASE_DIRS ../../../include/ FILES
../../../include/substrait/expression/DecimalLiteral.h)

target_link_libraries(substrait_expression substrait_proto absl::numeric
absl::strings)
Expand All @@ -9,4 +13,7 @@ if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_expression EXPORT SubstraitTargets)
install(
TARGETS substrait_expression
EXPORT SubstraitTargets
FILE_SET HEADERS)
16 changes: 15 additions & 1 deletion src/substrait/function/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@
set(FUNCTION_SRCS Function.cpp Extension.cpp FunctionLookup.cpp)

add_library(substrait_function ${FUNCTION_SRCS})
target_sources(
substrait_function
PUBLIC FILE_SET
HEADERS
BASE_DIRS
../../../include/
FILES
../../../include/substrait/function/Extension.h
../../../include/substrait/function/Function.h
../../../include/substrait/function/FunctionLookup.h
../../../include/substrait/function/FunctionSignature.h)

target_link_libraries(substrait_function substrait_type yaml-cpp)

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

install(TARGETS substrait_function EXPORT SubstraitTargets)
install(
TARGETS substrait_function
EXPORT SubstraitTargets
FILE_SET HEADERS)
17 changes: 11 additions & 6 deletions src/substrait/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ foreach(PROTO_FILE IN LISTS PROTOBUF_FILELIST)
endforeach()

# Add the generated protobuf C++ files to our exported library.
add_library(substrait_proto ${PROTO_SRCS} ${PROTO_HDRS} ProtoUtils.cpp
ProtoUtils.h)
add_library(substrait_proto ${PROTO_SRCS} ${PROTO_HDRS} ProtoUtils.cpp)
target_sources(
substrait_proto PUBLIC FILE_SET HEADERS BASE_DIRS
${PROTO_OUTPUT_TOPLEVEL_DIR} FILES ${PROTO_HDRS})
substrait_proto
PUBLIC FILE_SET
HEADERS
BASE_DIRS
${PROTO_OUTPUT_TOPLEVEL_DIR}/src
../..
FILES
${PROTO_HDRS}
ProtoUtils.h)

# Include the protobuf library as a dependency to use this class.
target_link_libraries(substrait_proto protobuf::libprotobuf)
Expand All @@ -97,5 +103,4 @@ target_include_directories(
install(
TARGETS substrait_proto
EXPORT SubstraitTargets
LIBRARY FILE_SET HEADERS
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/proto")
LIBRARY FILE_SET HEADERS)
5 changes: 3 additions & 2 deletions src/substrait/textplan/converter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,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)
install(TARGETS planconverter substrait_textplan_converter
substrait_base_proto_visitor substrait_textplan_normalizer
EXPORT SubstraitTargets)
2 changes: 1 addition & 1 deletion src/substrait/textplan/parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ if(${SUBSTRAIT_CPP_BUILD_TESTING})
add_subdirectory(tests)
endif()

install(TARGETS substrait_textplan_loader EXPORT SubstraitTargets)
install(TARGETS planparser substrait_textplan_loader EXPORT SubstraitTargets)
8 changes: 7 additions & 1 deletion src/substrait/type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
set(TYPE_SRCS Type.cpp)

add_library(substrait_type ${TYPE_SRCS})
target_sources(
substrait_type PUBLIC FILE_SET HEADERS BASE_DIRS ../../../include/ FILES
../../../include/substrait/type/Type.h)

target_link_libraries(substrait_type substrait_common)

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

install(TARGETS substrait_type EXPORT SubstraitTargets)
install(
TARGETS substrait_type
EXPORT SubstraitTargets
FILE_SET HEADERS)

0 comments on commit 5075bf0

Please sign in to comment.