Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions CMake/VeloxConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

block()
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

if("@Arrow_SOURCE@" STREQUAL "SYSTEM")
find_dependency(Arrow)
endif()
if("@Boost_SOURCE@" STREQUAL "SYSTEM")
find_dependency(Boost COMPONENTS "@BOOST_INCLUDE_LIBRARIES@")
endif()
find_dependency(double-conversion)
if("@folly_SOURCE@" STREQUAL "SYSTEM")
find_dependency(folly)
endif()
if("@fmt_SOURCE@" STREQUAL "SYSTEM")
find_dependency(fmt)
endif()
if("@gflags_SOURCE@" STREQUAL "SYSTEM")
find_dependency(gflags)
endif()
if("@glog_SOURCE@" STREQUAL "SYSTEM")
find_dependency(glog)
endif()
if("@VELOX_ENABLE_COMPRESSION_LZ4@")
find_dependency(lz4)
endif()
if("@Protobuf_SOURCE@" STREQUAL "SYSTEM")
find_dependency(Protobuf)
endif()
if("@re2_SOURCE@" STREQUAL "SYSTEM")
find_dependency(re2)
endif()
if("@stemmer_SOURCE@" STREQUAL "SYSTEM")
find_dependency(stemmer)
endif()
if("@VELOX_BUILD_MINIMAL_WITH_DWIO@" OR "@VELOX_ENABLE_HIVE_CONNECTOR@")
find_dependency(Snappy)
find_dependency(ZLIB)
find_dependency(zstd)
endif()
if("@simdjson_SOURCE@" STREQUAL "SYSTEM")
find_dependency(simdjson)
endif()
if("@THRIFT_SOURCE@" STREQUAL "SYSTEM")
find_dependency(Thrift)
endif()
if("@xsimd_SOURCE@" STREQUAL "SYSTEM")
find_dependency(xsimd)
endif()
endblock()

include("${CMAKE_CURRENT_LIST_DIR}/VeloxTargets.cmake")

check_required_components(Velox)
53 changes: 51 additions & 2 deletions CMake/VeloxUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
include_guard(GLOBAL)

include(CMakePackageConfigHelpers)

function(velox_get_rpath_origin VAR)
if(APPLE)
set(_origin @loader_path)
Expand Down Expand Up @@ -89,7 +92,9 @@ function(velox_add_library TARGET)
if(TARGET velox)
# Target already exists, append sources to it.
target_sources(velox PRIVATE ${ARGN})
install(TARGETS velox LIBRARY DESTINATION pyvelox COMPONENT pyvelox_libraries)
if(VELOX_BUILD_PYTHON_PACKAGE)
install(TARGETS velox LIBRARY DESTINATION pyvelox COMPONENT pyvelox_libraries)
endif()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. This is not an intended change. I'll revert this.

We should work on this as #14756 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted.

