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 35set(CMAKE_REQUIRED_FLAGS "-std=c++11") 36check_cxx_source_compiles(" 37 #include <memory> 38 int main(int, int) 39 { 40 auto test = std::make_unique<void>(); 41 return 0; 42 } 43" HAVE_MAKE_UNIQUE) 44 45check_cxx_source_compiles(" 46 #include <memory> 47 struct Base { 48 virtual void func() {} 49 }; 50 struct Derived : public Base { 51 void func() override {} 52 } 53 int main(int, int) 54 { 55 return 0; 56 } 57" HAVE_OVERRIDE) 58 59configure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 60 61# Configuration 62check_symbol_exists( symlink "unistd.h" HAVE_SYMLINK ) 63 64# find_library(WS2_LIBRARY NAMES ws2_32) 65 66# Libs 67 68set(LIBS gmock gtest) 69 70# Setup testing 71enable_testing() 72include_directories( 73 $ENV{GMOCK_HOME}/include 74 $ENV{GMOCK_HOME}/gtest/include 75 $ENV{BOOST_ROOT}/ 76 ../src/ 77) 78link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest) 79 80# Sources 81set(glogg_SOURCES 82 ../src/session.cpp 83 ../src/data/abstractlogdata.cpp 84 ../src/data/logdata.cpp 85 ../src/data/logfiltereddata.cpp 86 ../src/data/logfiltereddataworkerthread.cpp 87 ../src/data/logdataworkerthread.cpp 88 ../src/data/compressedlinestorage.cpp 89 ../src/mainwindow.cpp 90 ../src/crawlerwidget.cpp 91 ../src/abstractlogview.cpp 92 ../src/logmainview.cpp 93 ../src/filteredview.cpp 94 ../src/optionsdialog.cpp 95 ../src/persistentinfo.cpp 96 ../src/configuration.cpp 97 ../src/filtersdialog.cpp 98 ../src/filterset.cpp 99 ../src/savedsearches.cpp 100 ../src/infoline.cpp 101 ../src/menuactiontooltipbehavior.cpp 102 ../src/selection.cpp 103 ../src/quickfind.cpp 104 ../src/quickfindpattern.cpp 105 ../src/quickfindwidget.cpp 106 ../src/sessioninfo.cpp 107 ../src/recentfiles.cpp 108 ../src/overview.cpp 109 ../src/overviewwidget.cpp 110 ../src/marks.cpp 111 ../src/quickfindmux.cpp 112 ../src/signalmux.cpp 113 ../src/qtfilewatcher.cpp 114 ../src/tabbedcrawlerwidget.cpp 115 ../src/filewatcher.cpp 116 ../src/watchtowerlist.cpp 117 ../src/watchtower.cpp 118 ../src/viewtools.cpp 119 ../src/encodingspeculator.cpp 120 # ../src/platformfilewatcher.cpp 121) 122 123set(glogg_HEADERS 124 ../src/mainwindow.h 125 ../src/marks.h 126 ../src/filewatcher.h) 127 128# Unit tests 129set(glogg_UTESTS 130 # watchtowerTest.cpp 131 linepositionarrayTest.cpp 132 encodingspeculatorTest.cpp 133) 134 135# Integration tests 136set(glogg_ITESTS 137 logdataTest.cpp 138 logfiltereddataTest.cpp 139) 140 141# Performance tests 142set(glogg_PTESTS 143 logdataPerfTest.cpp 144 logfiltereddataPerfTest.cpp 145) 146 147 148# Options 149if (WIN32) 150 set(FileWatcherEngine_SOURCES 151 ../src/winwatchtowerdriver.cpp 152 ) 153elseif (LINUX) 154 # set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 155endif (WIN32) 156 157# Compiler flags 158set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 159 160# Add test cpp file 161add_executable(glogg_tests 162 ${glogg_SOURCES} 163 ${FileWatcherEngine_SOURCES} 164 ${glogg_UTESTS} 165) 166 167# Link test executable against gtest & gtest_main 168target_link_libraries(glogg_tests ${LIBS} gtest_main pthread Qt5::Widgets) 169 170add_executable(glogg_itests 171 ${glogg_SOURCES} 172 ${FileWatcherEngine_SOURCES} 173 ${glogg_ITESTS} 174 itests.cpp 175) 176 177target_link_libraries(glogg_itests ${LIBS} pthread Qt5::Widgets Qt5::Test) 178 179add_executable(glogg_ptests 180 ${glogg_SOURCES} 181 ${FileWatcherEngine_SOURCES} 182 ${glogg_PTESTS} 183 itests.cpp 184) 185 186target_link_libraries(glogg_ptests ${LIBS} pthread Qt5::Widgets Qt5::Test) 187 188add_test( 189 NAME glogg_tests 190 COMMAND glogg_tests 191) 192