diff --git a/Makefile b/Makefile index 5aaba008..193c3bc3 100644 --- a/Makefile +++ b/Makefile @@ -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) \ .. diff --git a/src/substrait/textplan/parser/grammar/CMakeLists.txt b/src/substrait/textplan/parser/grammar/CMakeLists.txt index 47d88944..440533e8 100644 --- a/src/substrait/textplan/parser/grammar/CMakeLists.txt +++ b/src/substrait/textplan/parser/grammar/CMakeLists.txt @@ -4,6 +4,7 @@ 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) @@ -11,6 +12,7 @@ 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 @@ -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 @@ -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}) @@ -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) diff --git a/third_party/antlr4/cmake/ExternalAntlr4Cpp.cmake b/third_party/antlr4/cmake/ExternalAntlr4Cpp.cmake index 13da24d8..9d8ee4eb 100644 --- a/third_party/antlr4/cmake/ExternalAntlr4Cpp.cmake +++ b/third_party/antlr4/cmake/ExternalAntlr4Cpp.cmake @@ -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 "" @@ -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") @@ -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}