[x265] [PATCH] cmake: disable exceptions for MSVC

Steve Borho steve at borho.org
Tue Jun 3 03:54:32 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1401759901 18000
#      Mon Jun 02 20:45:01 2014 -0500
# Branch stable
# Node ID 304773790fe4fe76f824f8ec1c1c964faa891a0b
# Parent  108996798e7829a43d481207aceb99c95e4b9129
cmake: disable exceptions for MSVC

This requires working around Microsoft's busted STL headers which raise warnings
when compiled without exceptions.

This makes the executable very slightly smaller, but seems to somehow make the
encoder run slower. Is this other's experience as well?

diff -r 108996798e78 -r 304773790fe4 source/CMakeLists.txt
--- a/source/CMakeLists.txt	Mon Jun 02 14:23:09 2014 -0500
+++ b/source/CMakeLists.txt	Mon Jun 02 20:45:01 2014 -0500
@@ -93,7 +93,13 @@
     add_definitions(/W4)  # Full warnings
     add_definitions(/Ob2) # always inline
     add_definitions(/MP)  # multithreaded build
+    if(NOT CHECKED_BUILD)
+        add_definitions(/GS-) # no buffer security check
 
+        # disable exceptions
+        add_definitions(/wd4530) # C++ exception handler used, but unwind semantics are not enabled)
+        string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+    endif()
     # disable Microsofts suggestions for proprietary secure APIs
     add_definitions(/D_CRT_SECURE_NO_WARNINGS)
 
diff -r 108996798e78 -r 304773790fe4 source/common/CMakeLists.txt
--- a/source/common/CMakeLists.txt	Mon Jun 02 14:23:09 2014 -0500
+++ b/source/common/CMakeLists.txt	Mon Jun 02 20:45:01 2014 -0500
@@ -50,7 +50,7 @@
     # /wd4389 signed/unsigned mismatch
     # /wd4018 '<' signed/unsigned mismatch
     set_source_files_properties(${LIBCOMMON_SRC} PROPERTIES COMPILE_FLAGS 
-        "/wd4244 /wd4389 /wd4018")
+        "/wd4244 /wd4389 /wd4018 /wd4530")
     if(INTEL_CXX)
         add_definitions(/Qwd2557) # signed/unsigned mismatch
     endif()
@@ -62,7 +62,7 @@
 
 if(MSVC AND X86)
     set(PRIMITIVES ${SSE3} ${SSSE3} ${SSE41})
-    set(WARNDISABLE "/wd4100") # unreferenced formal parameter
+    set(WARNDISABLE "/wd4100 /wd4530") # unreferenced formal parameter
     if(INTEL_CXX)
         add_definitions(/Qwd111) # statement is unreachable
         add_definitions(/Qwd128) # loop is unreachable
diff -r 108996798e78 -r 304773790fe4 source/encoder/CMakeLists.txt
--- a/source/encoder/CMakeLists.txt	Mon Jun 02 14:23:09 2014 -0500
+++ b/source/encoder/CMakeLists.txt	Mon Jun 02 20:45:01 2014 -0500
@@ -31,7 +31,7 @@
     # /wd4389 signed/unsigned mismatch
     # /wd4018 '<' signed/unsigned mismatch
     set_source_files_properties(${LIBENCODER_SRC} PROPERTIES COMPILE_FLAGS 
-        "/wd4244 /wd4389 /wd4018")
+        "/wd4244 /wd4389 /wd4018 /wd4530")
 endif(MSVC)
 
 add_library(encoder OBJECT ../x265.h


More information about the x265-devel mailing list