Skip to content

Commit

Permalink
[VL] Clean up duplicate CMake code for setting CMAKE_CXX_FLAGS (#8034)
Browse files Browse the repository at this point in the history
  • Loading branch information
surnaik authored Nov 26, 2024
1 parent 9f69d21 commit bcb768b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
21 changes: 20 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ set(KNOWN_WARNINGS
-Wno-error=unused-function \
-Wno-error=unused-variable \
-Wno-strict-aliasing \
-Wno-ignored-qualifiers")
-Wno-ignored-qualifiers \
-Wno-deprecated-declarations \
-Wno-attributes")

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(KNOWN_WARNINGS "-Wno-error=unused-but-set-variable \
Expand Down Expand Up @@ -141,8 +143,25 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_compile_definitions(_GNU_SOURCE)
endif()

if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KNOWN_WARNINGS}")

# Keep same compile option with Velox.
execute_process(
COMMAND
bash -c
"( source ${VELOX_HOME}/scripts/setup-helper-functions.sh && echo -n $(get_cxx_flags $ENV{CPU_TARGET}))"
OUTPUT_VARIABLE SCRIPT_CXX_FLAGS
RESULT_VARIABLE COMMAND_STATUS)
if(COMMAND_STATUS EQUAL "1")
message(FATAL_ERROR "Unable to determine compiler flags!")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}")

#
# Dependencies
#
Expand Down
22 changes: 0 additions & 22 deletions cpp/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ include(FindPkgConfig)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-attributes")
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
endif()

if(NOT DEFINED VELOX_HOME)
set(VELOX_HOME ${GLUTEN_HOME}/ep/build-velox/build/velox_ep)
message(STATUS "Set VELOX_HOME to ${VELOX_HOME}")
endif()

# Keep same compile option with Velox.
execute_process(
COMMAND
bash -c
"( source ${VELOX_HOME}/scripts/setup-helper-functions.sh && echo -n $(get_cxx_flags $ENV{CPU_TARGET}))"
OUTPUT_VARIABLE SCRIPT_CXX_FLAGS
RESULT_VARIABLE COMMAND_STATUS)
if(COMMAND_STATUS EQUAL "1")
message(FATAL_ERROR "Unable to determine compiler flags!")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}")
message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")

set(BOOST_MIN_VERSION "1.42.0")
Expand Down
18 changes: 0 additions & 18 deletions cpp/velox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
include(FindPackageHandleStandardArgs)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-attributes")
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-class-memaccess")
endif()

set(SYSTEM_LIB_PATH
"/usr/lib"
CACHE PATH "System Lib dir")
Expand Down Expand Up @@ -62,18 +56,6 @@ if(NOT DEFINED VELOX_HOME)
message(STATUS "Set VELOX_HOME to ${VELOX_HOME}")
endif()

# Keep same compile option with Velox.
execute_process(
COMMAND
bash -c
"( source ${VELOX_HOME}/scripts/setup-helper-functions.sh && echo -n $(get_cxx_flags $ENV{CPU_TARGET}))"
OUTPUT_VARIABLE SCRIPT_CXX_FLAGS
RESULT_VARIABLE COMMAND_STATUS)
if(COMMAND_STATUS EQUAL "1")
message(FATAL_ERROR "Unable to determine compiler flags!")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SCRIPT_CXX_FLAGS}")

message("Velox module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")

# User can specify VELOX_BUILD_PATH, if Velox are built elsewhere.
Expand Down

0 comments on commit bcb768b

Please sign in to comment.