mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
CMake for tests in its own folder
Besides making it more simple to add a new test now since you don't need to play hide and seek with the main cmake this has another good thing: on IDE's that scan the cmake to create targets on the project tree, the main project was being popullated with test-targets on the main tree and not inside the tests directory. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1d6683f3e0
commit
044e593957
2 changed files with 34 additions and 25 deletions
|
@ -11,8 +11,8 @@ option(LIBGIT2_FROM_PKGCONFIG "use pkg-config to retrieve libgit2" OFF)
|
||||||
option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF)
|
option(LIBDC_FROM_PKGCONFIG "use pkg-config to retrieve libdivecomputer" OFF)
|
||||||
option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF)
|
option(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" OFF)
|
||||||
option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
|
option(LIBMARBLE_FROM_PKGCONFIG "use pkg-config to retrieve marble" OFF)
|
||||||
|
option(MAKE_TESTS "Make the tests" ON)
|
||||||
option(NO_MARBLE "disable the marble widget" OFF)
|
option(NO_MARBLE "disable the marble widget" OFF)
|
||||||
option(NO_TESTS "disable the tests" OFF)
|
|
||||||
option(NO_DOCS "disable the docs" OFF)
|
option(NO_DOCS "disable the docs" OFF)
|
||||||
option(NO_PRINTING "disable the printing support" OFF)
|
option(NO_PRINTING "disable the printing support" OFF)
|
||||||
option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
|
option(NO_USERMANUAL "don't include a viewer for the user manual" OFF)
|
||||||
|
@ -340,7 +340,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT ANDROID)
|
||||||
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread)
|
set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} -lpthread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
# create the executables
|
# create the executables
|
||||||
if(SUBSURFACE_MOBILE)
|
if(SUBSURFACE_MOBILE)
|
||||||
set(MOBILE_SRC
|
set(MOBILE_SRC
|
||||||
|
@ -410,29 +409,6 @@ endif()
|
||||||
add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES})
|
add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES})
|
||||||
target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
|
target_link_libraries(export-html subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
|
||||||
|
|
||||||
# QTest based tests
|
|
||||||
macro(TEST NAME FILE)
|
|
||||||
add_executable(${NAME} EXCLUDE_FROM_ALL tests/${FILE} ${SUBSURFACE_RESOURCES})
|
|
||||||
target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES})
|
|
||||||
add_test(NAME ${NAME}_build COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${NAME})
|
|
||||||
add_test(NAME ${NAME}_run COMMAND ${NAME})
|
|
||||||
set_tests_properties(${NAME}_run PROPERTIES DEPENDS ${NAME}_build)
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
|
|
||||||
add_definitions(-g)
|
|
||||||
if(NOT NO_TESTS)
|
|
||||||
enable_testing()
|
|
||||||
TEST(TestUnitConversion testunitconversion.cpp)
|
|
||||||
TEST(TestProfile testprofile.cpp)
|
|
||||||
TEST(TestGpsCoords testgpscoords.cpp)
|
|
||||||
TEST(TestParse testparse.cpp)
|
|
||||||
TEST(TestPlan testplan.cpp)
|
|
||||||
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
|
|
||||||
TEST(TestRenumber testrenumber.cpp)
|
|
||||||
TEST(TestGitStorage testgitstorage.cpp)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# install a few things so that one can run Subsurface from the build
|
# install a few things so that one can run Subsurface from the build
|
||||||
# directory
|
# directory
|
||||||
if(NOT insource)
|
if(NOT insource)
|
||||||
|
@ -661,7 +637,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# get_cmake_property(_variableNames VARIABLES)
|
# get_cmake_property(_variableNames VARIABLES)
|
||||||
# foreach (_variableName ${_variableNames})
|
# foreach (_variableName ${_variableNames})
|
||||||
# message(STATUS "${_variableName}=${${_variableName}}")
|
# message(STATUS "${_variableName}=${${_variableName}}")
|
||||||
# endforeach()
|
# endforeach()
|
||||||
|
|
||||||
|
if (MAKE_TESTS)
|
||||||
|
add_subdirectory(tests)
|
||||||
|
endif()
|
||||||
|
|
28
tests/CMakeLists.txt
Normal file
28
tests/CMakeLists.txt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# QTest based tests
|
||||||
|
macro(TEST NAME FILE)
|
||||||
|
add_executable(${NAME} ${FILE} ${SUBSURFACE_RESOURCES})
|
||||||
|
target_link_libraries(${NAME} subsurface_corelib ${QT_TEST_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES})
|
||||||
|
add_test(NAME ${NAME} COMMAND $<TARGET_FILE:${NAME}>)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
add_definitions(-g)
|
||||||
|
TEST(TestUnitConversion testunitconversion.cpp)
|
||||||
|
TEST(TestProfile testprofile.cpp)
|
||||||
|
TEST(TestGpsCoords testgpscoords.cpp)
|
||||||
|
TEST(TestParse testparse.cpp)
|
||||||
|
TEST(TestPlan testplan.cpp)
|
||||||
|
TEST(TestDiveSiteDuplication testdivesiteduplication.cpp)
|
||||||
|
TEST(TestRenumber testrenumber.cpp)
|
||||||
|
TEST(TestGitStorage testgitstorage.cpp)
|
||||||
|
|
||||||
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
DEPENDS
|
||||||
|
TestUnitConversion
|
||||||
|
TestProfile
|
||||||
|
TestGpsCoords
|
||||||
|
TestParse
|
||||||
|
TestGitStorage
|
||||||
|
TestPlan
|
||||||
|
TestDiveSiteDuplication
|
||||||
|
)
|
Loading…
Reference in a new issue