From 6e2c1a3a6bee53952e12cb714615bc44acf89380 Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Wed, 18 Nov 2020 00:17:20 -0800 Subject: [PATCH] Update CMakeLists.txt (#770) This fixes the build errors that look like: source file is not valid UTF-8 This was due to CMake adding object files to the command line after the `-x` argument, which caused them to be interpreted as Objective C++ source code. --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15913934..029cee4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,11 @@ endif() IF(MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") ELSEIF(APPLE) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc -xobjective-c++") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc -ObjC++") + ELSE() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc -xobjective-c++") + ENDIF() ENDIF(MSVC) IF(WIN32) @@ -141,4 +145,4 @@ ENDIF(WIN32) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/") add_subdirectory(base) -add_subdirectory(examples) \ No newline at end of file +add_subdirectory(examples)