Skip to content

Commit

Permalink
feat: update CMAKE files to work in a submodule (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime authored Oct 20, 2023
1 parent ecfd5b8 commit 66c8d97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
option(SUBSTRAIT_CPP_SANITIZE_DEBUG_BUILD
"Turns on address and undefined memory sanitization runtime checking."
ON)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=address>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=address>)
if(${SUBSTRAIT_CPP_SANITIZE_DEBUG_BUILD})
add_compile_options($<$<CONFIG:Debug>:-fsanitize=undefined>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=undefined>)

add_compile_options($<$<CONFIG:Debug>:-fsanitize=address>)
add_link_options($<$<CONFIG:Debug>:-fsanitize=address>)
endif()

option(
SUBSTRAIT_CPP_BUILD_TESTING
Expand Down
15 changes: 6 additions & 9 deletions src/substrait/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# SPDX-License-Identifier: Apache-2.0

find_package(Protobuf REQUIRED)
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
Expand All @@ -8,8 +7,10 @@ find_package(Perl REQUIRED)
set(UPDATE_PROTO_PACKAGE_TOOL
"${CMAKE_CURRENT_SOURCE_DIR}/update_proto_package.pl")

set(PROTO_INCLUDE_DIR
"${CMAKE_SOURCE_DIR}/third_party/substrait/proto/substrait")
set(RAW_PROTO_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../../../third_party/substrait/proto/substrait"
)
cmake_path(SET PROTO_INCLUDE_DIR NORMALIZE "${RAW_PROTO_INCLUDE_DIR}")
cmake_path(GET PROTO_INCLUDE_DIR PARENT_PATH PROTO_INCLUDE_TOPLEVEL_DIR)
set(PROTOBUF_IMPORT_DIRS ${PROTO_INCLUDE_DIR}/extensions)

Expand All @@ -24,9 +25,7 @@ set(GENERATED_PROTO_MIDLEVEL_DIR
"${GENERATED_PROTO_TOPLEVEL_DIR}/substrait/proto")
set(GENERATED_PROTOBUF_LIST)
foreach(PROTO_FILE IN LISTS PROTOBUF_FILELIST)
file(RELATIVE_PATH RELATIVE_PROTO_PATH
"${CMAKE_SOURCE_DIR}/third_party/substrait/proto/substrait"
"${PROTO_FILE}")
file(RELATIVE_PATH RELATIVE_PROTO_PATH "${PROTO_INCLUDE_DIR}" "${PROTO_FILE}")
set(GENERATED_PROTO_FILE
${GENERATED_PROTO_MIDLEVEL_DIR}/${RELATIVE_PROTO_PATH})

Expand Down Expand Up @@ -54,9 +53,7 @@ cmake_path(GET PROTO_OUTPUT_PARENT_DIR PARENT_PATH PROTO_OUTPUT_MIDLEVEL_DIR)
cmake_path(GET PROTO_OUTPUT_MIDLEVEL_DIR PARENT_PATH PROTO_OUTPUT_TOPLEVEL_DIR)

foreach(PROTO_FILE IN LISTS PROTOBUF_FILELIST)
file(RELATIVE_PATH RELATIVE_PROTO_PATH
"${CMAKE_SOURCE_DIR}/third_party/substrait/proto/substrait"
"${PROTO_FILE}")
file(RELATIVE_PATH RELATIVE_PROTO_PATH "${PROTO_INCLUDE_DIR}" "${PROTO_FILE}")
set(GENERATED_PROTO_FILE
${GENERATED_PROTO_MIDLEVEL_DIR}/${RELATIVE_PROTO_PATH})
message(
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
@@ -1,12 +1,13 @@
# SPDX-License-Identifier: Apache-2.0

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/third_party/antlr4/cmake")
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../third_party/antlr4/cmake")

set(CMAKE_CXX_STANDARD 17)

add_definitions(-DANTLR4CPP_STATIC)

set(GRAMMAR_DIR ${CMAKE_BINARY_DIR}/src/substrait/textplan/parser/grammar)
set(GRAMMAR_DIR ${CMAKE_CURRENT_BINARY_DIR})

# using /MD flag for antlr4_runtime (for Visual C++ compilers only)
set(ANTLR4_WITH_STATIC_CRT OFF)
Expand Down

0 comments on commit 66c8d97

Please sign in to comment.