commit 243c3ad932e90d8254e9e9799e7e9ea45192e0fd
parent f0a0bff52a7688bf88cc6a43bfdf4bc69a43e701
Author: [email protected] <[email protected]>
Date: Tue, 13 Nov 2018 22:35:29 +0300
Fix MSVC compatibility
Diffstat:
3 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -36,6 +36,13 @@ if(NOT CMAKE_CXX_COMPILER)
# If clang is not found, leave default compiler (usually GCC)
if(NOT DISABLE_CLANG)
+ find_program(CLANG_CXX_PATH clang++-8)
+ find_program(CLANG_CXX_PATH clang++-7)
+ find_program(CLANG_CXX_PATH clang++-8.0)
+ find_program(CLANG_CXX_PATH clang++-7.0)
+ find_program(CLANG_CXX_PATH clang++-6.0)
+ find_program(CLANG_CXX_PATH clang++-5.0)
+ find_program(CLANG_CXX_PATH clang++-4.0)
find_program(CLANG_CXX_PATH clang++-4.0)
find_program(CLANG_CXX_PATH clang++-3.9)
find_program(CLANG_CXX_PATH clang++-3.8)
@@ -85,7 +92,7 @@ if (${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles"
OR ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles"
OR ${CMAKE_GENERATOR} STREQUAL "Ninja")
- if (CMAKE_CXX_COMPILER MATCHES "clang")
+ if (CMAKE_CXX_COMPILER MATCHES "clang" AND NOT CMAKE_CXX_COMPILER MATCHES "clang-cl")
if (WIN32)
# On windows, clang requires --target
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --target=x86_64-w64-windows-gnu" CACHE STRING "cxx compile flags" FORCE)
@@ -110,6 +117,12 @@ project(kfr CXX)
message(STATUS "C++ compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} ${CMAKE_CXX_COMPILER} ")
+if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ set(CLANG 1)
+else()
+ set(CLANG 0)
+endif()
+
# Binary output directories
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin/Debug)
@@ -123,7 +136,11 @@ else ()
set(STD_LIB stdc++)
endif ()
-if (NOT MSVC)
+add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
+
+add_definitions(-D_CRT_SECURE_NO_WARNINGS)
+
+if (NOT MSVC OR CLANG)
# Enable C++14, disable exceptions and rtti
add_compile_options(-std=c++1y -fno-exceptions -fno-rtti )
if (NOT ARCH_FLAGS)
@@ -134,7 +151,9 @@ if (NOT MSVC)
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARCH_FLAGS}")
endif ()
- link_libraries(${STD_LIB} pthread m)
+ if(NOT MSVC)
+ link_libraries(${STD_LIB} pthread m)
+ endif()
else ()
# Disable exceptions
add_compile_options(/EHsc /D_HAS_EXCEPTIONS=0 /D_CRT_SECURE_NO_WARNINGS=1)
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
@@ -67,3 +67,19 @@ jobs:
ninja
cd tests
ctest -V
+
+- job: Windows_MSVC64
+ pool:
+ vmImage: 'vs2017-win2016'
+ steps:
+ - script: |
+ choco install llvm ninja
+ mkdir build
+ cd build
+ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
+ set PATH=%PATH:C:\tools\mingw64\bin;=%
+ set PATH=%PATH:C:\Program Files\Git\mingw64\bin;=%
+ cmake -GNinja -DCMAKE_CXX_COMPILER="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_BUILD_TYPE=Release ..
+ ninja
+ cd tests
+ ctest -V
diff --git a/include/kfr/base/pointer.hpp b/include/kfr/base/pointer.hpp
@@ -116,7 +116,7 @@ struct expression_resource
};
template <typename E>
-struct alignas(const_max(size_t(8), alignof(E))) expression_resource_impl : expression_resource
+struct expression_resource_impl : expression_resource
{
expression_resource_impl(E&& e) noexcept : e(std::move(e)) {}
virtual ~expression_resource_impl() {}