Skip to content

Commit 8c64ff9

Browse files
committed
Do not modify compiler flags for in-tree build, this should be handled by the including project
Signed-off-by: Rickert, Jonas <[email protected]>
1 parent 589b7f2 commit 8c64ff9

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

CMakeLists.txt

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ if (NOT CMAKE_BUILD_TYPE)
3939
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build type (default Debug)" FORCE)
4040
endif()
4141

42-
# NOTE: The compiler flag /Ob1 will disable COMDAT (Common Data) functionality and will cause
43-
# duplicate symbols errors.
44-
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
45-
if (MSVC)
46-
string(REGEX REPLACE "/Ob1" "/Ob2" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
47-
endif()
48-
endif()
49-
5042
# CMP0116: Ninja generators transform `DEPFILE`s from `add_custom_command()`
5143
# New in CMake 3.20. https://cmake.org/cmake/help/latest/policy/CMP0116.html
5244
# Use the same setting as llvm-project
@@ -82,6 +74,25 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
8274
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/bin)
8375
set(CMAKE_INCLUDE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$<CONFIG>/include)
8476
set(ONNX_MLIR_BUILD_INTREE OFF)
77+
# NOTE: The compiler flag /Ob1 will disable COMDAT (Common Data) functionality and will cause
78+
# duplicate symbols errors.
79+
if (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
80+
if (MSVC)
81+
string(REGEX REPLACE "/Ob1" "/Ob2" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
82+
endif()
83+
endif()
84+
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
85+
# Use the new MSVC preprocessor to improve standard conformance.
86+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zc:preprocessor")
87+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor")
88+
89+
# Disable warning for non-standard usages of std::complex template which was
90+
# introduced in MSVC 14.34.
91+
# More details at https://github.com/microsoft/STL/pull/2759.
92+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING")
93+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING")
94+
95+
endif()
8596
else()
8697
message(STATUS "ONNX-MLIR in-tree build.")
8798
set(ONNX_MLIR_BUILD_INTREE ON)
@@ -151,19 +162,6 @@ else()
151162
message(WARNING "Java explicitly disabled with the ONNX_MLIR_ENABLE_JAVA option, JNI targets will not work")
152163
endif()
153164

154-
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
155-
# Use the new MSVC preprocessor to improve standard conformance.
156-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zc:preprocessor")
157-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:preprocessor")
158-
159-
# Disable warning for non-standard usages of std::complex template which was
160-
# introduced in MSVC 14.34.
161-
# More details at https://github.com/microsoft/STL/pull/2759.
162-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING")
163-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING")
164-
165-
endif()
166-
167165
# Suppress warnings in third party code if requested.
168166
if (ONNX_MLIR_SUPPRESS_THIRD_PARTY_WARNINGS)
169167
set(LLVM_ENABLE_WERROR OFF)

0 commit comments

Comments
 (0)