[libcxx] r290837 - build: tweak macros for Windows build

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 2 13:40:18 PST 2017


Author: compnerd
Date: Mon Jan  2 15:40:17 2017
New Revision: 290837

URL: http://llvm.org/viewvc/llvm-project?rev=290837&view=rev
Log:
build: tweak macros for Windows build

Move the windows specific macro definitions for compiling c++ into the
target.  Add a number of newer options that are necessary to properly
build libc++ for windows.  This ensures that we do not accidentally
autolink msvcprt (Microsoft's C++ runtime library), do not define linker
pragmas which are msvcprt specific, and do not accidentally encode the
incorrect version of the msvc compatibility version.

Modified:
    libcxx/trunk/CMakeLists.txt
    libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290837&r1=290836&r2=290837&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Jan  2 15:40:17 2017
@@ -442,9 +442,6 @@ if (LIBCXX_ENABLE_ASSERTIONS)
   define_if_not(MSVC -D_DEBUG)
 endif()
 
-# Feature flags ===============================================================
-define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
-
 # Modules flags ===============================================================
 # FIXME The libc++ sources are fundamentally non-modular. They need special
 # versions of the headers in order to provide C++03 and legacy ABI definitions.

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=290837&r1=290836&r2=290837&view=diff
==============================================================================
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Mon Jan  2 15:40:17 2017
@@ -161,6 +161,28 @@ split_list(LIBCXX_LINK_FLAGS)
 
 # Add a object library that contains the compiled source files.
 add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
+if(WIN32 AND NOT MINGW)
+  target_compile_definitions(cxx_objects
+                             PRIVATE
+                               # Ignore the -MSC_VER mismatch, as we may build
+                               # with a different compatibility version.
+                               _ALLOW_MSC_VER_MISMATCH
+                               # Don't check the msvcprt iterator debug levels
+                               # as we will define the iterator types; libc++
+                               # uses a different macro to identify the debug
+                               # level.
+                               _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
+                               # We are building the c++ runtime, don't pull in
+                               # msvcprt.
+                               _CRTBLD
+                               # Don't warn on the use of "deprecated"
+                               # "insecure" functions which are standards
+                               # specified.
+                               _CRT_SECURE_NO_WARNINGS
+                               # Use the ISO conforming behaviour for conversion
+                               # in printf, scanf.
+                               _CRT_STDIO_ISO_WIDE_SPECIFIERS)
+endif()
 
 set_target_properties(cxx_objects
   PROPERTIES




More information about the cfe-commits mailing list