From 66ac0df61b99d87a3a3458683f32f788deaf2b4f Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Tue, 11 Jan 2022 11:40:50 +0100 Subject: [PATCH 1/2] #2861: Check for macOS systems before adding "--no-undefined" to linker flags as it is not compatible with the default linker. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f715ac1e..c8a5a36b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,7 +163,7 @@ if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") add_compile_options(-Werror=deprecated-copy) endif() - if(NOT CMAKE_VERSION VERSION_LESS "3.13") + if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") # Error if there's symbols that are not found at link time. # add_link_options() was added in CMake 3.13 - if using an earlier # version don't set this - it should be caught by presubmits anyway. From ab87ffe7cf67a865cfe9c4d2b002d3fbeb5dc726 Mon Sep 17 00:00:00 2001 From: Nicolas Morales Date: Tue, 11 Jan 2022 11:40:54 +0100 Subject: [PATCH 2/2] #2861: If compiling with macOS and GCC, default ENABLE_PCH to false since CMake will generate incompatible Xarch flags for the precompiled headers --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8a5a36b..43533c14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,14 @@ CMAKE_DEPENDENT_OPTION(ENABLE_HLSL option(ENABLE_RTTI "Enables RTTI" OFF) option(ENABLE_EXCEPTIONS "Enables Exceptions" OFF) option(ENABLE_OPT "Enables spirv-opt capability if present" ON) -option(ENABLE_PCH "Enables Precompiled header" ON) + +if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") + # Workaround for CMake behavior on Mac OS with gcc, cmake generates -Xarch_* arguments + # which gcc rejects + option(ENABLE_PCH "Enables Precompiled header" OFF) +else() + option(ENABLE_PCH "Enables Precompiled header" ON) +endif() option(ENABLE_CTEST "Enables testing" ON) if(ENABLE_GLSLANG_INSTALL AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)