xref: /glogg/tests/CMakeLists.txt (revision 3104b26858f76d3848af58b8865d4e7d5735d2f8)
187e05652SNicolas BonnefonINCLUDE (CheckSymbolExists)
2f09fa651SNicolas BonnefonINCLUDE (CheckCXXSourceCompiles)
3*3104b268SNicolas BonnefonINCLUDE (CheckCXXCompilerFlag)
487e05652SNicolas Bonnefon
5f09fa651SNicolas Bonnefoncmake_minimum_required(VERSION 2.8.12)
684af0c9bSNicolas Bonnefonproject(glogg_tests)
784af0c9bSNicolas Bonnefon
887e05652SNicolas Bonnefon# Qt
984af0c9bSNicolas Bonnefonfind_program(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QT_DIR}/bin)
1084af0c9bSNicolas Bonnefonfind_package(Qt5Widgets REQUIRED)
1184af0c9bSNicolas Bonnefon
1284af0c9bSNicolas Bonnefonset(CMAKE_AUTOMOC ON)
1384af0c9bSNicolas Bonnefonset(CMAKE_AUTOUIC ON)
1484af0c9bSNicolas Bonnefonset(CMAKE_INCLUDE_CURRENT_DIR ON)
1584af0c9bSNicolas Bonnefon
16*3104b268SNicolas Bonnefoncheck_cxx_compiler_flag(-Wall HAS_WALL)
17*3104b268SNicolas Bonnefon
18*3104b268SNicolas Bonnefonif(HAS_WALL)
19*3104b268SNicolas Bonnefon    set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall")
20*3104b268SNicolas Bonnefonendif(HAS_WALL)
21*3104b268SNicolas Bonnefon
2287e05652SNicolas Bonnefon# Configuration
2387e05652SNicolas Bonnefoncheck_symbol_exists( symlink "unistd.h" HAVE_SYMLINK )
2487e05652SNicolas Bonnefon
25f09fa651SNicolas Bonnefoncheck_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
26f09fa651SNicolas Bonnefon    #include <memory>
27f09fa651SNicolas Bonnefon    int main(int, int)
28f09fa651SNicolas Bonnefon    {
29f09fa651SNicolas Bonnefon        auto test = std::make_unique<void>();
30f09fa651SNicolas Bonnefon        return 0;
31f09fa651SNicolas Bonnefon    }
32f09fa651SNicolas Bonnefon" HAVE_MAKE_UNIQUE)
33f09fa651SNicolas Bonnefon
3487e05652SNicolas Bonnefonconfigure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
3587e05652SNicolas Bonnefon
3684af0c9bSNicolas Bonnefon# Setup testing
3784af0c9bSNicolas Bonnefonenable_testing()
3884af0c9bSNicolas Bonnefoninclude_directories(
3984af0c9bSNicolas Bonnefon    $ENV{GMOCK_HOME}/include
4084af0c9bSNicolas Bonnefon    $ENV{GMOCK_HOME}/gtest/include
4184af0c9bSNicolas Bonnefon    $ENV{BOOST_ROOT}/
42a0936e1eSNicolas Bonnefon    ../src/
43a0936e1eSNicolas Bonnefon)
4484af0c9bSNicolas Bonnefonlink_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest)
4584af0c9bSNicolas Bonnefon
4684af0c9bSNicolas Bonnefon# Sources
4784af0c9bSNicolas Bonnefonset(glogg_SOURCES
4884af0c9bSNicolas Bonnefon    ../src/session.cpp
4984af0c9bSNicolas Bonnefon    ../src/data/abstractlogdata.cpp
5084af0c9bSNicolas Bonnefon    ../src/data/logdata.cpp
5184af0c9bSNicolas Bonnefon    ../src/data/logfiltereddata.cpp
5284af0c9bSNicolas Bonnefon    ../src/data/logfiltereddataworkerthread.cpp
5384af0c9bSNicolas Bonnefon    ../src/data/logdataworkerthread.cpp
5484af0c9bSNicolas Bonnefon    ../src/mainwindow.cpp
5584af0c9bSNicolas Bonnefon    ../src/crawlerwidget.cpp
5684af0c9bSNicolas Bonnefon    ../src/abstractlogview.cpp
5784af0c9bSNicolas Bonnefon    ../src/logmainview.cpp
5884af0c9bSNicolas Bonnefon    ../src/filteredview.cpp
5984af0c9bSNicolas Bonnefon    ../src/optionsdialog.cpp
6084af0c9bSNicolas Bonnefon    ../src/persistentinfo.cpp
6184af0c9bSNicolas Bonnefon    ../src/configuration.cpp
6284af0c9bSNicolas Bonnefon    ../src/filtersdialog.cpp
6384af0c9bSNicolas Bonnefon    ../src/filterset.cpp
6484af0c9bSNicolas Bonnefon    ../src/savedsearches.cpp
6584af0c9bSNicolas Bonnefon    ../src/infoline.cpp
6684af0c9bSNicolas Bonnefon    ../src/menuactiontooltipbehavior.cpp
6784af0c9bSNicolas Bonnefon    ../src/selection.cpp
6884af0c9bSNicolas Bonnefon    ../src/quickfind.cpp
6984af0c9bSNicolas Bonnefon    ../src/quickfindpattern.cpp
7084af0c9bSNicolas Bonnefon    ../src/quickfindwidget.cpp
7184af0c9bSNicolas Bonnefon    ../src/sessioninfo.cpp
7284af0c9bSNicolas Bonnefon    ../src/recentfiles.cpp
7384af0c9bSNicolas Bonnefon    ../src/overview.cpp
7484af0c9bSNicolas Bonnefon    ../src/overviewwidget.cpp
7584af0c9bSNicolas Bonnefon    ../src/marks.cpp
7684af0c9bSNicolas Bonnefon    ../src/quickfindmux.cpp
7784af0c9bSNicolas Bonnefon    ../src/signalmux.cpp
7884af0c9bSNicolas Bonnefon    ../src/qtfilewatcher.cpp
7984af0c9bSNicolas Bonnefon    ../src/tabbedcrawlerwidget.cpp
8084af0c9bSNicolas Bonnefon    ../src/filewatcher.cpp
81c540156cSNicolas Bonnefon    ../src/watchtowerlist.cpp
82a0936e1eSNicolas Bonnefon    ../src/watchtower.cpp
8384b2179eSNicolas Bonnefon    ../src/platformfilewatcher.cpp
8487e05652SNicolas Bonnefon)
8584af0c9bSNicolas Bonnefon
8684af0c9bSNicolas Bonnefonset(glogg_HEADERS
8784af0c9bSNicolas Bonnefon    ../src/mainwindow.h
8884af0c9bSNicolas Bonnefon    ../src/marks.h
8984af0c9bSNicolas Bonnefon    ../src/filewatcher.h)
9084af0c9bSNicolas Bonnefon
9184af0c9bSNicolas Bonnefonset(glogg_TESTS
9284af0c9bSNicolas Bonnefon    testtest.cpp
93a0936e1eSNicolas Bonnefon    filewatcherTest.cpp
9484af0c9bSNicolas Bonnefon    watchtowerTest.cpp
9584af0c9bSNicolas Bonnefon)
9684af0c9bSNicolas Bonnefon
9784af0c9bSNicolas Bonnefon# Options
9884af0c9bSNicolas Bonnefonif (WIN32)
99a0936e1eSNicolas Bonnefon    set(FileWatcherEngine_SOURCES
100f09fa651SNicolas Bonnefon        ../src/winwatchtowerdriver.cpp
101a0936e1eSNicolas Bonnefon    )
10287e05652SNicolas Bonnefonelse (WIN32)
103c540156cSNicolas Bonnefon    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
10484af0c9bSNicolas Bonnefonendif (WIN32)
10584af0c9bSNicolas Bonnefon
10684af0c9bSNicolas Bonnefon# Qt
10784af0c9bSNicolas Bonnefon# QT4_WRAP_CPP(glogg_HEADERS_MOC ${glogg_HEADERS})
10884af0c9bSNicolas Bonnefon# INCLUDE(${QT_USE_FILE})
10984af0c9bSNicolas Bonnefon# ADD_DEFINITIONS(${QT_DEFINITIONS})
110*3104b268SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${PARANOID_FLAGS} -fPIC -std=c++11 -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
11184af0c9bSNicolas Bonnefon
11284af0c9bSNicolas Bonnefon# Add test cpp file
11384af0c9bSNicolas Bonnefonadd_executable(glogg_tests
11484af0c9bSNicolas Bonnefon    ${glogg_SOURCES}
11584af0c9bSNicolas Bonnefon    ${FileWatcherEngine_SOURCES}
11684af0c9bSNicolas Bonnefon    ${glogg_HEADERS_MOC}
11784af0c9bSNicolas Bonnefon    ${glogg_TESTS}
11884af0c9bSNicolas Bonnefon)
11984af0c9bSNicolas Bonnefon
12084af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main
12184af0c9bSNicolas Bonnefontarget_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
12284af0c9bSNicolas Bonnefon
12384af0c9bSNicolas Bonnefonadd_test(
12484af0c9bSNicolas Bonnefon    NAME glogg_tests
12584af0c9bSNicolas Bonnefon    COMMAND glogg_tests
12684af0c9bSNicolas Bonnefon)
127