build: add option for running tests

cmake configuration for running tests is now in the
tests folder.

Add option in main cmake file that has to be set to
ON and only build the tests in that case.

Update appveyor and travis ci configurations accordingly.
This commit is contained in:
Petra Baranski
2023-07-23 06:04:29 +02:00
parent 6dd47f5de5
commit 87ec259c28
7 changed files with 44 additions and 34 deletions

28
tests/CMakeLists.txt Normal file
View File

@@ -0,0 +1,28 @@
# This project is licensed under the MIT license. For more information see the
# LICENSE file.
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG b796f7d44681514f58a683a3a71ff17c94edb0c1 # v1.13.0
)
FetchContent_MakeAvailable(googletest)
# ------------------------------------------------------------------------------
file(GLOB_RECURSE MADDY_TESTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/maddy/*.cpp)
# ------------------------------------------------------------------------------
add_executable(
MaddyTests
${MADDY_TESTS_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)
target_include_directories(MaddyTests PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(MaddyTests maddy gmock_main)
add_test(MaddyTests MaddyTests)