xref: /glogg/tests/CMakeLists.txt (revision 6e2e573c451ec24d720c967fab68538eaa3f3ab5)
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)
129
130# Performance tests
131set(glogg_PTESTS
132    logdataPerfTest.cpp
133    logfiltereddataPerfTest.cpp
134)
135
136
137# Options
138if (WIN32)
139    set(FileWatcherEngine_SOURCES
140        ../src/winwatchtowerdriver.cpp
141    )
142else (WIN32)
143    set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp)
144endif (WIN32)
145
146# Compiler flags
147set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2")
148
149# Add test cpp file
150add_executable(glogg_tests
151    ${glogg_SOURCES}
152    ${FileWatcherEngine_SOURCES}
153    ${glogg_UTESTS}
154)
155
156# Link test executable against gtest & gtest_main
157target_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets)
158
159add_executable(glogg_itests
160    ${glogg_SOURCES}
161    ${FileWatcherEngine_SOURCES}
162    ${glogg_ITESTS}
163    itests.cpp
164)
165
166target_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test)
167
168add_executable(glogg_ptests
169    ${glogg_SOURCES}
170    ${FileWatcherEngine_SOURCES}
171    ${glogg_PTESTS}
172    itests.cpp
173)
174
175target_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test)
176
177add_test(
178    NAME glogg_tests
179    COMMAND glogg_tests
180)
181