This is an automated email from the ASF dual-hosted git repository.

philo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 022c20856 [VL] Refine CMAKE_CXX_FLAGS setting logic (#5769)
022c20856 is described below

commit 022c208564dbb6dc59b7d64fbc4ad002c166e012
Author: Yang Zhang <[email protected]>
AuthorDate: Fri May 17 10:27:34 2024 +0800

    [VL] Refine CMAKE_CXX_FLAGS setting logic (#5769)
---
 cpp/CMakeLists.txt       | 58 ++++++++++++++++++++++++++++++------------------
 cpp/core/CMakeLists.txt  |  7 +++---
 cpp/velox/CMakeLists.txt | 23 +++++++++++++------
 3 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 7c38d8cc4..28c28a5bd 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -16,6 +16,9 @@
 cmake_minimum_required(VERSION 3.16)
 message(STATUS "Building using CMake version: ${CMAKE_VERSION}")
 
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
 # The set(CACHE) command does not remove any normal variable of the same name 
from the current scope
 # https://cmake.org/cmake/help/latest/policy/CMP0126.html
 if(POLICY CMP0126)
@@ -82,46 +85,59 @@ else ()
   message(STATUS "Add definition NDEBUG")
 endif()
 
-add_compile_options(-Wall)
-add_compile_options(-Wno-sign-compare)
-add_compile_options(-Wno-comment)
-
-add_compile_options(-Werror)
-add_compile_options(-Wno-error=parentheses)
-add_compile_options(-Wno-error=unused-function)
-add_compile_options(-Wno-error=unused-variable)
-add_compile_options(-Wno-strict-aliasing)
+set(KNOWN_WARNINGS
+    "-Wall \
+       -Wno-sign-compare \
+       -Wno-comment \
+       -Werror \
+       -Wno-error=parentheses \
+       -Wno-error=unused-function \
+       -Wno-error=unused-variable \
+       -Wno-strict-aliasing \
+       -Wno-ignored-qualifiers")
 
 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
-  add_compile_options(-Wno-error=unused-but-set-variable)
+  set(KNOWN_WARNINGS
+      "-Wno-error=unused-but-set-variable \
+      ${KNOWN_WARNINGS}")
   if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)
-    add_compile_options(-Wno-error=maybe-uninitialized)
+    set(KNOWN_WARNINGS
+        "-Wno-error=maybe-uninitialized \
+      ${KNOWN_WARNINGS}")
   endif()
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
   # Experimental
-  add_compile_options(-Wno-implicit-int-float-conversion)
-  add_compile_options(-Wno-nullability-completeness)
-  add_compile_options(-Wno-mismatched-tags)
+  set(KNOWN_WARNINGS
+      "-Wno-implicit-int-float-conversion \
+      -Wno-nullability-completeness \
+      -Wno-mismatched-tags \
+      ${KNOWN_WARNINGS}")
 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
   # Experimental
-  add_compile_options(-Wno-implicit-int-float-conversion)
-  add_compile_options(-Wno-nullability-completeness)
-  add_compile_options(-Wno-mismatched-tags)
+  set(KNOWN_WARNINGS
+      "-Wno-implicit-int-float-conversion \
+      -Wno-nullability-completeness \
+      -Wno-mismatched-tags \
+      ${KNOWN_WARNINGS}")
 else()
   message(FATAL_ERROR "Unsupported compiler ID: ${CMAKE_CXX_COMPILER_ID}")
 endif()
 
 # see https://issues.apache.org/jira/browse/ARROW-4665
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
-  add_compile_options(-Wno-macro-redefined)
-  add_compile_options(-Wno-nullability-completeness)
-  add_compile_options(-Wno-pessimizing-move)
-  add_compile_options(-Wno-mismatched-tags)
+  set(KNOWN_WARNINGS
+      "-Wno-macro-redefined \
+      -Wno-nullability-completeness \
+      -Wno-pessimizing-move \
+      -Wno-mismatched-tags \
+      ${KNOWN_WARNINGS}")
   # Specific definition for an issue with boost/stacktrace when building on 
macOS.
   # See https://github.com/boostorg/stacktrace/issues/88 and comments therein.
   add_compile_definitions(_GNU_SOURCE)
 endif()
 
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KNOWN_WARNINGS}")
+
 #
 # Dependencies
 #
diff --git a/cpp/core/CMakeLists.txt b/cpp/core/CMakeLists.txt
index c369a5bc3..4a8ae0e47 100644
--- a/cpp/core/CMakeLists.txt
+++ b/cpp/core/CMakeLists.txt
@@ -22,10 +22,6 @@ include(FindPkgConfig)
 include(GNUInstallDirs)
 include(CheckCXXCompilerFlag)
 
-set(CMAKE_CXX_STANDARD 17)
-
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
 # Only set arch=native for non-AppleClang compilers.
 if (NOT CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
@@ -173,6 +169,9 @@ set_source_files_properties(${GLUTEN_PROTO_OUTPUT_FILES} 
PROPERTIES GENERATED TR
 get_filename_component(GLUTEN_PROTO_DIR ${GLUTEN_PROTO_SRC_DIR}/ DIRECTORY)
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations 
-Wno-attributes")
+
+message("Core module final CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
+
 set(SPARK_COLUMNAR_PLUGIN_SRCS
         ${SUBSTRAIT_PROTO_SRCS}
         ${GLUTEN_PROTO_SRCS}
diff --git a/cpp/velox/CMakeLists.txt b/cpp/velox/CMakeLists.txt
index 9ad14fdf7..9e5f08b1c 100644
--- a/cpp/velox/CMakeLists.txt
+++ b/cpp/velox/CMakeLists.txt
@@ -23,11 +23,6 @@ include(GNUInstallDirs)
 include(CheckCXXCompilerFlag)
 include(FindPackageHandleStandardArgs)
 
-set(CMAKE_CXX_STANDARD 17)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx -mavx2")
-endif()
 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")
@@ -52,6 +47,20 @@ 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.
 if(NOT DEFINED VELOX_BUILD_PATH)
   if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
@@ -125,7 +134,7 @@ macro(ADD_VELOX_DEPENDENCIES)
     add_velox_dependency(dwio::common::test::utils 
"${VELOX_COMPONENTS_PATH}/dwio/common/tests/utils/libvelox_dwio_common_test_utils.a")
   endif()
   add_velox_dependency(exec "${VELOX_COMPONENTS_PATH}/exec/libvelox_exec.a")
-  
+
   if(BUILD_TESTS)
     add_velox_dependency(parse::parser 
"${VELOX_COMPONENTS_PATH}/parse/libvelox_parse_parser.a")
     add_velox_dependency(duckdb::parser 
"${VELOX_COMPONENTS_PATH}/duckdb/conversion/libvelox_duckdb_parser.a")
@@ -162,7 +171,7 @@ macro(ADD_VELOX_DEPENDENCIES)
     add_velox_dependency(parquet::reader::duckdb_conversion 
"${VELOX_COMPONENTS_PATH}/duckdb/conversion/libvelox_duckdb_conversion.a")
 
     add_duckdb()
-    
+
     add_velox_dependency(tpch::gen 
"${VELOX_COMPONENTS_PATH}/tpch/gen/libvelox_tpch_gen.a")
     add_velox_dependency(dbgen 
"${VELOX_COMPONENTS_PATH}/tpch/gen/dbgen/libvelox_dbgen.a")
   endif()


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to