Add executable to run CS tests

depth-refraction
elsid 2 years ago
parent 59f2fccc9f
commit 6f6e452dfa
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -1117,6 +1117,7 @@ fi
if [ -n "${TEST_FRAMEWORK}" ]; then if [ -n "${TEST_FRAMEWORK}" ]; then
add_cmake_opts -DBUILD_UNITTESTS=ON add_cmake_opts -DBUILD_UNITTESTS=ON
add_cmake_opts -DBUILD_OPENCS_TESTS=ON
fi fi
if [ -n "$ACTIVATE_MSVC" ]; then if [ -n "$ACTIVATE_MSVC" ]; then

@ -54,13 +54,14 @@ option(BUILD_UNITTESTS "Enable Unittests with Google C++ Unittest" OFF)
option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF) option(BUILD_BENCHMARKS "Build benchmarks with Google Benchmark" OFF)
option(BUILD_NAVMESHTOOL "Build navmesh tool" ON) option(BUILD_NAVMESHTOOL "Build navmesh tool" ON)
option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON) option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON)
option(BUILD_OPENCS_TESTS "Build OpenMW Construction Set tests" OFF)
set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up. set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up.
if (NOT BUILD_LAUNCHER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD) if (BUILD_LAUNCHER OR BUILD_OPENCS OR BUILD_WIZARD OR BUILD_OPENCS_TESTS)
set(USE_QT FALSE)
else()
set(USE_QT TRUE) set(USE_QT TRUE)
else()
set(USE_QT FALSE)
endif() endif()
# If the user doesn't supply a CMAKE_BUILD_TYPE via command line, choose one for them. # If the user doesn't supply a CMAKE_BUILD_TYPE via command line, choose one for them.
@ -294,6 +295,11 @@ if (OPENMW_USE_SYSTEM_YAML_CPP)
find_package(yaml-cpp REQUIRED) find_package(yaml-cpp REQUIRED)
endif() endif()
if ((BUILD_UNITTESTS OR BUILD_OPENCS_TESTS) AND OPENMW_USE_SYSTEM_GOOGLETEST)
find_package(GTest 1.10 REQUIRED)
find_package(GMock 1.10 REQUIRED)
endif()
add_subdirectory(extern) add_subdirectory(extern)
# Sound setup # Sound setup
@ -621,7 +627,7 @@ endif (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clan
add_subdirectory (extern/osg-ffmpeg-videoplayer) add_subdirectory (extern/osg-ffmpeg-videoplayer)
add_subdirectory (extern/oics) add_subdirectory (extern/oics)
add_subdirectory (extern/Base64) add_subdirectory (extern/Base64)
if (BUILD_OPENCS AND Qt5_FOUND) if ((BUILD_OPENCS OR BUILD_OPENCS_TESTS) AND Qt5_FOUND)
add_subdirectory (extern/osgQt) add_subdirectory (extern/osgQt)
endif() endif()
@ -657,7 +663,7 @@ if (BUILD_ESSIMPORTER)
add_subdirectory (apps/essimporter ) add_subdirectory (apps/essimporter )
endif() endif()
if (BUILD_OPENCS) if (BUILD_OPENCS OR BUILD_OPENCS_TESTS)
add_subdirectory (apps/opencs) add_subdirectory (apps/opencs)
endif() endif()
@ -686,6 +692,10 @@ if (BUILD_BULLETOBJECTTOOL)
add_subdirectory( apps/bulletobjecttool ) add_subdirectory( apps/bulletobjecttool )
endif() endif()
if (BUILD_OPENCS_TESTS)
add_subdirectory(apps/opencs_tests)
endif()
if (WIN32) if (WIN32)
if (MSVC) if (MSVC)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )

