Skip to content

Commit

Permalink
Merge pull request pmem#10 from igchor/appveyor
Browse files Browse the repository at this point in the history
Windows support
  • Loading branch information
marcinslusarz authored Jun 18, 2018
2 parents 131a366 + 0c5fa4b commit fb6077b
Show file tree
Hide file tree
Showing 21 changed files with 327 additions and 316 deletions.
33 changes: 33 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: 1.4.{build}
os: Visual Studio 2015
platform: x64

environment:
VCPKG_DEFAULT_TRIPLET: x64-windows
GENERATOR: "Visual Studio 14 2015 Win64"

install:
- vcpkg install pmdk:x64-windows
- vcpkg install sfml:x64-windows
- vcpkg integrate install

cache: c:\tools\vcpkg\installed

configuration:
- Debug
- Release

matrix:
fast_finish: true

before_build:
- cmake . -Bbuild -G "%GENERATOR%"
-DCMAKE_MODULE_PATH=c:/projects/libpmemobj-cpp
-DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake

build_script:
- msbuild build/ALL_BUILD.vcxproj /property:Configuration=%CONFIGURATION%

test_script:
- cd build
- ctest -C %CONFIGURATION% --output-on-failure
44 changes: 25 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ find_package(PkgConfig QUIET)

include_directories(include)

# Treat CMAKE_CXX_STANDARD as a requirement
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)

function(join SEP OUT VALUES)
Expand Down Expand Up @@ -303,7 +305,7 @@ add_custom_target(uninstall
if(PKG_CONFIG_FOUND)
pkg_check_modules(PMEMOBJ REQUIRED libpmemobj>=1.4)
else()
find_package(PMEMOBJ REQUIRED)
find_package(PMEMOBJ REQUIRED 1.4)
endif()

if(PKG_CONFIG_FOUND)
Expand Down Expand Up @@ -336,24 +338,28 @@ if(NOT LIBUNWIND_FOUND)
message(WARNING "libunwind not found. Stack traces from tests will not be reliable")
endif()

set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})

# Check for issues with older gcc compilers which do not expand variadic template
# variables in lambda expressions.
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -c")
CHECK_CXX_SOURCE_COMPILES(
"void print() {}
template<typename...Args, typename T>
void print(const T&, const Args &...arg) {
auto f = [&]{ print(arg...);};
}
int main() {
print(1, 2, 3);
return 0;
}"
NO_GCC_VARIADIC_TEMPLATE_BUG)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
if(NOT WIN32)
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})

# Check for issues with older gcc compilers which do not expand variadic template
# variables in lambda expressions.
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -c")
CHECK_CXX_SOURCE_COMPILES(
"void print() {}
template<typename...Args, typename T>
void print(const T&, const Args &...arg) {
auto f = [&]{ print(arg...);};
}
int main() {
print(1, 2, 3);
return 0;
}"
NO_GCC_VARIADIC_TEMPLATE_BUG)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
else()
set(NO_GCC_VARIADIC_TEMPLATE_BUG TRUE)
endif()

if(BUILD_TESTS)
if(TEST_DIR)
Expand Down
39 changes: 39 additions & 0 deletions FindPMEMOBJ.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright 2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_path(PMEMOBJ_INCLUDE_DIR libpmemobj.h HINTS ${PMEMOBJ_PATH}/include)
find_library(PMEMOBJ_LIBRARY libpmemobj HINTS ${PMEMOBJ_PATH}/lib)
find_library(PMEM_LIBRARY libpmem HINTS ${PMEMOBJ_PATH}/lib)

set(PMEMOBJ_LIBRARIES ${PMEMOBJ_LIBRARY} ${PMEM_LIBRARY})
set(PMEMOBJ_INCLUDE_DIRS ${PMEMOBJ_INCLUDE_DIR})

mark_as_advanced(PMEMOBJ_LIBRARY PMEM_LIBRARY PMEMOBJ_INCLUDE_DIR)
12 changes: 8 additions & 4 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ link_directories(${PMEMOBJ_LIBRARY_DIRS})
add_cppstyle(examples-common ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
add_check_whitespace(examples-common ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)

function(add_example name srcs)
function(add_example name)
set(srcs ${ARGN})
prepend(srcs ${CMAKE_CURRENT_SOURCE_DIR} ${srcs})
add_executable(example-${name} ${srcs})
add_cppstyle(examples-${name} ${srcs})
Expand All @@ -54,7 +55,9 @@ endif()
if(PKG_CONFIG_FOUND)
pkg_check_modules(SFML QUIET sfml-all>=2.4)
else()
find_package(SFML 2.4 QUIET all)
# SFML 2.5 has different cmake interface than <= 2.4 so previous versions are not supported
find_package(SFML 2.5 QUIET COMPONENTS graphics window system)
set(SFML_LIBRARIES sfml-graphics sfml-window sfml-system)
endif()

add_example(queue queue/queue.cpp)
Expand All @@ -69,9 +72,10 @@ else()
endif()

if(SFML_FOUND)
# XXX: this can only be run in Release mode - in Debug SFML doesn't add all dependencies automatically
add_example(pmpong pmpong/Ball.cpp pmpong/GameController.cpp pmpong/GameOverView.cpp
pmpong/GameView.cpp pmpong/MainGame.cpp pmpong/MenuView.cpp pmpong/Paddle.cpp
pmpong/PongGameStatus.cpp pmpong/Pool.cpp)
pmpong/GameView.cpp pmpong/MainGame.cpp pmpong/MenuView.cpp pmpong/Paddle.cpp
pmpong/PongGameStatus.cpp pmpong/Pool.cpp)
target_include_directories(example-pmpong PUBLIC ${SFML_INCLUDE_DIR})
target_link_libraries(example-pmpong ${PMEMOBJ_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${SFML_LIBRARIES})

Expand Down
2 changes: 2 additions & 0 deletions examples/objcpp_examples_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ find_last_set_64(uint64_t val)

#else

#include <corecrt_io.h>
#include <process.h>
#include <windows.h>

#define CREATE_MODE_RW (S_IWRITE | S_IREAD)
Expand Down
48 changes: 0 additions & 48 deletions examples/pmpong/buildScript.ps1

This file was deleted.

71 changes: 42 additions & 29 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,46 @@ endif()
include_directories(${INCLUDE_DIRS})
link_directories(${LIBS_DIRS})

set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(SAVED_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})

