Skip to content

Commit

Permalink
Overly force -fPIC everywhere for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime committed Feb 9, 2024
1 parent e754a1c commit 1b191ea
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build-common:
cmake -Wno-dev \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DPREFER_STATIC_LIBS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
$(FORCE_COLOR) \
..

Expand Down
5 changes: 5 additions & 0 deletions src/substrait/textplan/parser/grammar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/../../../../../third_party/antlr4/cmake")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_definitions(-DANTLR4CPP_STATIC)

set(GRAMMAR_DIR ${CMAKE_CURRENT_BINARY_DIR})

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

set(ANTLR4_TAG 4.13.0)
set(ANTLR4_ZIP_REPOSITORY
Expand All @@ -27,6 +29,7 @@ find_package(ANTLR REQUIRED)

antlr_target(SubstraitPlanLexer SubstraitPlanLexer.g4 LEXER PACKAGE
io::substrait::textplan)
#set_target_properties(SubstraitPlanLexer PROPERTIES POSITION_INDEPENDENT_CODE ON)
antlr_target(
SubstraitPlanParser
SubstraitPlanParser.g4
Expand All @@ -39,6 +42,7 @@ antlr_target(
-lib
${ANTLR_SubstraitPlanLexer_OUTPUT_DIR}
VISITOR)
#set_target_properties(SubstraitPlanParser PROPERTIES POSITION_INDEPENDENT_CODE ON)

include_directories(${ANTLR_SubstraitPlanLexer_OUTPUT_DIR})
include_directories(${ANTLR_SubstraitPlanParser_OUTPUT_DIR})
Expand All @@ -57,5 +61,6 @@ message(STATUS "generated dir: ${GRAMMAR_DIR}/antlr4cpp_generated_src")

target_include_directories(textplan_grammar
PUBLIC "${GRAMMAR_DIR}/antlr4cpp_generated_src")
set_target_properties(textplan_grammar PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_link_libraries(textplan_grammar antlr4_static)
6 changes: 5 additions & 1 deletion third_party/antlr4/cmake/ExternalAntlr4Cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ if(ANTLR4_ZIP_REPOSITORY)
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
-DDISABLE_WARNINGS:BOOL=ON
-DCMAKE_POSITION_INDEPENDENT_CODE: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 ""
Expand All @@ -116,12 +117,15 @@ else()
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DWITH_STATIC_CRT:BOOL=${ANTLR4_WITH_STATIC_CRT}
-DDISABLE_WARNINGS:BOOL=ON
-DCMAKE_POSITION_INDEPENDENT_CODE: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()

set_target_properties(antlr4_runtime PROPERTIES POSITION_INDEPENDENT_CODE ON)

# Separate build step as rarely people want both
set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT})
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
Expand All @@ -146,7 +150,7 @@ add_dependencies(antlr4_static antlr4_runtime-build_static)
set_target_properties(antlr4_static PROPERTIES
IMPORTED_LOCATION ${ANTLR4_STATIC_LIBRARIES})
set_target_properties(antlr4_static PROPERTIES
CMAKE_POSITION_INDEPENDENT_CODE ON)
POSITION_INDEPENDENT_CODE ON)
target_include_directories(antlr4_static
INTERFACE
${ANTLR4_INCLUDE_DIRS}
Expand Down

0 comments on commit 1b191ea

Please sign in to comment.