else()
set(_type STATIC)
if(VELOX_BUILD_SHARED)
Expand All @@ -99,7 +104,51 @@ function(velox_add_library TARGET)
add_library(velox ${_type} ${ARGN})
set_target_properties(velox PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set_target_properties(velox PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
install(TARGETS velox DESTINATION lib/velox)
install(TARGETS velox DESTINATION lib/velox EXPORT velox_targets)
if(VELOX_BUILD_CMAKE_PACKAGE)
set(package_cmake_dir "lib/cmake/Velox")
set(config_cmake_in "${PROJECT_SOURCE_DIR}/CMake/VeloxConfig.cmake.in")
set(config_cmake "${PROJECT_BINARY_DIR}/CMake/VeloxConfig.cmake")
configure_package_config_file(
"${config_cmake_in}"
"${config_cmake}"
INSTALL_DESTINATION "${package_cmake_dir}"
)
install(FILES "${config_cmake}" DESTINATION "${package_cmake_dir}")
set(system_dependencies)
if(glog_SOURCE STREQUAL "SYSTEM")
list(APPEND system_dependencies glog)
endif()
if(VELOX_ENABLE_COMPRESSION_LZ4)
list(APPEND system_dependencies lz4)
endif()
if(re2_SOURCE STREQUAL "SYSTEM")
list(APPEND system_dependencies re2)
endif()
if(stemmer_SOURCE STREQUAL "SYSTEM")
list(APPEND system_dependencies stemmer)
endif()
if(VELOX_BUILD_MINIMAL_WITH_DWIO OR VELOX_ENABLE_HIVE_CONNECTOR)
list(APPEND system_dependencies Snappy zstd)
endif()
foreach(system_dependency ${system_dependencies})
install(
FILES "${PROJECT_SOURCE_DIR}/CMake/Find${system_dependency}.cmake"
DESTINATION "${package_cmake_dir}"
)
endforeach()
# TODO: We can enable this once we add version to Velox.
# set(version_cmake "${PROJECT_BINARY_DIR}/CMake/VeloxConfigVersion.cmake")
# write_basic_package_version_file("${version_cmake}"
# COMPATIBILITY SameMajorVersion)
# install(FILES "${version_cmake}" DESTINATION "${package_cmake_dir}")
install(
EXPORT velox_targets
DESTINATION "${package_cmake_dir}"
NAMESPACE "Velox::"
FILE "VeloxTargets.cmake"
)
endif()
endif()
# create alias for compatability
if(NOT TARGET ${TARGET})
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ option(
option(VELOX_MONO_LIBRARY "Build single unified library." OFF)
option(ENABLE_ALL_WARNINGS "Enable -Wall and -Wextra compiler warnings." ON)
option(VELOX_BUILD_SHARED "Build Velox as shared libraries." OFF)
option(VELOX_BUILD_CMAKE_PACKAGE "Build CMake package for Velox." OFF)
option(VELOX_SKIP_WAVE_BRANCH_KERNEL_TEST "Disable Wave branch kernel test." OFF)
# While it's possible to build both in one go we currently want to build either
# static or shared.
Expand Down Expand Up @@ -193,6 +194,14 @@ if(${VELOX_BUILD_MINIMAL} OR ${VELOX_BUILD_MINIMAL_WITH_DWIO})
set(VELOX_ENABLE_S3 OFF)
set(VELOX_ENABLE_GCS OFF)
set(VELOX_ENABLE_ABFS OFF)
else()
if(VELOX_BUILD_CMAKE_PACKAGE)
message(
FATAL_ERROR
"VELOX_BUILD_CMAKE_PACKAGE is only available with "
"VELOX_BUILD_MINIMAL=ON or VELOX_BUILD_MINIMAL_WITH_DWIO=ON for now."
)
endif()
endif()

if(${VELOX_ENABLE_BENCHMARKS})
Expand Down
5 changes: 4 additions & 1 deletion velox/dwio/dwrf/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ velox_link_libraries(
)

# required for the wrapped protobuf headers/sources
velox_include_directories(velox_dwio_dwrf_common PUBLIC ${PROJECT_BINARY_DIR})
velox_include_directories(
velox_dwio_dwrf_common
PUBLIC "$<BUILD_LOCAL_INTERFACE:${PROJECT_BINARY_DIR}>"
)

if(NOT VELOX_MONO_LIBRARY)
# trigger generation of pb files
Expand Down
5 changes: 4 additions & 1 deletion velox/tpcds/gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ add_subdirectory(utils)
add_subdirectory(dsdgen)

velox_add_library(velox_tpcds_gen TpcdsGen.cpp DSDGenIterator.cpp)
velox_include_directories(velox_tpcds_gen PUBLIC dsdgen/include)
velox_include_directories(
velox_tpcds_gen
PUBLIC "$<BUILD_LOCAL_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dsdgen/include>"
)
velox_link_libraries(
velox_tpcds_gen
PUBLIC velox_memory velox_tpcds_append_info
Expand Down
5 changes: 4 additions & 1 deletion velox/tpch/gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ velox_add_library(velox_tpch_gen DBGenIterator.cpp TpchGen.cpp)

velox_include_directories(velox_tpch_gen PRIVATE dbgen/include)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not need the same generator expression as velox_tpcds_gen?

Copy link
Contributor Author

@kou kou Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it here because this is a "PRIVATE" include directory. "PRIVATE" include directories aren't exported.


velox_link_libraries(velox_tpch_gen velox_memory velox_vector dbgen)
velox_link_libraries(
velox_tpch_gen
PUBLIC velox_memory velox_vector "$<BUILD_LOCAL_INTERFACE:dbgen>"
)

if(${VELOX_BUILD_TESTING})
add_subdirectory(tests)
Expand Down
Loading