Skip to content

Commit 3bf20fc

Browse files
committed
Improve Windows build
1 parent 063200a commit 3bf20fc

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

CMakeLists.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ include(GNUInstallDirs)
44

55
# Set C++ standard
66
set(CMAKE_CXX_STANDARD 17)
7-
#set(CMAKE_CXX_STANDARD_REQUIRED True)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_EXTENSIONS OFF)
89
#set(CMAKE_CXX_COMPILER "clang++")
910

1011
# Set C standard (for TestAPI.c)
@@ -20,14 +21,16 @@ if(CONCURRENCY_DISABLED)
2021
add_definitions(-DCONCURRENCY_DISABLED)
2122
endif()
2223

23-
set(COMMON_FLAGS "-Wall -Wextra -O3 -fomit-frame-pointer -fPIC -DNDEBUG -pedantic -march=native")
24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -fno-rtti")
25-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
26-
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
27-
2824
if(MSVC)
29-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
25+
set(COMMON_FLAGS "/W4 /O2 /DNDEBUG")
26+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} /GR-")
27+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
28+
else()
29+
set(COMMON_FLAGS "-Wall -Wextra -O3 -fomit-frame-pointer -fPIC -DNDEBUG -pedantic -march=native")
30+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -fno-rtti")
31+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
3032
endif()
33+
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
3134

3235
# Source files
3336
set(LIB_COMMON_SOURCES

src/types.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ limitations under the License.
157157
// __cplusplus always defaults to 199711L (aka C++98) !!! (unless
158158
// the extra option /Zc:__cplusplus is added to the command line).
159159
// Otherwise, using the _MSVC_LANG macro returns the proper C++ version.
160-
#if __cplusplus >= 201103L
160+
#if (__cplusplus >= 201103L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
161161
// C++ 11 or higher
162162
#define FINAL final
163163
#define NOEXCEPT noexcept
@@ -197,7 +197,12 @@ limitations under the License.
197197
#endif
198198
#endif
199199

200-
#if !defined(nullptr)
200+
#if !defined(nullptr) && \
201+
((defined(_MSC_VER) && (_MSC_VER < 1600)) || \
202+
(defined(__GNUC__) && !defined(__clang__) && \
203+
((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 6)))) || \
204+
(defined(__clang__) && \
205+
((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 1)))))
201206
#define nullptr NULL
202207
#endif
203208
#endif

0 commit comments

Comments
 (0)