@ -176,18 +176,25 @@ add_library(openmw-cs-lib
set_target_properties(openmw-cs-lib PROPERTIES OUTPUT_NAME openmw-cs) set_target_properties(openmw-cs-lib PROPERTIES OUTPUT_NAME openmw-cs)
openmw_add_executable(openmw-cs if(BUILD_OPENCS)
openmw_add_executable(openmw-cs
MACOSX_BUNDLE MACOSX_BUNDLE
${OPENCS_MAC_ICON} ${OPENCS_MAC_ICON}
${OPENCS_CFG} ${OPENCS_CFG}
${OPENCS_DEFAULT_FILTERS_FILE} ${OPENCS_DEFAULT_FILTERS_FILE}
${OPENCS_OPENMW_CFG} ${OPENCS_OPENMW_CFG}
main.cpp main.cpp
) )
target_link_libraries(openmw-cs openmw-cs-lib) target_link_libraries(openmw-cs openmw-cs-lib)
if(APPLE) if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-lib PRIVATE --coverage)
target_link_libraries(openmw-cs-lib gcov)
endif()
endif()
if(APPLE AND BUILD_OPENCS)
set(OPENCS_BUNDLE_NAME "OpenMW-CS") set(OPENCS_BUNDLE_NAME "OpenMW-CS")
set(OPENCS_BUNDLE_RESOURCES_DIR "${OpenMW_BINARY_DIR}/${OPENCS_BUNDLE_NAME}.app/Contents/Resources") set(OPENCS_BUNDLE_RESOURCES_DIR "${OpenMW_BINARY_DIR}/${OPENCS_BUNDLE_NAME}.app/Contents/Resources")
@ -218,7 +225,7 @@ if(APPLE)
add_custom_command(TARGET openmw-cs add_custom_command(TARGET openmw-cs
POST_BUILD POST_BUILD
COMMAND cp "${OpenMW_BINARY_DIR}/resources/version" "${OPENCS_BUNDLE_RESOURCES_DIR}/resources") COMMAND cp "${OpenMW_BINARY_DIR}/resources/version" "${OPENCS_BUNDLE_RESOURCES_DIR}/resources")
endif(APPLE) endif()
target_link_libraries(openmw-cs-lib target_link_libraries(openmw-cs-lib
# CMake's built-in OSG finder does not use pkgconfig, so we have to # CMake's built-in OSG finder does not use pkgconfig, so we have to
@ -240,6 +247,9 @@ target_link_libraries(openmw-cs-lib Qt::Widgets Qt::Core Qt::Network Qt::OpenGL)
if (WIN32) if (WIN32)
target_link_libraries(openmw-cs-lib ${Boost_LOCALE_LIBRARY}) target_link_libraries(openmw-cs-lib ${Boost_LOCALE_LIBRARY})
endif()
if (WIN32 AND BUILD_OPENCS)
INSTALL(TARGETS openmw-cs RUNTIME DESTINATION ".") INSTALL(TARGETS openmw-cs RUNTIME DESTINATION ".")
get_generator_is_multi_config(multi_config) get_generator_is_multi_config(multi_config)
@ -259,8 +269,7 @@ if (MSVC)
endif (CMAKE_CL_64) endif (CMAKE_CL_64)
endif (MSVC) endif (MSVC)
if(APPLE AND BUILD_OPENCS)
if(APPLE)
INSTALL(TARGETS openmw-cs BUNDLE DESTINATION "." COMPONENT Bundle) INSTALL(TARGETS openmw-cs BUNDLE DESTINATION "." COMPONENT Bundle)
endif() endif()
@ -271,8 +280,6 @@ endif(USE_QT)
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-lib PRIVATE --coverage) target_compile_options(openmw-cs-lib PRIVATE --coverage)
target_link_libraries(openmw-cs-lib gcov) target_link_libraries(openmw-cs-lib gcov)
target_compile_options(openmw-cs PRIVATE --coverage)
target_link_libraries(openmw-cs gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -0,0 +1,31 @@
file(GLOB OPENCS_TESTS_SRC_FILES
main.cpp
)
source_group(apps\\openmw-cs-tests FILES ${OPENCS_TESTS_SRC_FILES})
openmw_add_executable(openmw-cs-tests ${OPENCS_TESTS_SRC_FILES})
target_include_directories(openmw-cs-tests SYSTEM PRIVATE ${GTEST_INCLUDE_DIRS})
target_include_directories(openmw-cs-tests SYSTEM PRIVATE ${GMOCK_INCLUDE_DIRS})
target_link_libraries(openmw-cs-tests PRIVATE
openmw-cs-lib
GTest::GTest
GMock::GMock
)
if (UNIX AND NOT APPLE)
target_link_libraries(openmw-cs-tests PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs-tests PRIVATE --coverage)
target_link_libraries(openmw-cs-tests PRIVATE gcov)
endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-cs-tests PRIVATE
<gtest/gtest.h>
)
endif()

@ -0,0 +1,7 @@
#include <gtest/gtest.h>
int main(int argc, char* argv[])
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

@ -1,8 +1,3 @@
if (OPENMW_USE_SYSTEM_GOOGLETEST)
find_package(GTest 1.10 REQUIRED)
find_package(GMock 1.10 REQUIRED)
endif()
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS}) include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS})

@ -303,7 +303,7 @@ if (NOT OPENMW_USE_SYSTEM_ICU)
set(ICU_LIBRARIES ICU::i18n ICU::uc ICU::data PARENT_SCOPE) set(ICU_LIBRARIES ICU::i18n ICU::uc ICU::data PARENT_SCOPE)
endif() endif()
if (BUILD_UNITTESTS AND NOT OPENMW_USE_SYSTEM_GOOGLETEST) if ((BUILD_UNITTESTS OR BUILD_OPENCS_TESTS) AND NOT OPENMW_USE_SYSTEM_GOOGLETEST)
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.11)
include(FetchContent) include(FetchContent)

Loading…
Cancel
Save