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# Configuration 25check_symbol_exists( symlink "unistd.h" HAVE_SYMLINK ) 26 27check_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" " 28 #include <memory> 29 int main(int, int) 30 { 31 auto test = std::make_unique<void>(); 32 return 0; 33 } 34" HAVE_MAKE_UNIQUE) 35 36configure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 37 38# Setup testing 39enable_testing() 40include_directories( 41 $ENV{GMOCK_HOME}/include 42 $ENV{GMOCK_HOME}/gtest/include 43 $ENV{BOOST_ROOT}/ 44 ../src/ 45) 46link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest) 47 48# Sources 49set(glogg_SOURCES 50 ../src/session.cpp 51 ../src/data/abstractlogdata.cpp 52 ../src/data/logdata.cpp 53 ../src/data/logfiltereddata.cpp 54 ../src/data/logfiltereddataworkerthread.cpp 55 ../src/data/logdataworkerthread.cpp 56 ../src/mainwindow.cpp 57 ../src/crawlerwidget.cpp 58 ../src/abstractlogview.cpp 59 ../src/logmainview.cpp 60 ../src/filteredview.cpp 61 ../src/optionsdialog.cpp 62 ../src/persistentinfo.cpp 63 ../src/configuration.cpp 64 ../src/filtersdialog.cpp 65 ../src/filterset.cpp 66 ../src/savedsearches.cpp 67 ../src/infoline.cpp 68 ../src/menuactiontooltipbehavior.cpp 69 ../src/selection.cpp 70 ../src/quickfind.cpp 71 ../src/quickfindpattern.cpp 72 ../src/quickfindwidget.cpp 73 ../src/sessioninfo.cpp 74 ../src/recentfiles.cpp 75 ../src/overview.cpp 76 ../src/overviewwidget.cpp 77 ../src/marks.cpp 78 ../src/quickfindmux.cpp 79 ../src/signalmux.cpp 80 ../src/qtfilewatcher.cpp 81 ../src/tabbedcrawlerwidget.cpp 82 ../src/filewatcher.cpp 83 ../src/watchtowerlist.cpp 84 ../src/watchtower.cpp 85 ../src/platformfilewatcher.cpp 86) 87 88set(glogg_HEADERS 89 ../src/mainwindow.h 90 ../src/marks.h 91 ../src/filewatcher.h) 92 93# Unit tests 94set(glogg_UTESTS 95 filewatcherTest.cpp 96 watchtowerTest.cpp 97) 98 99# Integration tests 100set(glogg_ITESTS 101 logdataTest.cpp 102) 103 104# Performance tests 105set(glogg_PTESTS 106 logdataPerfTest.cpp 107) 108 109 110# Options 111if (WIN32) 112 set(FileWatcherEngine_SOURCES 113 ../src/winwatchtowerdriver.cpp 114 ) 115else (WIN32) 116 set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 117endif (WIN32) 118 119# Qt 120set(CMAKE_CXX_FLAGS "${PARANOID_FLAGS} -fPIC -std=c++11 -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 121 122# Add test cpp file 123add_executable(glogg_tests 124 ${glogg_SOURCES} 125 ${FileWatcherEngine_SOURCES} 126 ${glogg_UTESTS} 127) 128 129# Link test executable against gtest & gtest_main 130target_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets) 131 132add_executable(glogg_itests 133 ${glogg_SOURCES} 134 ${FileWatcherEngine_SOURCES} 135 ${glogg_ITESTS} 136 itests.cpp 137) 138 139target_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test) 140 141add_executable(glogg_ptests 142 ${glogg_SOURCES} 143 ${FileWatcherEngine_SOURCES} 144 ${glogg_PTESTS} 145 itests.cpp 146) 147 148target_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test) 149 150add_test( 151 NAME glogg_tests 152 COMMAND glogg_tests 153) 154