2022-12-17 18:33:01 +01:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
2016-11-28 23:27:21 +01:00
|
|
|
|
2021-11-14 21:34:45 +01:00
|
|
|
find_package(GTest REQUIRED)
|
2017-07-26 10:50:00 +02:00
|
|
|
|
2021-11-14 21:34:45 +01:00
|
|
|
set(GTEST_LIBRARIES ${GTEST_BOTH_LIBRARIES})
|
2017-07-26 10:50:00 +02:00
|
|
|
|
2017-07-26 10:39:17 +02:00
|
|
|
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
|
2017-05-08 18:35:15 +02:00
|
|
|
include_directories("${ROOT_DIR}/src")
|
2020-10-09 06:28:34 +02:00
|
|
|
include_directories(SYSTEM ${SDL2_INCLUDE_DIRS})
|
2016-11-30 11:51:55 +01:00
|
|
|
|
2017-02-24 23:04:20 +01:00
|
|
|
# Some most common files required in tests
|
|
|
|
set(COMMON_TEST_SOURCES
|
2017-05-08 18:35:15 +02:00
|
|
|
"${ROOT_DIR}/src/openrct2/core/Console.cpp"
|
|
|
|
"${ROOT_DIR}/src/openrct2/core/Diagnostics.cpp"
|
|
|
|
"${ROOT_DIR}/src/openrct2/core/Guard.cpp"
|
|
|
|
"${ROOT_DIR}/src/openrct2/core/String.cpp"
|
2017-12-12 14:52:57 +01:00
|
|
|
"${ROOT_DIR}/src/openrct2/Diagnostic.cpp"
|
2018-04-15 19:19:55 +02:00
|
|
|
"${ROOT_DIR}/src/openrct2/localisation/ConversionTables.cpp"
|
|
|
|
"${ROOT_DIR}/src/openrct2/localisation/Convert.cpp"
|
2018-01-06 18:32:25 +01:00
|
|
|
"${ROOT_DIR}/src/openrct2/localisation/FormatCodes.cpp"
|
|
|
|
"${ROOT_DIR}/src/openrct2/localisation/UTF8.cpp"
|
2017-12-13 13:02:24 +01:00
|
|
|
"${ROOT_DIR}/src/openrct2/util/Util.cpp"
|
2017-05-08 18:35:15 +02:00
|
|
|
"${ROOT_DIR}/src/openrct2/Version.cpp"
|
2017-05-08 18:28:33 +02:00
|
|
|
)
|
2017-02-24 23:04:20 +01:00
|
|
|
|
|
|
|
# Create a re-usable library to save some compilation time
|
|
|
|
add_library(test-common STATIC ${COMMON_TEST_SOURCES})
|
2020-07-25 09:09:15 +02:00
|
|
|
set_target_properties(test-common PROPERTIES COMPILE_DEFINITIONS DISABLE_HTTP)
|
2017-02-24 23:04:20 +01:00
|
|
|
|
2017-06-05 23:08:14 +02:00
|
|
|
# Setup testdata. It should be fine here, as the only way to reach here is by explicitly requesting tests.
|
2018-04-10 13:36:51 +02:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_LIST_DIR}/testdata" "${CMAKE_CURRENT_BINARY_DIR}/testdata")
|
2018-04-10 20:14:27 +02:00
|
|
|
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_DATADIR}/openrct2\" \"${CMAKE_CURRENT_BINARY_DIR}/data\")")
|
2017-06-05 23:08:14 +02:00
|
|
|
|
2018-05-15 16:37:41 +02:00
|
|
|
if (NOT MINGW AND NOT MSVC)
|
|
|
|
# For unicode code page conversion (required for ini and string tests)
|
|
|
|
find_package(ICU 59.0 REQUIRED COMPONENTS uc)
|
|
|
|
target_link_libraries(test-common ${ICU_LIBRARIES})
|
2018-12-19 23:31:24 +01:00
|
|
|
target_include_directories(test-common SYSTEM PUBLIC ${ICU_INCLUDE_DIRS})
|
2018-05-15 16:37:41 +02:00
|
|
|
endif ()
|
2018-05-06 16:53:42 +02:00
|
|
|
|
2016-11-28 14:37:27 +01:00
|
|
|
# Start of our tests
|
2016-11-28 23:27:21 +01:00
|
|
|
|
2016-11-30 11:51:55 +01:00
|
|
|
# sawyercoding test
|
|
|
|
|
2016-12-28 13:39:21 +01:00
|
|
|
set(SAWYERCODING_TEST_SOURCES
|
2023-01-18 07:06:54 +01:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/SawyerCodingTest.cpp"
|
2017-05-08 18:28:33 +02:00
|
|
|
)
|
2016-11-28 14:33:50 +01:00
|
|
|
add_executable(test_sawyercoding ${SAWYERCODING_TEST_SOURCES})
|
2021-02-13 03:50:29 +01:00
|
|
|
target_link_libraries(test_sawyercoding ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_sawyercoding)
|
2016-11-30 11:51:55 +01:00
|
|
|
add_test(NAME sawyercoding COMMAND test_sawyercoding)
|
|
|
|
|
|
|
|
# LanguagePack test
|
|
|
|
set(LANGUAGEPACK_TEST_SOURCES
|
2017-05-08 18:35:15 +02:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/LanguagePackTest.cpp"
|
2017-05-08 18:28:33 +02:00
|
|
|
)
|
2016-11-30 11:51:55 +01:00
|
|
|
add_executable(test_languagepack ${LANGUAGEPACK_TEST_SOURCES})
|
2017-06-25 23:01:59 +02:00
|
|
|
if (UNIX AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
|
|
|
# Include libdl for dlopen
|
|
|
|
set(LDL dl)
|
|
|
|
endif ()
|
2021-02-13 03:50:29 +01:00
|
|
|
target_link_libraries(test_languagepack ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_languagepack)
|
2016-12-15 17:55:17 +01:00
|
|
|
add_test(NAME languagepack COMMAND test_languagepack)
|
2017-02-23 23:26:11 +01:00
|
|
|
|
2017-02-24 23:04:20 +01:00
|
|
|
# INI test
|
2017-02-23 23:26:11 +01:00
|
|
|
set(INI_TEST_SOURCES
|
2017-05-08 18:35:15 +02:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/IniWriterTest.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/IniReaderTest.cpp"
|
2017-05-08 18:28:33 +02:00
|
|
|
)
|
2017-02-23 23:26:11 +01:00
|
|
|
add_executable(test_ini ${INI_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_ini)
|
2021-02-13 03:50:29 +01:00
|
|
|
target_link_libraries(test_ini ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_ini)
|
2017-02-23 23:26:11 +01:00
|
|
|
add_test(NAME ini COMMAND test_ini)
|
2017-02-24 23:04:36 +01:00
|
|
|
|
2019-03-02 14:40:24 +01:00
|
|
|
# Platform
|
|
|
|
add_executable(test_platform ${CMAKE_CURRENT_LIST_DIR}/Platform.cpp)
|
|
|
|
SET_CHECK_CXX_FLAGS(test_platform)
|
|
|
|
target_link_libraries(test_platform ${GTEST_LIBRARIES} test-common ${LDL} z libopenrct2)
|
|
|
|
target_link_platform_libraries(test_platform)
|
|
|
|
add_test(NAME platform COMMAND test_platform)
|
|
|
|
|
2017-02-24 23:04:36 +01:00
|
|
|
# String test
|
|
|
|
set(STRING_TEST_SOURCES
|
2017-05-08 18:35:15 +02:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/StringTest.cpp"
|
2017-05-08 18:28:33 +02:00
|
|
|
)
|
2017-02-24 23:04:36 +01:00
|
|
|
add_executable(test_string ${STRING_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_string)
|
2021-02-13 03:50:29 +01:00
|
|
|
target_link_libraries(test_string ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_string)
|
2017-02-24 23:04:36 +01:00
|
|
|
add_test(NAME string COMMAND test_string)
|
2017-06-03 15:39:40 +02:00
|
|
|
|
2020-10-19 21:37:07 +02:00
|
|
|
# Formatting tests
|
|
|
|
set(STRING_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/FormattingTests.cpp")
|
|
|
|
add_executable(test_formatting ${STRING_TEST_SOURCES})
|
|
|
|
SET_CHECK_CXX_FLAGS(test_formatting)
|
|
|
|
target_link_libraries(test_formatting ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
|
|
|
target_link_platform_libraries(test_formatting)
|
|
|
|
add_test(NAME formatting COMMAND test_formatting)
|
|
|
|
|
2018-04-15 19:19:55 +02:00
|
|
|
# Localisation test
|
|
|
|
set(STRING_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/Localisation.cpp")
|
|
|
|
add_executable(test_localisation ${STRING_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_localisation)
|
2021-02-13 03:50:29 +01:00
|
|
|
target_link_libraries(test_localisation ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_localisation)
|
2018-04-15 19:19:55 +02:00
|
|
|
add_test(NAME localisation COMMAND test_localisation)
|
2017-08-31 10:36:01 +02:00
|
|
|
|
2018-06-01 23:47:29 +02:00
|
|
|
if (NOT DISABLE_NETWORK)
|
|
|
|
# Crypt tests
|
|
|
|
add_executable(test_crypt "${CMAKE_CURRENT_LIST_DIR}/CryptTests.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_crypt)
|
2018-06-01 23:47:29 +02:00
|
|
|
target_link_libraries(test_crypt ${GTEST_LIBRARIES} libopenrct2)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_crypt)
|
2018-06-01 23:47:29 +02:00
|
|
|
add_test(NAME Crypt COMMAND test_crypt)
|
|
|
|
endif ()
|
2018-05-23 02:01:48 +02:00
|
|
|
|
2018-05-12 01:04:16 +02:00
|
|
|
# ImageImporter tests
|
|
|
|
add_executable(test_imageimporter "${CMAKE_CURRENT_LIST_DIR}/ImageImporterTests.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_imageimporter)
|
2018-05-12 01:04:16 +02:00
|
|
|
target_link_libraries(test_imageimporter ${GTEST_LIBRARIES} libopenrct2)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_imageimporter)
|
2018-05-12 01:04:16 +02:00
|
|
|
add_test(NAME ImageImporter COMMAND test_imageimporter)
|
|
|
|
|
2017-08-31 10:36:01 +02:00
|
|
|
# Ride ratings test
|
|
|
|
set(RIDE_RATINGS_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/RideRatings.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_ride_ratings ${RIDE_RATINGS_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_ride_ratings)
|
2017-08-31 10:36:01 +02:00
|
|
|
target_link_libraries(test_ride_ratings ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_ride_ratings)
|
2018-04-10 13:36:51 +02:00
|
|
|
add_test(NAME ride_ratings COMMAND test_ride_ratings)
|
2017-08-31 10:36:01 +02:00
|
|
|
|
|
|
|
# Multi-launch test
|
|
|
|
set(MULTILAUNCH_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/MultiLaunch.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_multilaunch ${MULTILAUNCH_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_multilaunch)
|
2017-08-31 10:36:01 +02:00
|
|
|
target_link_libraries(test_multilaunch ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_multilaunch)
|
2018-04-10 13:36:51 +02:00
|
|
|
add_test(NAME multilaunch COMMAND test_multilaunch)
|
2018-04-17 13:13:58 +02:00
|
|
|
|
|
|
|
# Tile element test
|
|
|
|
set(TILE_ELEMENT_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/TileElements.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_tile_elements ${TILE_ELEMENT_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_tile_elements)
|
2018-04-17 19:44:20 +02:00
|
|
|
target_link_libraries(test_tile_elements ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_tile_elements)
|
2018-04-17 13:13:58 +02:00
|
|
|
add_test(NAME tile_elements COMMAND test_tile_elements)
|
2018-12-11 09:57:04 +01:00
|
|
|
|
2019-08-12 18:04:08 +02:00
|
|
|
# Replay tests
|
|
|
|
set(REPLAY_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/ReplayTests.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_replays ${REPLAY_TEST_SOURCES})
|
|
|
|
SET_CHECK_CXX_FLAGS(test_replays)
|
|
|
|
target_link_libraries(test_replays ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
|
|
|
target_link_platform_libraries(test_replays)
|
|
|
|
add_test(NAME replay_tests COMMAND test_replays)
|
2018-12-30 11:15:03 +01:00
|
|
|
|
2020-04-12 16:00:02 +02:00
|
|
|
# Play tests
|
|
|
|
set(PLAY_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/PlayTests.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_plays ${PLAY_TEST_SOURCES})
|
|
|
|
SET_CHECK_CXX_FLAGS(test_plays)
|
|
|
|
target_link_libraries(test_plays ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
|
|
|
target_link_platform_libraries(test_plays)
|
|
|
|
add_test(NAME play_tests COMMAND test_plays)
|
|
|
|
|
2018-12-30 11:15:03 +01:00
|
|
|
# Pathfinding test
|
|
|
|
set(PATHFINDING_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/Pathfinding.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_pathfinding ${PATHFINDING_TEST_SOURCES})
|
2019-02-03 23:32:51 +01:00
|
|
|
SET_CHECK_CXX_FLAGS(test_pathfinding)
|
2018-12-30 11:15:03 +01:00
|
|
|
target_link_libraries(test_pathfinding ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
2019-02-05 20:17:14 +01:00
|
|
|
target_link_platform_libraries(test_pathfinding)
|
2018-12-30 11:15:03 +01:00
|
|
|
add_test(NAME pathfinding COMMAND test_pathfinding)
|
2019-03-01 00:23:15 +01:00
|
|
|
|
2019-10-19 23:30:47 +02:00
|
|
|
# S6 Import/Export test
|
|
|
|
set(S6IMPORTEXPORT_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/S6ImportExportTests.cpp"
|
2019-03-01 00:23:15 +01:00
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
2019-10-19 23:30:47 +02:00
|
|
|
add_executable(test_s6importexporttests ${S6IMPORTEXPORT_TEST_SOURCES})
|
|
|
|
SET_CHECK_CXX_FLAGS(test_s6importexporttests)
|
|
|
|
target_link_libraries(test_s6importexporttests ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
|
|
|
target_link_platform_libraries(test_s6importexporttests)
|
|
|
|
add_test(NAME s6importexporttests COMMAND test_s6importexporttests)
|
2021-07-22 19:51:28 +02:00
|
|
|
|
|
|
|
# EnumMap Test
|
|
|
|
set(ENUMMAP_TEST_SOURCES "${CMAKE_CURRENT_LIST_DIR}/EnumMapTest.cpp.cpp"
|
|
|
|
"${CMAKE_CURRENT_LIST_DIR}/TestData.cpp")
|
|
|
|
add_executable(test_enummap ${S6IMPORTEXPORT_TEST_SOURCES})
|
|
|
|
SET_CHECK_CXX_FLAGS(test_enummap)
|
|
|
|
target_link_libraries(test_enummap ${GTEST_LIBRARIES} libopenrct2 ${LDL} z)
|
|
|
|
target_link_platform_libraries(test_enummap)
|
|
|
|
add_test(NAME enummaptests COMMAND test_enummap)
|