Commit 887367ca authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Shift the job of defining NOMINMAX into source rather than the build system

Summary:
This makes it easier to consume Folly from a non-cmake project.
Note that this also requires making libevent, which was previously categorized as a semi-portable header into a non-portable header, meaning it can't be referenced directly. (libevent includes `Windows.h` in one of its headers -_-....)

Reviewed By: yfeldblum

Differential Revision: D5106051

fbshipit-source-id: 5ce2d4188c9036d6ab206af3036c8fd4b09516a4
parent c32f067b
...@@ -235,7 +235,6 @@ function(apply_folly_compile_options_to_target THETARGET) ...@@ -235,7 +235,6 @@ function(apply_folly_compile_options_to_target THETARGET)
# And the extra defines: # And the extra defines:
target_compile_definitions(${THETARGET} target_compile_definitions(${THETARGET}
PUBLIC PUBLIC
NOMINMAX # This is needed because, for some absurd reason, one of the windows headers tries to define "min" and "max" as macros, which messes up most uses of std::numeric_limits.
_CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions. _CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions.
_CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. _CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.
_SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps. _SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#pragma once #pragma once
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <event.h> #include <folly/portability/Event.h>
#include <map> #include <map>
namespace folly { namespace folly {
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <folly/portability/Event.h> #include <folly/portability/Event.h>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <event.h>
#include <memory> #include <memory>
#include <utility> #include <utility>
......
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
#include <folly/io/async/HHWheelTimer.h> #include <folly/io/async/HHWheelTimer.h>
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
#include <folly/io/async/TimeoutManager.h> #include <folly/io/async/TimeoutManager.h>
#include <folly/portability/Event.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <event.h> // libevent
namespace folly { namespace folly {
......
...@@ -21,7 +21,8 @@ ...@@ -21,7 +21,8 @@
#pragma once #pragma once
#include <functional> #include <functional>
#include <event.h> // libevent
#include <folly/portability/Event.h>
namespace folly { namespace folly {
......
...@@ -16,12 +16,16 @@ ...@@ -16,12 +16,16 @@
#pragma once #pragma once
#ifdef _MSC_VER
// This needs to be before the libevent include.
# include <folly/portability/Windows.h>
#endif
#include <event.h> #include <event.h>
#ifdef _MSC_VER #ifdef _MSC_VER
# include <event2/event_compat.h> # include <event2/event_compat.h>
# include <folly/portability/Fcntl.h> # include <folly/portability/Fcntl.h>
# include <folly/portability/Windows.h>
#endif #endif
namespace folly { namespace folly {
......
...@@ -37,6 +37,18 @@ ...@@ -37,6 +37,18 @@
#include <direct.h> // nolint #include <direct.h> // nolint
#endif #endif
#if defined(min) || defined(max)
#error Windows.h needs to be included by this header, or else NOMINMAX needs \
to be defined before including it yourself.
#endif
// This is needed because, for some absurd reason, one of the windows headers
// tries to define "min" and "max" as macros, which messes up most uses of
// std::numeric_limits.
#ifndef NOMINMAX
#define NOMINMAX 1
#endif
#include <WinSock2.h> #include <WinSock2.h>
#include <Windows.h> #include <Windows.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment