Skip to content

feat: Add CLP connector #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
fb10f2c
add clp module
wraymo Aug 16, 2024
7b1d318
add clp code to velox
wraymo Aug 18, 2024
cf4aad2
add more methods
wraymo Aug 20, 2024
0414c5a
add more methods
wraymo Aug 21, 2024
bb93043
modify CMakeLists.txt
wraymo Aug 21, 2024
fe6bace
add clp data source support
wraymo Aug 24, 2024
4738ad4
add polymorphic type support
wraymo Aug 26, 2024
6b5998c
remove duplicate values and add null support
wraymo Aug 28, 2024
8080d84
fix array bugs and the pipe blocking bug
wraymo Aug 28, 2024
5907d11
add concurrent split support
wraymo Sep 30, 2024
b742bb0
fixed a bug affecting select count(*) queries
wraymo Sep 30, 2024
e7112be
apply changes from upstream
wraymo Oct 2, 2024
7fe8838
fix some issues
wraymo Oct 3, 2024
b27d95a
fix some bugs for concurrent ClppSplits
wraymo Oct 4, 2024
580e411
fix some issues
wraymo Oct 9, 2024
bf76ccc
another impl with fork and pipe
wraymo Oct 31, 2024
55c43e0
add clp lib code for clp connector
wraymo Nov 4, 2024
3f6d60c
solve many dependency issues
wraymo Nov 4, 2024
4999b18
add antlr jar
wraymo Nov 5, 2024
72b7b98
add single file archive and network reader support
wraymo Nov 12, 2024
e1b0c3a
add msgpack dependency
wraymo Nov 13, 2024
7ae6504
add datasouce url support
wraymo Nov 13, 2024
98bf4f4
add s3 support
wraymo Jan 22, 2025
3c248ee
fix several issues
wraymo Jan 24, 2025
529c2fa
not treat warnings as errors
wraymo Jan 28, 2025
ef9e272
change the order
wraymo Jan 28, 2025
527f6fe
refactor the code
wraymo Feb 5, 2025
fd4c435
update clp dep
wraymo Feb 23, 2025
4c259b7
update velox code
wraymo Mar 17, 2025
2dd5e0e
rebase to the latest master branch
wraymo Mar 17, 2025
52cd74f
revert IP related changes
wraymo Mar 17, 2025
6bda409
update connector APIs and change the way how we use clpsplit
Mar 18, 2025
4f36e5e
fix warnings
Mar 19, 2025
b6aed4f
advance clp
wraymo Apr 1, 2025
ea33a7a
working on QueryRunner refactoring
wraymo Apr 2, 2025
a222eaf
refactor the code
wraymo Apr 11, 2025
d1eaabd
finish refactoring
wraymo Apr 11, 2025
62048e8
add license header
wraymo Apr 11, 2025
80fcd9d
fix lint errors in cmake files
wraymo Apr 11, 2025
dcbf0d9
improve clp connector comments
wraymo Apr 14, 2025
695d5f3
improve clp connector comments and reflect clp src code changes in cl…
wraymo Apr 16, 2025
f1c6cfe
add support to track num of rows sacnned
wraymo Apr 17, 2025
2f9356c
download antlr jar on demand and clean up FindANTLR.cmake
wraymo Apr 17, 2025
27c4b7d
add ClpConnectorTest
wraymo Apr 17, 2025
efa6ec9
use loop-based for
wraymo Apr 17, 2025
b8cf3ed
advance clp submodule
wraymo Apr 18, 2025
9c44db1
add clp test changes
wraymo Apr 18, 2025
ee126d4
resolve comments
wraymo Apr 29, 2025
73e845e
remove spdlog in ClpCursor.cpp
wraymo Apr 29, 2025
c6f1e05
add QueryRunner to CMakeLists.txt
wraymo Apr 29, 2025
e5e2b66
add glog statements in ClpCursor.cpp
wraymo Apr 29, 2025
a8c48f8
unit test progress
wraymo Apr 29, 2025
7955a92
fix multiple bugs
wraymo Apr 30, 2025
4300210
optimize headers
wraymo Apr 30, 2025
aa9390c
add the second test case; change archivePath to splitPath
wraymo May 1, 2025
b00d340
add more tests
wraymo May 1, 2025
b6ba69b
fix code formats
wraymo May 1, 2025
730aabf
add clp docs
wraymo May 2, 2025
eff493b
temperory solution
wraymo May 2, 2025
ffe2760
address comments
wraymo May 5, 2025
92f9fc0
use fetch_content for clp
wraymo May 5, 2025
c466884
fix code formats issues
wraymo May 5, 2025
6410857
remove clp header files from CMakeLists.txt
wraymo May 5, 2025
ec28c71
change method name
wraymo May 8, 2025
0cd9943
fix several build issues and optimize the cmake files
wraymo May 9, 2025
f26ba13
1. remove extra # in cmake files
wraymo May 12, 2025
9834a69
1. rename varialbes in ClpQueryRunner
wraymo May 14, 2025
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
175 changes: 175 additions & 0 deletions CMake/ExternalAntlr4Cpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# 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.

