xref: /glogg/tests/CMakeLists.txt (revision dfb2a39cb717e84f8a91ff75f7d49658243c4ca1) !
1INCLUDE (CheckSymbolExists)
2INCLUDE (CheckCXXSourceCompiles)
3INCLUDE (CheckCXXCompilerFlag)
4
5cmake_minimum_required(VERSION 2.8.12)
6project(glogg_tests)
7
8# Qt
9
10find_program(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QT_DIR}/bin)
11find_package(Qt5Widgets REQUIRED)
12find_package(Qt5Test REQUIRED)
13
14set(CMAKE_AUTOMOC ON)
15set(CMAKE_AUTOUIC ON)
16set(CMAKE_INCLUDE_CURRENT_DIR ON)
17
18check_cxx_compiler_flag(-Wall HAS_WALL)
19
20if(HAS_WALL)
21    set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall")
22endif(HAS_WALL)
23
24# Compiler
25check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
26check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
27if(COMPILER_SUPPORTS_CXX11)
28    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
29elseif(COMPILER_SUPPORTS_CXX0X)
30    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
31else()
32    message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
33endif()
34
35check_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
36    #include <memory>
37    int main(int, int)
38    {
39        auto test = std::make_unique<void>();
40        return 0;
41    }
42" HAVE_MAKE_UNIQUE)
43
44check_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" "
45    #include <memory>
46    struct Base {
47        virtual void func() {}
48    };
49    struct Derived : public Base {
50        void func() override {}
51    }
52    int main(int, int)
53    {
54        return 0;
55    }
56" HAVE_OVERRIDE)
57
58configure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
59
60# Configuration
61check_symbol_exists( symlink "unistd.h" HAVE_SYMLINK )
62
63# Setup testing
64enable_testing()
65include_directories(
66    $ENV{GMOCK_HOME}/include
67    $ENV{GMOCK_HOME}/gtest/include
68    $ENV{BOOST_ROOT}/
69    ../src/
70)
71link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest)
72
73# Sources
74set(glogg_SOURCES
75    ../src/session.cpp
76    ../src/data/abstractlogdata.cpp
77    ../src/data/logdata.cpp
78    ../src/data/logfiltereddata.cpp
79    ../src/data/logfiltereddataworkerthread.cpp
80    ../src/data/logdataworkerthread.cpp
81    ../src/mainwindow.cpp
82    ../src/crawlerwidget.cpp
83    ../src/abstractlogview.cpp
84    ../src/logmainview.cpp
85    ../src/filteredview.cpp
86    ../src/optionsdialog.cpp
87    ../src/persistentinfo.cpp
88    ../src/configuration.cpp
89    ../src/filtersdialog.cpp
90    ../src/filterset.cpp
91    ../src/savedsearches.cpp
92    ../src/infoline.cpp
93    ../src/menuactiontooltipbehavior.cpp
94    ../src/selection.cpp
95    ../src/quickfind.cpp
96    ../src/quickfindpattern.cpp
97    ../src/quickfindwidget.cpp
98    ../src/sessioninfo.cpp
99    ../src/recentfiles.cpp
100    ../src/overview.cpp
101    ../src/overviewwidget.cpp
102    ../src/marks.cpp
103    ../src/quickfindmux.cpp
104    ../src/signalmux.cpp
105    ../src/qtfilewatcher.cpp
106    ../src/tabbedcrawlerwidget.cpp
107    ../src/filewatcher.cpp
108    ../src/watchtowerlist.cpp
109    ../src/watchtower.cpp
110    ../src/platformfilewatcher.cpp
111)
112
113set(glogg_HEADERS
114    ../src/mainwindow.h
115    ../src/marks.h
116    ../src/filewatcher.h)
117
118# Unit tests
119set(glogg_UTESTS
120    watchtowerTest.cpp
121)
122
123# Integration tests
124set(glogg_ITESTS
125    logdataTest.cpp
126)
127
128# Performance tests
129set(glogg_PTESTS
130    logdataPerfTest.cpp
131)
132
133
134# Options
135if (WIN32)
136    set(FileWatcherEngine_SOURCES
137        ../src/winwatchtowerdriver.cpp
138    )
139else (WIN32)
140    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
141endif (WIN32)
142
143# Qt
144set(CMAKE_CXX_FLAGS "${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
145
146# Add test cpp file
147add_executable(glogg_tests
148    ${glogg_SOURCES}
149    ${FileWatcherEngine_SOURCES}
150    ${glogg_UTESTS}
151)
152
153# Link test executable against gtest & gtest_main
154target_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
155
156add_executable(glogg_itests
157    ${glogg_SOURCES}
158    ${FileWatcherEngine_SOURCES}
159    ${glogg_ITESTS}
160    itests.cpp
161)
162
163target_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test)
164
165add_executable(glogg_ptests
166    ${glogg_SOURCES}
167    ${FileWatcherEngine_SOURCES}
168    ${glogg_PTESTS}
169    itests.cpp
170)
171
172target_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test)
173
174add_test(
175    NAME glogg_tests
176    COMMAND glogg_tests
177)
178