🔧 Replaced gtest with catch2

This commit is contained in:
2018-12-15 12:18:07 +01:00
parent e83556ae74
commit cc0d44a01d
3 changed files with 23 additions and 22 deletions

View File

@ -1,20 +1,17 @@
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.13/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
if(NOT EXISTS "${CMAKE_BINARY_DIR}/catch/catch.hpp")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/catch")
message(STATUS "Downloading catch.hpp from https://github.com/catchorg/Catch2/")
file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/v2.5.0/catch.hpp"
"${CMAKE_BINARY_DIR}/catch/catch.hpp")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(REQUIRES gtest/1.8.1@bincrafters/stable BASIC_SETUP CMAKE_TARGETS BUILD missing)
add_executable(moFileReaderTest test.cpp)
target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(moFileReaderTest CONAN_PKG::gtest moFileReader)
target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/catch)
target_link_libraries(moFileReaderTest moFileReader)
add_test(NAME mo_test COMMAND moFileReaderTest)
add_custom_command(
TARGET moFileReaderTest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.mo $<TARGET_FILE_DIR:moFileReaderTest>/test.mo
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.mo $<TARGET_FILE_DIR:moFileReaderTest>/test.mo
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/test.mo ${CMAKE_CURRENT_BINARY_DIR}/test.mo
)