Skip to content

Commit

Permalink
Add appveyor
Browse files Browse the repository at this point in the history
Fix build on windows
  • Loading branch information
Nicolas CATTANEO committed Mar 5, 2018
1 parent 321595a commit 86c4853
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

include(ExternalProject)
project(wave)
project(wave CXX)
include(CTest)

# build options
option(wave_enable_tests "Build Unit tests" ON)
Expand All @@ -11,20 +12,20 @@ if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)
# use of c++14
set(CMAKE_CXX_STANDARD 14)
endif()
if(wave_enable_tests)

if (${wave_enable_tests})
enable_testing()

set(gtest_install_dir ${CMAKE_BINARY_DIR}/googletest-install)
ExternalProject_Add(googletest
set(gtest_install_dir ${CMAKE_BINARY_DIR}/gtest-install)
ExternalProject_Add(external_googletest
GIT_REPOSITORY "https://github.com/google/googletest.git"
GIT_TAG "release-1.8.0"
UPDATE_COMMAND ""
CMAKE_ARGS
"-Dgtest_force_shared_crt=ON"
"-DCMAKE_INSTALL_PREFIX=${gtest_install_dir}"
)
link_directories("${gtest_install_dir}/lib")

set(GTEST_ROOT "${gtest_install_dir}" CACHE PATH "Path to googletest")

# download test resource from https://archive.org/details/test_wav
set(test_resource_path "${CMAKE_BINARY_DIR}/test_resource")
file(MAKE_DIRECTORY "${test_resource_path}")
Expand Down
28 changes: 14 additions & 14 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
version: 0.4.{build}a
version: 1.0.{build}

branches:
only:
- master

before_build:
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%/build/install ..
image:
- Visual Studio 2015
- Visual Studio 2017
init:
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

build_script:
- cd %APPVEYOR_BUILD_FOLDER%
- mkdir build
- cd build
- cmake ..
- cmake --build .
- cmake --build . --target install --config Release

test_script:
- cmd /c %APPVEYOR_BUILD_FOLDER%/build/src/wave/Debug/wave_tests.exe
- cmd: C:/projects/wave/build/src/wave/Debug/wave_test.exe --gtest_output=xml:tests.xml

after_test:
- ps: (new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests.xml))

artifacts:
- path: build/install
on_finish:
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
19 changes: 14 additions & 5 deletions src/wave/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,33 @@ install(FILES

# tests
if (${wave_enable_tests})
include(GoogleTest)
add_executable(wave_tests
${src}/wave/file_test.cc
)
add_dependencies(wave_tests googletest)

add_dependencies(wave_tests
external_googletest)

if (UNIX AND NOT APPLE)
target_link_libraries(wave_tests
gtest
gtest_main
wave
pthread
gtest
gtest_main
)
else()
target_link_libraries(wave_tests
gtest
gtest_main
optimized gtest
optimized gtest_main
debug gtestd
debug gtest_maind
wave
)
endif()

gtest_discover_tests( wave_tests )

target_include_directories(wave_tests
PUBLIC
${gtest_install_dir}/include
Expand Down

0 comments on commit 86c4853

Please sign in to comment.