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