0029129: Incomplete support of MSVS2017
authorapn <apn@opencascade.com>
Mon, 12 Mar 2018 13:19:21 +0000 (16:19 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 16 Mar 2018 11:56:48 +0000 (14:56 +0300)
MSVC_VERSION is used instead of MSVC10, MSVC11, MSVC12, etc.

adm/cmake/occt_defs_flags.cmake
adm/cmake/occt_macros.cmake
samples/mfc/occtdemo/adm/cmake/CMakeLists.txt

index 41db64a..09da18d 100644 (file)
@@ -16,10 +16,9 @@ if (MSVC)
   set (CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /fp:precise")
 endif()
 
-# set compiler short name and choose SSE2 option for appropriate MSVC compilers
-# ONLY for 32-bit
+# add SSE2 option for old MSVC compilers (VS 2005 - 2010, 32 bit only)
 if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
-  if (MSVC80 OR MSVC90 OR MSVC10)
+  if (MSVC AND ((MSVC_VERSION EQUAL 1400) OR (MSVC_VERSION EQUAL 1500) OR (MSVC_VERSION EQUAL 1600)))
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
     set (CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   /arch:SSE2")
   endif()
@@ -82,7 +81,7 @@ if (IS_DEBUG_C)
   string (REGEX REPLACE "-DDEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
 endif()
 # enable parallel compilation on MSVC 9 and above
-if (MSVC AND NOT MSVC70 AND NOT MSVC80)
+if (MSVC AND (MSVC_VERSION GREATER 1400))
   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
 endif()
 
index 3d40a7c..55028a2 100644 (file)
@@ -60,25 +60,27 @@ endmacro()
 # COMPILER variable
 macro (OCCT_MAKE_COMPILER_SHORT_NAME)
   if (MSVC)
-    if (MSVC70)
+    if ((MSVC_VERSION EQUAL 1300) OR (MSVC_VERSION EQUAL 1310))
       set (COMPILER vc7)
-    elseif (MSVC80)
+    elseif (MSVC_VERSION EQUAL 1400)
       set (COMPILER vc8)
-    elseif (MSVC90)
+    elseif (MSVC_VERSION EQUAL 1500)
       set (COMPILER vc9)
-    elseif (MSVC10)
+    elseif (MSVC_VERSION EQUAL 1600)
       set (COMPILER vc10)
-    elseif (MSVC11)
+    elseif (MSVC_VERSION EQUAL 1700)
       set (COMPILER vc11)
-    elseif (MSVC12)
+    elseif (MSVC_VERSION EQUAL 1800)
       set (COMPILER vc12)
-    elseif (MSVC14)
+    elseif (MSVC_VERSION EQUAL 1900)
       set (COMPILER vc14)
-    elseif (MSVC15)
+    elseif ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000))
       # Since Visual Studio 15 (2017), its version diverged from version of
       # compiler which is 14.1; as that compiler uses the same run-time as 14.0,
       # we keep its id as "vc14" to be compatibille
       set (COMPILER vc14)
+    else()
+      message (FATAL_ERROR "Unrecognized MSVC_VERSION")
     endif()
   elseif (DEFINED CMAKE_COMPILER_IS_GNUCC)
     set (COMPILER gcc)
index 63a147e..909002c 100644 (file)
@@ -9,16 +9,25 @@ set( OCC_LIB_PATH "" CACHE PATH "OpenCascade LIB PATH")
 
 set( OCCTDEMO_DIR ${OCC_CASROOT}/samples/mfc/occtdemo)
 
-if (DEFINED MSVC70)
+if ((MSVC_VERSION EQUAL 1300) OR (MSVC_VERSION EQUAL 1310))
   SET(COMPILER vc7)
-elseif (DEFINED MSVC80)
+elseif (MSVC_VERSION EQUAL 1400)
   SET(COMPILER vc8)
-elseif (DEFINED MSVC90)
+elseif (MSVC_VERSION EQUAL 1500)
   SET(COMPILER vc9)
-elseif (DEFINED MSVC10)
+elseif (MSVC_VERSION EQUAL 1600)
   SET(COMPILER vc10)
-elseif (DEFINED MSVC11)
+elseif (MSVC_VERSION EQUAL 1700)
   SET(COMPILER vc11)
+elseif (MSVC_VERSION EQUAL 1800)
+  SET(COMPILER vc12)
+elseif (MSVC_VERSION EQUAL 1900)
+  SET(COMPILER vc14)
+elseif ((MSVC_VERSION GREATER 1900) AND (MSVC_VERSION LESS 2000))
+  # Since Visual Studio 15 (2017), its version diverged from version of
+  # compiler which is 14.1; as that compiler uses the same run-time as 14.0,
+  # we keep its id as "vc14" to be compatibille
+  SET(COMPILER vc14)
 else()
   SET(COMPILER ${CMAKE_GENERATOR})
 endif()