# NOTE: ExternalAntlr4Cpp.cmake taken from
# https://github.com/antlr/antlr4/blob/4.13.1/runtime/Cpp/cmake/ExternalAntlr4Cpp.cmake

cmake_minimum_required(VERSION 3.7)

if(POLICY CMP0114)
cmake_policy(SET CMP0114 NEW)
endif()

include(ExternalProject)

set(ANTLR4_ROOT ${CMAKE_CURRENT_BINARY_DIR}/antlr4_runtime/src/antlr4_runtime)
set(ANTLR4_INCLUDE_DIRS ${ANTLR4_ROOT}/runtime/Cpp/runtime/src)
set(ANTLR4_GIT_REPOSITORY https://github.com/antlr/antlr4.git)
if(NOT DEFINED ANTLR4_TAG)
# Set to branch name to keep library updated at the cost of needing to rebuild
# after 'clean' Set to commit hash to keep the build stable and does not need
# to rebuild after 'clean'
set(ANTLR4_TAG master)
endif()

# Ensure that the include dir already exists at configure time (to avoid cmake
# erroring on non-existent include dirs)
file(MAKE_DIRECTORY "${ANTLR4_INCLUDE_DIRS}")

if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(Configuration))
elseif(${CMAKE_GENERATOR} MATCHES "Xcode.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(CONFIGURATION))
else()
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist)
endif()
Comment on lines +40 to +46
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Quote generator variable in if() to avoid empty-string pitfalls

When CMAKE_GENERATOR is empty, if(${CMAKE_GENERATOR} MATCHES …) raises a CMake error.
Quote the variable to make the comparison safe:

-if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio.*")

Apply the same pattern to the other generator checks below (lines 40-46, 42-44, 68-80).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(Configuration))
elseif(${CMAKE_GENERATOR} MATCHES "Xcode.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(CONFIGURATION))
else()
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist)
endif()
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(Configuration))
elseif(${CMAKE_GENERATOR} MATCHES "Xcode.*")
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist/$(CONFIGURATION))
else()
set(ANTLR4_OUTPUT_DIR ${ANTLR4_ROOT}/runtime/Cpp/dist)
endif()


if(MSVC)
set(ANTLR4_STATIC_LIBRARIES ${ANTLR4_OUTPUT_DIR}/antlr4-runtime-static.lib)
set(ANTLR4_SHARED_LIBRARIES ${ANTLR4_OUTPUT_DIR}/antlr4-runtime.lib)
set(ANTLR4_RUNTIME_LIBRARIES ${ANTLR4_OUTPUT_DIR}/antlr4-runtime.dll)
else()
set(ANTLR4_STATIC_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.a)
if(MINGW)
set(ANTLR4_SHARED_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dll.a)
set(ANTLR4_RUNTIME_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dll)
elseif(CYGWIN)
set(ANTLR4_SHARED_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dll.a)
set(ANTLR4_RUNTIME_LIBRARIES
${ANTLR4_OUTPUT_DIR}/cygantlr4-runtime-${ANTLR4_TAG}.dll)
elseif(APPLE)
set(ANTLR4_RUNTIME_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.dylib)
else()
set(ANTLR4_RUNTIME_LIBRARIES ${ANTLR4_OUTPUT_DIR}/libantlr4-runtime.so)
endif()
endif()

