2013-04-22 14:49:28 +00:00
|
|
|
enable_testing()
|
2017-07-09 18:31:21 +02:00
|
|
|
|
|
|
|
set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
|
2017-08-15 21:17:00 +03:00
|
|
|
if(EXISTS ${googleTest_Dir})
|
2017-08-12 21:58:09 +03:00
|
|
|
set(GTestSrc ${googleTest_Dir}/googletest)
|
|
|
|
set(GMockSrc ${googleTest_Dir}/googlemock)
|
2017-08-15 21:17:00 +03:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "No googletest src dir found!")
|
|
|
|
endif()
|
2017-07-09 18:31:21 +02:00
|
|
|
include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include)
|
2016-08-12 09:38:26 +03:00
|
|
|
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test)
|
2017-07-02 01:53:50 +03:00
|
|
|
include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
|
2013-04-22 14:49:28 +00:00
|
|
|
|
|
|
|
set(test_SRCS
|
2017-07-04 13:29:50 +02:00
|
|
|
StdInc.cpp
|
|
|
|
main.cpp
|
|
|
|
CMemoryBufferTest.cpp
|
|
|
|
CVcmiTestConfig.cpp
|
|
|
|
|
|
|
|
battle/BattleHexTest.cpp
|
|
|
|
battle/CHealthTest.cpp
|
|
|
|
|
|
|
|
map/CMapEditManagerTest.cpp
|
|
|
|
map/CMapFormatTest.cpp
|
|
|
|
map/MapComparer.cpp
|
2017-06-29 02:03:37 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
set(test_HEADERS
|
2017-07-04 13:29:50 +02:00
|
|
|
StdInc.h
|
|
|
|
|
|
|
|
CVcmiTestConfig.h
|
|
|
|
map/MapComparer.h
|
2013-04-22 14:49:28 +00:00
|
|
|
)
|
|
|
|
|
2017-08-15 21:17:00 +03:00
|
|
|
assign_source_group(${test_SRCS} ${test_HEADERS})
|
|
|
|
|
2017-07-18 21:04:57 +02:00
|
|
|
set(mock_HEADERS
|
|
|
|
mock/mock_UnitHealthInfo.h
|
|
|
|
)
|
2017-08-15 21:17:00 +03:00
|
|
|
|
2017-08-07 19:43:32 +03:00
|
|
|
add_subdirectory_with_folder("3rdparty" googletest EXCLUDE_FROM_ALL)
|
2017-07-09 18:31:21 +02:00
|
|
|
|
2017-07-18 21:04:57 +02:00
|
|
|
add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc)
|
2017-07-09 18:31:21 +02:00
|
|
|
target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB})
|
2013-04-22 14:49:28 +00:00
|
|
|
add_test(vcmitest vcmitest)
|
|
|
|
|
2017-07-04 23:46:49 +03:00
|
|
|
vcmi_set_output_dir(vcmitest "")
|
|
|
|
|
2014-02-05 20:25:36 +00:00
|
|
|
set_target_properties(vcmitest PROPERTIES ${PCH_PROPERTIES})
|
|
|
|
cotire(vcmitest)
|
2014-02-01 13:37:26 +00:00
|
|
|
|
2013-04-25 16:09:48 +00:00
|
|
|
# Files to copy to the build directory
|
2013-04-22 14:49:28 +00:00
|
|
|
set(vcmitest_FILES
|
2016-11-13 13:38:42 +03:00
|
|
|
testdata/TerrainViewTest.h3m
|
|
|
|
testdata/terrainViewMappings.json
|
|
|
|
testdata/ObjectPropertyTest/header.json
|
|
|
|
testdata/ObjectPropertyTest/objects.json
|
|
|
|
testdata/ObjectPropertyTest/surface_terrain.json
|
|
|
|
testdata/ObjectPropertyTest/underground_terrain.json
|
2013-04-22 14:49:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
foreach(file ${vcmitest_FILES})
|
2017-08-11 05:31:23 +03:00
|
|
|
add_custom_command(TARGET vcmitest POST_BUILD
|
2017-08-15 21:17:00 +03:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR}
|
2017-07-04 13:29:50 +02:00
|
|
|
)
|
2013-04-22 14:49:28 +00:00
|
|
|
endforeach()
|