BUILD: Fix build of draw_state.cpp with VS 2015.
authorMark Young <marky@lunarg.com>
Tue, 19 Jan 2016 00:22:48 +0000 (17:22 -0700)
committerMark Young <marky@lunarg.com>
Mon, 25 Jan 2016 18:01:48 +0000 (11:01 -0700)
Added /bigobj to Debug build of all layer files when using VS 2015 or newer.

layers/CMakeLists.txt

index b593357..44345d6 100644 (file)
@@ -88,8 +88,21 @@ include_directories(
 )
 
 if (WIN32)
-    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
-    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS")
+    set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
+    set (CMAKE_C_FLAGS_RELEASE   "${CMAKE_C_FLAGS_RELEASE} -D_CRT_SECURE_NO_WARNINGS")
+    
+    # For VS 2015, which uses compiler version 1900, draw_state.cpp fails with too many objects
+    # without either optimizations enabled, or setting the /bigobj compilation option.  Since
+    # optimizations are enabled in a release build, this only affects the debug build.  For now,
+    # enable /bigobj mode for all debug layer files. An alternative for the future is to split
+    # draw_state.cpp into multiple files, which will also alleviate the compilation error.
+    if (NOT (MSVC_VERSION LESS 1900))
+        set (CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
+        set (CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS /bigobj")
+    else()
+        set (CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS")
+        set (CMAKE_C_FLAGS_DEBUG     "${CMAKE_C_FLAGS_DEBUG} -D_CRT_SECURE_NO_WARNINGS")
+    endif()
 endif()
 if (NOT WIN32)
     set (CMAKE_CXX_FLAGS "-std=c++11")