mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
Fix PR #1600
This commit is contained in:
parent
3ebe42c400
commit
7fe60279de
7 changed files with 56 additions and 38 deletions
38
tests/CMakeLists.txt
Normal file
38
tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
enable_testing()
|
||||
add_test(NAME dummy_test COMMAND dummy_test)
|
||||
|
||||
# Find GTest
|
||||
|
||||
add_executable(dummy_test dummy_test.cpp)
|
||||
|
||||
find_package(GTest)
|
||||
|
||||
if(NOT GTEST_FOUND)
|
||||
IF(NOT EXISTS "${CMAKE_BINARY_DIR}/gtest-build")
|
||||
message(STATUS "Downloading googletest")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/cmake/gtest-CMakeLists.txt.in" "${CMAKE_BINARY_DIR}/gtest-download/CMakeLists.txt")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download )
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/gtest-download )
|
||||
ELSE()
|
||||
message(STATUS "GoogleTest directory exists")
|
||||
ENDIF()
|
||||
|
||||
# Add gtest directly to our build
|
||||
add_subdirectory(${CMAKE_BINARY_DIR}/gtest-src
|
||||
${CMAKE_BINARY_DIR}/gtest-build
|
||||
EXCLUDE_FROM_ALL )
|
||||
|
||||
# Add the gtest include directory, since gtest
|
||||
# doesn't add that dependency to its gtest target
|
||||
target_include_directories(gtest INTERFACE
|
||||
"${CMAKE_BINARY_DIR}/gtest-src/include" )
|
||||
|
||||
SET(GTEST_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/gtest-src/include")
|
||||
SET(GTEST_BOTH_LIBRARIES gtest)
|
||||
add_dependencies(dummy_test gtest)
|
||||
endif()
|
||||
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
target_link_libraries(dummy_test ${GTEST_BOTH_LIBRARIES})
|
||||
16
tests/dummy_test.cpp
Normal file
16
tests/dummy_test.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
class FooTest : public ::testing::Test {
|
||||
|
||||
};
|
||||
|
||||
TEST(DummyTest, Works) {
|
||||
ASSERT_EQ(1, 1) << "One is not equal to one";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue