xref: /glogg/tests/CMakeLists.txt (revision f049f87fc315bc7e68fc0a52b15c5b79496761d2)
187e05652SNicolas BonnefonINCLUDE (CheckSymbolExists)
2f09fa651SNicolas BonnefonINCLUDE (CheckCXXSourceCompiles)
33104b268SNicolas BonnefonINCLUDE (CheckCXXCompilerFlag)
487e05652SNicolas Bonnefon
5f09fa651SNicolas Bonnefoncmake_minimum_required(VERSION 2.8.12)
684af0c9bSNicolas Bonnefonproject(glogg_tests)
784af0c9bSNicolas Bonnefon
887e05652SNicolas Bonnefon# Qt
91ee847caSNicolas Bonnefon
1084af0c9bSNicolas Bonnefonfind_program(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QT_DIR}/bin)
1184af0c9bSNicolas Bonnefonfind_package(Qt5Widgets REQUIRED)
121ee847caSNicolas Bonnefonfind_package(Qt5Test REQUIRED)
1384af0c9bSNicolas Bonnefon
1484af0c9bSNicolas Bonnefonset(CMAKE_AUTOMOC ON)
1584af0c9bSNicolas Bonnefonset(CMAKE_AUTOUIC ON)
1684af0c9bSNicolas Bonnefonset(CMAKE_INCLUDE_CURRENT_DIR ON)
1784af0c9bSNicolas Bonnefon
183104b268SNicolas Bonnefoncheck_cxx_compiler_flag(-Wall HAS_WALL)
193104b268SNicolas Bonnefon
203104b268SNicolas Bonnefonif(HAS_WALL)
213104b268SNicolas Bonnefon    set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall")
223104b268SNicolas Bonnefonendif(HAS_WALL)
233104b268SNicolas Bonnefon
24dfb2a39cSNicolas Bonnefon# Compiler
25dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
26dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
27dfb2a39cSNicolas Bonnefonif(COMPILER_SUPPORTS_CXX11)
28dfb2a39cSNicolas Bonnefon    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
29dfb2a39cSNicolas Bonnefonelseif(COMPILER_SUPPORTS_CXX0X)
30dfb2a39cSNicolas Bonnefon    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
31dfb2a39cSNicolas Bonnefonelse()
32dfb2a39cSNicolas Bonnefon    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
33dfb2a39cSNicolas Bonnefonendif()
3487e05652SNicolas Bonnefon
35f09fa651SNicolas Bonnefoncheck_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
36f09fa651SNicolas Bonnefon    #include <memory>
37f09fa651SNicolas Bonnefon    int main(int, int)
38f09fa651SNicolas Bonnefon    {
39f09fa651SNicolas Bonnefon        auto test = std::make_unique<void>();
40f09fa651SNicolas Bonnefon        return 0;
41f09fa651SNicolas Bonnefon    }
42f09fa651SNicolas Bonnefon" HAVE_MAKE_UNIQUE)
43f09fa651SNicolas Bonnefon
44dfb2a39cSNicolas Bonnefoncheck_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
45dfb2a39cSNicolas Bonnefon    #include <memory>
46dfb2a39cSNicolas Bonnefon    struct Base {
47dfb2a39cSNicolas Bonnefon        virtual void func() {}
48dfb2a39cSNicolas Bonnefon    };
49dfb2a39cSNicolas Bonnefon    struct Derived : public Base {
50dfb2a39cSNicolas Bonnefon        void func() override {}
51dfb2a39cSNicolas Bonnefon    }
52dfb2a39cSNicolas Bonnefon    int main(int, int)
53dfb2a39cSNicolas Bonnefon    {
54dfb2a39cSNicolas Bonnefon        return 0;
55dfb2a39cSNicolas Bonnefon    }
56dfb2a39cSNicolas Bonnefon" HAVE_OVERRIDE)
57dfb2a39cSNicolas Bonnefon
5887e05652SNicolas Bonnefonconfigure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
5987e05652SNicolas Bonnefon
60dfb2a39cSNicolas Bonnefon# Configuration
61dfb2a39cSNicolas Bonnefoncheck_symbol_exists( symlink "unistd.h" HAVE_SYMLINK )
62dfb2a39cSNicolas Bonnefon
6384af0c9bSNicolas Bonnefon# Setup testing
6484af0c9bSNicolas Bonnefonenable_testing()
6584af0c9bSNicolas Bonnefoninclude_directories(
6684af0c9bSNicolas Bonnefon    $ENV{GMOCK_HOME}/include
6784af0c9bSNicolas Bonnefon    $ENV{GMOCK_HOME}/gtest/include
6884af0c9bSNicolas Bonnefon    $ENV{BOOST_ROOT}/
69a0936e1eSNicolas Bonnefon    ../src/
70a0936e1eSNicolas Bonnefon)
7184af0c9bSNicolas Bonnefonlink_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest)
7284af0c9bSNicolas Bonnefon
7384af0c9bSNicolas Bonnefon# Sources
7484af0c9bSNicolas Bonnefonset(glogg_SOURCES
7584af0c9bSNicolas Bonnefon    ../src/session.cpp
7684af0c9bSNicolas Bonnefon    ../src/data/abstractlogdata.cpp
7784af0c9bSNicolas Bonnefon    ../src/data/logdata.cpp
7884af0c9bSNicolas Bonnefon    ../src/data/logfiltereddata.cpp
7984af0c9bSNicolas Bonnefon    ../src/data/logfiltereddataworkerthread.cpp
8084af0c9bSNicolas Bonnefon    ../src/data/logdataworkerthread.cpp
8184af0c9bSNicolas Bonnefon    ../src/mainwindow.cpp
8284af0c9bSNicolas Bonnefon    ../src/crawlerwidget.cpp
8384af0c9bSNicolas Bonnefon    ../src/abstractlogview.cpp
8484af0c9bSNicolas Bonnefon    ../src/logmainview.cpp
8584af0c9bSNicolas Bonnefon    ../src/filteredview.cpp
8684af0c9bSNicolas Bonnefon    ../src/optionsdialog.cpp
8784af0c9bSNicolas Bonnefon    ../src/persistentinfo.cpp
8884af0c9bSNicolas Bonnefon    ../src/configuration.cpp
8984af0c9bSNicolas Bonnefon    ../src/filtersdialog.cpp
9084af0c9bSNicolas Bonnefon    ../src/filterset.cpp
9184af0c9bSNicolas Bonnefon    ../src/savedsearches.cpp
9284af0c9bSNicolas Bonnefon    ../src/infoline.cpp
9384af0c9bSNicolas Bonnefon    ../src/menuactiontooltipbehavior.cpp
9484af0c9bSNicolas Bonnefon    ../src/selection.cpp
9584af0c9bSNicolas Bonnefon    ../src/quickfind.cpp
9684af0c9bSNicolas Bonnefon    ../src/quickfindpattern.cpp
9784af0c9bSNicolas Bonnefon    ../src/quickfindwidget.cpp
9884af0c9bSNicolas Bonnefon    ../src/sessioninfo.cpp
9984af0c9bSNicolas Bonnefon    ../src/recentfiles.cpp
10084af0c9bSNicolas Bonnefon    ../src/overview.cpp
10184af0c9bSNicolas Bonnefon    ../src/overviewwidget.cpp
10284af0c9bSNicolas Bonnefon    ../src/marks.cpp
10384af0c9bSNicolas Bonnefon    ../src/quickfindmux.cpp
10484af0c9bSNicolas Bonnefon    ../src/signalmux.cpp
10584af0c9bSNicolas Bonnefon    ../src/qtfilewatcher.cpp
10684af0c9bSNicolas Bonnefon    ../src/tabbedcrawlerwidget.cpp
10784af0c9bSNicolas Bonnefon    ../src/filewatcher.cpp
108c540156cSNicolas Bonnefon    ../src/watchtowerlist.cpp
109a0936e1eSNicolas Bonnefon    ../src/watchtower.cpp
11084b2179eSNicolas Bonnefon    ../src/platformfilewatcher.cpp
11187e05652SNicolas Bonnefon)
11284af0c9bSNicolas Bonnefon
11384af0c9bSNicolas Bonnefonset(glogg_HEADERS
11484af0c9bSNicolas Bonnefon    ../src/mainwindow.h
11584af0c9bSNicolas Bonnefon    ../src/marks.h
11684af0c9bSNicolas Bonnefon    ../src/filewatcher.h)
11784af0c9bSNicolas Bonnefon
1181ee847caSNicolas Bonnefon# Unit tests
1191ee847caSNicolas Bonnefonset(glogg_UTESTS
12084af0c9bSNicolas Bonnefon    watchtowerTest.cpp
121*f049f87fSNicolas Bonnefon    linepositionarrayTest.cpp
12284af0c9bSNicolas Bonnefon)
12384af0c9bSNicolas Bonnefon
1241ee847caSNicolas Bonnefon# Integration tests
1251ee847caSNicolas Bonnefonset(glogg_ITESTS
1261ee847caSNicolas Bonnefon    logdataTest.cpp
1271ee847caSNicolas Bonnefon)
1281ee847caSNicolas Bonnefon
1291ee847caSNicolas Bonnefon# Performance tests
1301ee847caSNicolas Bonnefonset(glogg_PTESTS
1311ee847caSNicolas Bonnefon    logdataPerfTest.cpp
13274d66bf4SNicolas Bonnefon    logfiltereddataPerfTest.cpp
1331ee847caSNicolas Bonnefon)
1341ee847caSNicolas Bonnefon
1351ee847caSNicolas Bonnefon
13684af0c9bSNicolas Bonnefon# Options
13784af0c9bSNicolas Bonnefonif (WIN32)
138a0936e1eSNicolas Bonnefon    set(FileWatcherEngine_SOURCES
139f09fa651SNicolas Bonnefon        ../src/winwatchtowerdriver.cpp
140a0936e1eSNicolas Bonnefon    )
14187e05652SNicolas Bonnefonelse (WIN32)
142c540156cSNicolas Bonnefon    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
14384af0c9bSNicolas Bonnefonendif (WIN32)
14484af0c9bSNicolas Bonnefon
14591f7c705SNicolas Bonnefon# Compiler flags
14691f7c705SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
14784af0c9bSNicolas Bonnefon
14884af0c9bSNicolas Bonnefon# Add test cpp file
14984af0c9bSNicolas Bonnefonadd_executable(glogg_tests
15084af0c9bSNicolas Bonnefon    ${glogg_SOURCES}
15184af0c9bSNicolas Bonnefon    ${FileWatcherEngine_SOURCES}
1521ee847caSNicolas Bonnefon    ${glogg_UTESTS}
15384af0c9bSNicolas Bonnefon)
15484af0c9bSNicolas Bonnefon
15584af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main
15684af0c9bSNicolas Bonnefontarget_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
15784af0c9bSNicolas Bonnefon
1581ee847caSNicolas Bonnefonadd_executable(glogg_itests
1591ee847caSNicolas Bonnefon    ${glogg_SOURCES}
1601ee847caSNicolas Bonnefon    ${FileWatcherEngine_SOURCES}
1611ee847caSNicolas Bonnefon    ${glogg_ITESTS}
1621ee847caSNicolas Bonnefon    itests.cpp
1631ee847caSNicolas Bonnefon)
1641ee847caSNicolas Bonnefon
1651ee847caSNicolas Bonnefontarget_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test)
1661ee847caSNicolas Bonnefon
1671ee847caSNicolas Bonnefonadd_executable(glogg_ptests
1681ee847caSNicolas Bonnefon    ${glogg_SOURCES}
1691ee847caSNicolas Bonnefon    ${FileWatcherEngine_SOURCES}
1701ee847caSNicolas Bonnefon    ${glogg_PTESTS}
1711ee847caSNicolas Bonnefon    itests.cpp
1721ee847caSNicolas Bonnefon)
1731ee847caSNicolas Bonnefon
1741ee847caSNicolas Bonnefontarget_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test)
1751ee847caSNicolas Bonnefon
17684af0c9bSNicolas Bonnefonadd_test(
17784af0c9bSNicolas Bonnefon    NAME glogg_tests
17884af0c9bSNicolas Bonnefon    COMMAND glogg_tests
17984af0c9bSNicolas Bonnefon)
180