if(${CMAKE_GENERATOR} MATCHES ".* Makefiles")
# This avoids 'warning: jobserver unavailable: using -j1. Add '+' to parent
# make rule.'
set(ANTLR4_BUILD_COMMAND $(MAKE))
elseif(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
set(ANTLR4_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $(Configuration)
--target)
elseif(${CMAKE_GENERATOR} MATCHES "Xcode.*")
set(ANTLR4_BUILD_COMMAND ${CMAKE_COMMAND} --build . --config $(CONFIGURATION)
--target)
else()
set(ANTLR4_BUILD_COMMAND ${CMAKE_COMMAND} --build . --target)
endif()

if(NOT DEFINED ANTLR4_WITH_STATIC_CRT)
set(ANTLR4_WITH_STATIC_CRT ON)
endif()

if(ANTLR4_ZIP_REPOSITORY)
ExternalProject_Add(
antlr4_runtime
PREFIX antlr4_runtime
URL ${ANTLR4_ZIP_REPOSITORY}
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ""
BUILD_IN_SOURCE 1
SOURCE_DIR ${ANTLR4_ROOT}
SOURCE_SUBDIR runtime/Cpp
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
-DDISABLE_WARNINGS:BOOL=ON
# -DCMAKE_CXX_STANDARD:STRING=17 # if desired, compile the runtime with a
# different C++ standard -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
# alternatively, compile the runtime with the same C++ standard as the
# outer project
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1)
else()
ExternalProject_Add(
antlr4_runtime
PREFIX antlr4_runtime
GIT_REPOSITORY ${ANTLR4_GIT_REPOSITORY}
GIT_TAG ${ANTLR4_TAG}
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
BUILD_COMMAND ""
BUILD_IN_SOURCE 1
SOURCE_DIR ${ANTLR4_ROOT}
SOURCE_SUBDIR runtime/Cpp
CMAKE_CACHE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
-DDISABLE_WARNINGS:BOOL=ON
# -DCMAKE_CXX_STANDARD:STRING=17 # if desired, compile the runtime with a
# different C++ standard -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}
# alternatively, compile the runtime with the same C++ standard as the
# outer project
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL 1)
endif()

# Separate build step as rarely people want both
set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT})
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
# CMake 3.14 builds in above's SOURCE_SUBDIR when BUILD_IN_SOURCE is true
set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT}/runtime/Cpp)
endif()

ExternalProject_Add_Step(
antlr4_runtime build_static
COMMAND ${ANTLR4_BUILD_COMMAND} antlr4_static
# Depend on target instead of step (a custom command) to avoid running
# dependent steps concurrently
DEPENDS antlr4_runtime
BYPRODUCTS ${ANTLR4_STATIC_LIBRARIES}
EXCLUDE_FROM_MAIN 1
WORKING_DIRECTORY ${ANTLR4_BUILD_DIR})
ExternalProject_Add_StepTargets(antlr4_runtime build_static)

add_library(antlr4_static STATIC IMPORTED)
add_dependencies(antlr4_static antlr4_runtime-build_static)
set_target_properties(
antlr4_static
PROPERTIES IMPORTED_LOCATION ${ANTLR4_STATIC_LIBRARIES})
target_include_directories(antlr4_static INTERFACE ${ANTLR4_INCLUDE_DIRS})

ExternalProject_Add_Step(
antlr4_runtime build_shared
COMMAND ${ANTLR4_BUILD_COMMAND} antlr4_shared
# Depend on target instead of step (a custom command) to avoid running
# dependent steps concurrently
DEPENDS antlr4_runtime
BYPRODUCTS ${ANTLR4_SHARED_LIBRARIES} ${ANTLR4_RUNTIME_LIBRARIES}
EXCLUDE_FROM_MAIN 1
WORKING_DIRECTORY ${ANTLR4_BUILD_DIR})
ExternalProject_Add_StepTargets(antlr4_runtime build_shared)

add_library(antlr4_shared SHARED IMPORTED)
add_dependencies(antlr4_shared antlr4_runtime-build_shared)
set_target_properties(
antlr4_shared
PROPERTIES IMPORTED_LOCATION ${ANTLR4_RUNTIME_LIBRARIES})
target_include_directories(antlr4_shared INTERFACE ${ANTLR4_INCLUDE_DIRS})

