xref: /glogg/tests/CMakeLists.txt (revision 58ab9c5330b6011b7e977bd08f974c1c65f5d8d6)
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/data/compressedlinestorage.cpp
82    ../src/mainwindow.cpp
83    ../src/crawlerwidget.cpp
84    ../src/abstractlogview.cpp
85    ../src/logmainview.cpp
86    ../src/filteredview.cpp
87    ../src/optionsdialog.cpp
88    ../src/persistentinfo.cpp
89    ../src/configuration.cpp
90    ../src/filtersdialog.cpp
91    ../src/filterset.cpp
92    ../src/savedsearches.cpp
93    ../src/infoline.cpp
94    ../src/menuactiontooltipbehavior.cpp
95    ../src/selection.cpp
96    ../src/quickfind.cpp
97    ../src/quickfindpattern.cpp
98    ../src/quickfindwidget.cpp
99    ../src/sessioninfo.cpp
100    ../src/recentfiles.cpp
101    ../src/overview.cpp
102    ../src/overviewwidget.cpp
103    ../src/marks.cpp
104    ../src/quickfindmux.cpp
105    ../src/signalmux.cpp
106    ../src/qtfilewatcher.cpp
107    ../src/tabbedcrawlerwidget.cpp
108    ../src/filewatcher.cpp
109    ../src/watchtowerlist.cpp
110    ../src/watchtower.cpp
111    ../src/platformfilewatcher.cpp
112)
113
114set(glogg_HEADERS
115    ../src/mainwindow.h
116    ../src/marks.h
117    ../src/filewatcher.h)
118
119# Unit tests
120set(glogg_UTESTS
121    watchtowerTest.cpp
122    linepositionarrayTest.cpp
123)
124
125# Integration tests
126set(glogg_ITESTS
127    logdataTest.cpp
128    logfiltereddataTest.cpp
129)
130
131# Performance tests
132set(glogg_PTESTS
133    logdataPerfTest.cpp
134    logfiltereddataPerfTest.cpp
135)
136
137
138# Options
139if (WIN32)
140    set(FileWatcherEngine_SOURCES
141        ../src/winwatchtowerdriver.cpp
142    )
143else (WIN32)
144    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
145endif (WIN32)
146
147# Compiler flags
148set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
149
150# Add test cpp file
151add_executable(glogg_tests
152    ${glogg_SOURCES}
153    ${FileWatcherEngine_SOURCES}
154    ${glogg_UTESTS}
155)
156
157# Link test executable against gtest & gtest_main
158target_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
159
160add_executable(glogg_itests
161    ${glogg_SOURCES}
162    ${FileWatcherEngine_SOURCES}
163    ${glogg_ITESTS}
164    itests.cpp
165)
166
167target_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test)
168
169add_executable(glogg_ptests
170    ${glogg_SOURCES}
171    ${FileWatcherEngine_SOURCES}
172    ${glogg_PTESTS}
173    itests.cpp
174)
175
176target_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test)
177
178add_test(
179    NAME glogg_tests
180    COMMAND glogg_tests
181)
182