From 044e593957acc8de045c02003fa468bd76c98767 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 3 Sep 2015 17:10:50 -0300 Subject: 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 Signed-off-by: Dirk Hohndel --- CMakeLists.txt | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b0195a6..7abe3d6c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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(LIBGRANTLEE_FROM_PKGCONFIG "use pkg-config to retrieve grantlee" 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_TESTS "disable the tests" OFF) option(NO_DOCS "disable the docs" OFF) option(NO_PRINTING "disable the printing support" 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) endif() - # create the executables if(SUBSURFACE_MOBILE) set(MOBILE_SRC @@ -410,29 +409,6 @@ endif() add_executable(export-html EXCLUDE_FROM_ALL export-html.cpp ${SUBSURFACE_RESOURCES}) 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 # directory if(NOT insource) @@ -661,7 +637,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() endif() + # get_cmake_property(_variableNames VARIABLES) # foreach (_variableName ${_variableNames}) # message(STATUS "${_variableName}=${${_variableName}}") # endforeach() + +if (MAKE_TESTS) + add_subdirectory(tests) +endif() -- cgit v1.2.3-70-g09d2