if(ANTLR4_SHARED_LIBRARIES)
set_target_properties(antlr4_shared PROPERTIES IMPORTED_IMPLIB
${ANTLR4_SHARED_LIBRARIES})
endif()
174 changes: 174 additions & 0 deletions CMake/FindANTLR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# 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.

# NOTE: FindANTLR.cmake taken from
# https://github.com/antlr/antlr4/blob/4.13.1/runtime/Cpp/cmake/FindANTLR.cmake

# Set ANTLR version
set(ANTLR4_TAG 4.13.1)
add_definitions(-DANTLR4CPP_STATIC)

# Define the JAR name and path
set(ANTLR_JAR_NAME antlr-${ANTLR4_TAG}-complete.jar)

# Set the download directory
set(ANTLR_DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/antlr)
file(MAKE_DIRECTORY ${ANTLR_DOWNLOAD_DIR})

# Define the full path to the ANTLR JAR
set(ANTLR_EXECUTABLE ${ANTLR_DOWNLOAD_DIR}/${ANTLR_JAR_NAME})

# Download the ANTLR JAR if it does not exist
if(NOT EXISTS ${ANTLR_EXECUTABLE})
message(STATUS "ANTLR JAR not found. Downloading ANTLR ${ANTLR4_TAG}...")
file(
DOWNLOAD https://www.antlr.org/download/${ANTLR_JAR_NAME}
${ANTLR_EXECUTABLE}
SHOW_PROGRESS
EXPECTED_HASH
SHA256=bc13a9c57a8dd7d5196888211e5ede657cb64a3ce968608697e4f668251a8487
TLS_VERIFY ON)
endif()

# Include the ANTLR C++ runtime integration
include(ExternalAntlr4Cpp)

find_package(Java 11 REQUIRED COMPONENTS Runtime)

if(NOT ANTLR_EXECUTABLE)
find_program(ANTLR_EXECUTABLE NAMES antlr.jar antlr4.jar antlr-4.jar
antlr-${ANTLR4_TAG}-complete.jar)
endif()

if(ANTLR_EXECUTABLE AND Java_JAVA_EXECUTABLE)
execute_process(
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${ANTLR_EXECUTABLE}
OUTPUT_VARIABLE ANTLR_COMMAND_OUTPUT
ERROR_VARIABLE ANTLR_COMMAND_ERROR
RESULT_VARIABLE ANTLR_COMMAND_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(ANTLR_COMMAND_RESULT EQUAL 0)
string(REGEX MATCH "Version [0-9]+(\\.[0-9]+)*" ANTLR_VERSION
${ANTLR_COMMAND_OUTPUT})
string(REPLACE "Version " "" ANTLR_VERSION ${ANTLR_VERSION})
else()
message(
SEND_ERROR "Command '${Java_JAVA_EXECUTABLE} -jar ${ANTLR_EXECUTABLE}' "
"failed with the output '${ANTLR_COMMAND_ERROR}'")
endif()

macro(ANTLR_TARGET Name InputFile)
set(ANTLR_OPTIONS LEXER PARSER LISTENER VISITOR)
set(ANTLR_ONE_VALUE_ARGS PACKAGE OUTPUT_DIRECTORY DEPENDS_ANTLR)
set(ANTLR_MULTI_VALUE_ARGS COMPILE_FLAGS DEPENDS)
cmake_parse_arguments(
ANTLR_TARGET
"${ANTLR_OPTIONS}"
"${ANTLR_ONE_VALUE_ARGS}"
"${ANTLR_MULTI_VALUE_ARGS}"
${ARGN})
set(ANTLR_${Name}_INPUT ${InputFile})

get_filename_component(ANTLR_INPUT ${InputFile} NAME_WE)
get_filename_component(ANTLR_INPUT_PARENT_DIR "${InputFile}" DIRECTORY)

if(ANTLR_TARGET_OUTPUT_DIRECTORY)
set(ANTLR_${Name}_OUTPUT_DIR ${ANTLR_TARGET_OUTPUT_DIRECTORY})
else()
set(ANTLR_${Name}_OUTPUT_DIR
${CMAKE_CURRENT_BINARY_DIR}/antlr4cpp_generated_src/${ANTLR_INPUT})
endif()

unset(ANTLR_${Name}_CXX_OUTPUTS)

if((ANTLR_TARGET_LEXER AND NOT ANTLR_TARGET_PARSER)
OR (ANTLR_TARGET_PARSER AND NOT ANTLR_TARGET_LEXER))
list(APPEND ANTLR_${Name}_CXX_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}.cpp)
set(ANTLR_${Name}_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}.interp
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}.tokens)
else()
list(
APPEND
ANTLR_${Name}_CXX_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Lexer.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Lexer.cpp
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Parser.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Parser.cpp)
list(APPEND ANTLR_${Name}_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Lexer.interp
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Lexer.tokens)
endif()

