xref: /glogg/tests/CMakeLists.txt (revision 3104b26858f76d3848af58b8865d4e7d5735d2f8)
1INCLUDE (CheckSymbolExists)
2INCLUDE (CheckCXXSourceCompiles)
3INCLUDE (CheckCXXCompilerFlag)
4
5cmake_minimum_required(VERSION 2.8.12)
6project(glogg_tests)
7
8# Qt
9find_program(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QT_DIR}/bin)
10find_package(Qt5Widgets REQUIRED)
11
12set(CMAKE_AUTOMOC ON)
13set(CMAKE_AUTOUIC ON)
14set(CMAKE_INCLUDE_CURRENT_DIR ON)
15
16check_cxx_compiler_flag(-Wall HAS_WALL)
17
18if(HAS_WALL)
19    set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall")
20endif(HAS_WALL)
21
22# Configuration
23check_symbol_exists( symlink "unistd.h" HAVE_SYMLINK )
24
25check_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
26    #include <memory>
27    int main(int, int)
28    {
29        auto test = std::make_unique<void>();
30        return 0;
31    }
32" HAVE_MAKE_UNIQUE)
33
34configure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
35
36# Setup testing
37enable_testing()
38include_directories(
39    $ENV{GMOCK_HOME}/include
40    $ENV{GMOCK_HOME}/gtest/include
41    $ENV{BOOST_ROOT}/
42    ../src/
43)
44link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest)
45
46# Sources
47set(glogg_SOURCES
48    ../src/session.cpp
49    ../src/data/abstractlogdata.cpp
50    ../src/data/logdata.cpp
51    ../src/data/logfiltereddata.cpp
52    ../src/data/logfiltereddataworkerthread.cpp
53    ../src/data/logdataworkerthread.cpp
54    ../src/mainwindow.cpp
55    ../src/crawlerwidget.cpp
56    ../src/abstractlogview.cpp
57    ../src/logmainview.cpp
58    ../src/filteredview.cpp
59    ../src/optionsdialog.cpp
60    ../src/persistentinfo.cpp
61    ../src/configuration.cpp
62    ../src/filtersdialog.cpp
63    ../src/filterset.cpp
64    ../src/savedsearches.cpp
65    ../src/infoline.cpp
66    ../src/menuactiontooltipbehavior.cpp
67    ../src/selection.cpp
68    ../src/quickfind.cpp
69    ../src/quickfindpattern.cpp
70    ../src/quickfindwidget.cpp
71    ../src/sessioninfo.cpp
72    ../src/recentfiles.cpp
73    ../src/overview.cpp
74    ../src/overviewwidget.cpp
75    ../src/marks.cpp
76    ../src/quickfindmux.cpp
77    ../src/signalmux.cpp
78    ../src/qtfilewatcher.cpp
79    ../src/tabbedcrawlerwidget.cpp
80    ../src/filewatcher.cpp
81    ../src/watchtowerlist.cpp
82    ../src/watchtower.cpp
83    ../src/platformfilewatcher.cpp
84)
85
86set(glogg_HEADERS
87    ../src/mainwindow.h
88    ../src/marks.h
89    ../src/filewatcher.h)
90
91set(glogg_TESTS
92    testtest.cpp
93    filewatcherTest.cpp
94    watchtowerTest.cpp
95)
96
97# Options
98if (WIN32)
99    set(FileWatcherEngine_SOURCES
100        ../src/winwatchtowerdriver.cpp
101    )
102else (WIN32)
103    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
104endif (WIN32)
105
106# Qt
107# QT4_WRAP_CPP(glogg_HEADERS_MOC ${glogg_HEADERS})
108# INCLUDE(${QT_USE_FILE})
109# ADD_DEFINITIONS(${QT_DEFINITIONS})
110set(CMAKE_CXX_FLAGS "${PARANOID_FLAGS} -fPIC -std=c++11 -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
111
112# Add test cpp file
113add_executable(glogg_tests
114    ${glogg_SOURCES}
115    ${FileWatcherEngine_SOURCES}
116    ${glogg_HEADERS_MOC}
117    ${glogg_TESTS}
118)
119
120# Link test executable against gtest & gtest_main
121target_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
122
123add_test(
124    NAME glogg_tests
125    COMMAND glogg_tests
126)
127