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