# Check for issues with older clang compilers which assert on delete persistent<[][]>.
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../include ${PMEMOBJ_INCLUDE_DIRS})
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -c")
CHECK_CXX_SOURCE_COMPILES(
"#include <libpmemobj++/make_persistent_array.hpp>
using namespace pmem::obj;
int main() {
delete_persistent<int[][3]>(make_persistent<int[][3]>(2), 2);
return 0;
}"
NO_CLANG_TEMPLATE_BUG)

# This is a workaround for older incompatible versions of libstdc++ and clang.
# Please see https://llvm.org/bugs/show_bug.cgi?id=15517 for more info.
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -include future")
CHECK_CXX_SOURCE_COMPILES(
"int main() { return 0; }"
NO_CHRONO_BUG)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${SAVED_CMAKE_REQUIRED_INCLUDES})
if(NOT WIN32)
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(SAVED_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})

# Check for issues with older clang compilers which assert on delete persistent<[][]>.
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/../include ${PMEMOBJ_INCLUDE_DIRS})
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -c")
CHECK_CXX_SOURCE_COMPILES(
"#include <libpmemobj++/make_persistent_array.hpp>
using namespace pmem::obj;
int main() {
delete_persistent<int[][3]>(make_persistent<int[][3]>(2), 2);
return 0;
}"
NO_CLANG_TEMPLATE_BUG)

# This is a workaround for older incompatible versions of libstdc++ and clang.
# Please see https://llvm.org/bugs/show_bug.cgi?id=15517 for more info.
set(CMAKE_REQUIRED_FLAGS "--std=c++11 -include future")
CHECK_CXX_SOURCE_COMPILES(
"int main() { return 0; }"
NO_CHRONO_BUG)

set(CMAKE_REQUIRED_FLAGS ${SAVED_CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${SAVED_CMAKE_REQUIRED_INCLUDES})
else()
set(NO_CLANG_TEMPLATE_BUG TRUE)
set(NO_CHRONO_BUG TRUE)
endif()

add_cppstyle("tests-common" ${CMAKE_CURRENT_SOURCE_DIR}/common/*.*pp)
add_check_whitespace("tests-common" ${CMAKE_CURRENT_SOURCE_DIR}/common/*.*pp)

function(build_test name srcs)
function(build_test name)
# skip posix tests
if(${name} MATCHES "posix$" AND WIN32)
return()
endif()

set(srcs ${ARGN})
prepend(srcs ${CMAKE_CURRENT_SOURCE_DIR} ${srcs})

add_cppstyle(tests-${name} ${srcs})
Expand All @@ -113,7 +119,9 @@ build_test(shared_mutex_posix shared_mutex_posix/shared_mutex_posix.cpp)
build_test(transaction transaction/transaction.cpp)
build_test(ptr_arith ptr_arith/ptr_arith.cpp)

#build_test(pool_win pool_win/pool_win.cpp) XXX: add toUTF8
if(WIN32)
build_test(pool_win pool_win/pool_win.cpp)
endif()
#build_test(v v/v.cpp) XXX: fix compile error

if(NO_CHRONO_BUG)
Expand Down Expand Up @@ -189,21 +197,21 @@ function(add_testcase name tracer testcase)

if ((NOT VALGRIND_FOUND) AND ${tracer} IN_LIST vg_tracers)
add_test(NAME ${name}_${testcase}_${tracer}_SKIPPED_BECAUSE_OF_MISSING_VALGRIND
COMMAND true)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/true.cmake)
return()
endif()

if(${tracer} STREQUAL pmemcheck)
if (VALGRIND_PMEMCHECK_NOT_FOUND)
add_test(NAME ${name}_${testcase}_${tracer}_SKIPPED_BECAUSE_OF_MISSING_PMEMCHECK
COMMAND true)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/true.cmake)
return()
endif()
endif()

if (NOT TARGET ${name}) # if test was not build (because of compiler issue)
add_test(NAME ${name}_${testcase}_${tracer}_SKIPPED_BECAUSE_OF_COMPILER_ISSUE
COMMAND true)
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/true.cmake)
return()
endif()

Expand Down Expand Up @@ -308,6 +316,11 @@ add_test_generic(pool none 1)
add_test_generic(pool none 2)
add_test_generic(pool none 3)

add_test_generic(pool_win none 0)
add_test_generic(pool_win none 1)
add_test_generic(pool_win none 2)
add_test_generic(pool_win none 3)

add_test_generic(pool_primitives none)
add_test_generic(pool_primitives pmemcheck)

Expand Down
Loading

0 comments on commit fb6077b

Please sign in to comment.