[Bf-blender-cvs] [34bd23dbb71] master: MSVC: Support Building clang+ninja+VS2019

Ray Molenkamp noreply at git.blender.org
Tue Oct 1 20:36:17 CEST 2019


Commit: 34bd23dbb71b2f8bfc696acf5107650bd750364d
Author: Ray Molenkamp
Date:   Tue Oct 1 12:36:11 2019 -0600
Branches: master
https://developer.blender.org/rB34bd23dbb71b2f8bfc696acf5107650bd750364d

MSVC: Support Building clang+ninja+VS2019

1) Clang was given the wrong VS version to emulate when used in
combination with VS2019 causing build issues.

2) The erroneous supplied parameter `-std::c++11`caused CMake to
fail running its compiler detection scripts.

===================================================================

M	CMakeLists.txt
M	build_files/windows/configure_ninja.cmd

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 258e79b7d4a..cddb93dd7ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1610,15 +1610,19 @@ if(WITH_PYTHON)
   endif()
 endif()
 
-if(
+if(MSVC)
+  # MSVC needs to be tested first, since clang on windows will
+  # match the compiler test below but clang-cl does not accept -std=c++11
+  # since it is on by default and cannot be turned off.
+  #
+  # Nothing special is needed, C++11 features are available by default.
+elseif(
   CMAKE_COMPILER_IS_GNUCC OR
   CMAKE_C_COMPILER_ID MATCHES "Clang" OR
   CMAKE_C_COMPILER_ID MATCHES "Intel"
 )
   # TODO(sergey): Do we want c++11 or gnu-c++11 here?
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-elseif(MSVC)
-  # Nothing special is needed, C++11 features are available by default.
 else()
   message(FATAL_ERROR "Unknown compiler ${CMAKE_C_COMPILER_ID}, can't enable C++11 build")
 endif()
diff --git a/build_files/windows/configure_ninja.cmd b/build_files/windows/configure_ninja.cmd
index 995d8d56fa8..8f766e855a6 100644
--- a/build_files/windows/configure_ninja.cmd
+++ b/build_files/windows/configure_ninja.cmd
@@ -30,9 +30,15 @@ set LLVM_DIR=
 :DetectionComplete	
 	set CC=%LLVM_DIR%\bin\clang-cl
 	set CXX=%LLVM_DIR%\bin\clang-cl
-	rem build and tested against 2017 15.7
-	set CFLAGS=-m64 -fmsc-version=1914
-	set CXXFLAGS=-m64 -fmsc-version=1914
+	if "%BUILD_VS_YEAR%" == "2019" (
+		rem build and tested against 2019 16.2
+		set CFLAGS=-m64 -fmsc-version=1922
+		set CXXFLAGS=-m64 -fmsc-version=1922
+	) else (
+		rem build and tested against 2017 15.7
+		set CFLAGS=-m64 -fmsc-version=1914
+		set CXXFLAGS=-m64 -fmsc-version=1914
+	)
 	if "%WITH_ASAN%"=="1" (
 		set BUILD_CMAKE_ARGS=%BUILD_CMAKE_ARGS% -DWITH_COMPILER_ASAN=On
 	)



More information about the Bf-blender-cvs mailing list