if(ANTLR_TARGET_LISTENER)
list(
APPEND
ANTLR_${Name}_CXX_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}BaseListener.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}BaseListener.cpp
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Listener.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Listener.cpp)
list(APPEND ANTLR_TARGET_COMPILE_FLAGS -listener)
endif()

if(ANTLR_TARGET_VISITOR)
list(
APPEND
ANTLR_${Name}_CXX_OUTPUTS
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}BaseVisitor.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}BaseVisitor.cpp
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Visitor.h
${ANTLR_${Name}_OUTPUT_DIR}/${ANTLR_INPUT}Visitor.cpp)
list(APPEND ANTLR_TARGET_COMPILE_FLAGS -visitor)
endif()

if(ANTLR_TARGET_PACKAGE)
list(APPEND ANTLR_TARGET_COMPILE_FLAGS -package ${ANTLR_TARGET_PACKAGE})
endif()

list(APPEND ANTLR_${Name}_OUTPUTS ${ANTLR_${Name}_CXX_OUTPUTS})

if(ANTLR_TARGET_DEPENDS_ANTLR)
if(ANTLR_${ANTLR_TARGET_DEPENDS_ANTLR}_INPUT)
list(APPEND ANTLR_TARGET_DEPENDS
${ANTLR_${ANTLR_TARGET_DEPENDS_ANTLR}_INPUT})
list(APPEND ANTLR_TARGET_DEPENDS
${ANTLR_${ANTLR_TARGET_DEPENDS_ANTLR}_OUTPUTS})
else()
message(
SEND_ERROR "ANTLR target '${ANTLR_TARGET_DEPENDS_ANTLR}' not found")
endif()
endif()

add_custom_command(
OUTPUT ${ANTLR_${Name}_OUTPUTS}
COMMAND
${Java_JAVA_EXECUTABLE} -jar ${ANTLR_EXECUTABLE} ${InputFile} -o
${ANTLR_${Name}_OUTPUT_DIR} -no-listener -Dlanguage=Cpp
${ANTLR_TARGET_COMPILE_FLAGS}
DEPENDS ${InputFile} ${ANTLR_TARGET_DEPENDS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building ${Name} with ANTLR ${ANTLR_VERSION}")
endmacro(ANTLR_TARGET)

endif(ANTLR_EXECUTABLE AND Java_JAVA_EXECUTABLE)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
ANTLR
REQUIRED_VARS ANTLR_EXECUTABLE Java_JAVA_EXECUTABLE
VERSION_VAR ANTLR_VERSION)
38 changes: 38 additions & 0 deletions CMake/resolve_dependency_modules/clp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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.
include_guard(GLOBAL)

FetchContent_Declare(
clp
GIT_REPOSITORY https://github.com/y-scope/clp.git
GIT_TAG 7b1b169a89abdfe44c159d6200b168391b697877
GIT_SUBMODULES "" GIT_SUBMODULES_RECURSE TRUE)

FetchContent_MakeAvailable(clp)

if(clp_POPULATED)
message(STATUS "Updating submodules for clp...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E chdir "${clp_SOURCE_DIR}" git submodule update
--init --recursive
RESULT_VARIABLE submodule_update_result
OUTPUT_VARIABLE submodule_update_output
ERROR_VARIABLE submodule_update_error)
if(NOT ${submodule_update_result} EQUAL 0)
message(ERROR
"Failed to update submodules for clp:\n${submodule_update_error}")
else()
message(STATUS "Submodules for clp updated successfully.")
endif()
endif()
Loading
Loading