Skip to content

Commit 58729cd

Browse files
committed
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. llvm-svn: 290837
1 parent 2d2ed1c commit 58729cd

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

libcxx/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,6 @@ if (LIBCXX_ENABLE_ASSERTIONS)
442442
define_if_not(MSVC -D_DEBUG)
443443
endif()
444444

445-
# Feature flags ===============================================================
446-
define_if(MSVC -D_CRT_SECURE_NO_WARNINGS)
447-
448445
# Modules flags ===============================================================
449446
# FIXME The libc++ sources are fundamentally non-modular. They need special
450447
# versions of the headers in order to provide C++03 and legacy ABI definitions.

libcxx/lib/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,28 @@ split_list(LIBCXX_LINK_FLAGS)
161161

162162
# Add a object library that contains the compiled source files.
163163
add_library(cxx_objects OBJECT ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS})
164+
if(WIN32 AND NOT MINGW)
165+
target_compile_definitions(cxx_objects
166+
PRIVATE
167+
# Ignore the -MSC_VER mismatch, as we may build
168+
# with a different compatibility version.
169+
_ALLOW_MSC_VER_MISMATCH
170+
# Don't check the msvcprt iterator debug levels
171+
# as we will define the iterator types; libc++
172+
# uses a different macro to identify the debug
173+
# level.
174+
_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
175+
# We are building the c++ runtime, don't pull in
176+
# msvcprt.
177+
_CRTBLD
178+
# Don't warn on the use of "deprecated"
179+
# "insecure" functions which are standards
180+
# specified.
181+
_CRT_SECURE_NO_WARNINGS
182+
# Use the ISO conforming behaviour for conversion
183+
# in printf, scanf.
184+
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
185+
endif()
164186

165187
set_target_properties(cxx_objects
166188
PROPERTIES

0 commit comments

Comments
 (0)