187e05652SNicolas BonnefonINCLUDE (CheckSymbolExists) 2f09fa651SNicolas BonnefonINCLUDE (CheckCXXSourceCompiles) 33104b268SNicolas BonnefonINCLUDE (CheckCXXCompilerFlag) 487e05652SNicolas Bonnefon 5f09fa651SNicolas Bonnefoncmake_minimum_required(VERSION 2.8.12) 684af0c9bSNicolas Bonnefonproject(glogg_tests) 784af0c9bSNicolas Bonnefon 887e05652SNicolas Bonnefon# Qt 91ee847caSNicolas Bonnefon 1084af0c9bSNicolas Bonnefonfind_program(QT_QMAKE_EXECUTABLE NAMES qmake PATHS $ENV{QT_DIR}/bin) 11f869e41dSNicolas Bonnefonfind_package(Qt5Core 5.8 REQUIRED) 12f869e41dSNicolas Bonnefonfind_package(Qt5Widgets 5.8 REQUIRED) 13f869e41dSNicolas Bonnefonfind_package(Qt5Test 5.8 REQUIRED) 1484af0c9bSNicolas Bonnefon 1584af0c9bSNicolas Bonnefonset(CMAKE_AUTOMOC ON) 1684af0c9bSNicolas Bonnefonset(CMAKE_AUTOUIC ON) 1784af0c9bSNicolas Bonnefonset(CMAKE_INCLUDE_CURRENT_DIR ON) 1884af0c9bSNicolas Bonnefon 193104b268SNicolas Bonnefoncheck_cxx_compiler_flag(-Wall HAS_WALL) 203104b268SNicolas Bonnefon 213104b268SNicolas Bonnefonif(HAS_WALL) 223104b268SNicolas Bonnefon set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall") 233104b268SNicolas Bonnefonendif(HAS_WALL) 243104b268SNicolas Bonnefon 25dfb2a39cSNicolas Bonnefon# Compiler 26dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) 27dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X) 28dfb2a39cSNicolas Bonnefonif(COMPILER_SUPPORTS_CXX11) 29dfb2a39cSNicolas Bonnefon set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 30dfb2a39cSNicolas Bonnefonelseif(COMPILER_SUPPORTS_CXX0X) 31dfb2a39cSNicolas Bonnefon set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") 32dfb2a39cSNicolas Bonnefonelse() 33dfb2a39cSNicolas Bonnefon message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") 34dfb2a39cSNicolas Bonnefonendif() 3587e05652SNicolas Bonnefon 369ba963cbSNicolas Bonnefonset(CMAKE_REQUIRED_FLAGS "-std=c++11") 379ba963cbSNicolas Bonnefoncheck_cxx_source_compiles(" 38f09fa651SNicolas Bonnefon #include <memory> 39f09fa651SNicolas Bonnefon int main(int, int) 40f09fa651SNicolas Bonnefon { 41f09fa651SNicolas Bonnefon auto test = std::make_unique<void>(); 42f09fa651SNicolas Bonnefon return 0; 43f09fa651SNicolas Bonnefon } 44f09fa651SNicolas Bonnefon" HAVE_MAKE_UNIQUE) 45f09fa651SNicolas Bonnefon 469ba963cbSNicolas Bonnefoncheck_cxx_source_compiles(" 47dfb2a39cSNicolas Bonnefon #include <memory> 48dfb2a39cSNicolas Bonnefon struct Base { 49dfb2a39cSNicolas Bonnefon virtual void func() {} 50dfb2a39cSNicolas Bonnefon }; 51dfb2a39cSNicolas Bonnefon struct Derived : public Base { 52dfb2a39cSNicolas Bonnefon void func() override {} 53dfb2a39cSNicolas Bonnefon } 54dfb2a39cSNicolas Bonnefon int main(int, int) 55dfb2a39cSNicolas Bonnefon { 56dfb2a39cSNicolas Bonnefon return 0; 57dfb2a39cSNicolas Bonnefon } 58dfb2a39cSNicolas Bonnefon" HAVE_OVERRIDE) 59dfb2a39cSNicolas Bonnefon 6087e05652SNicolas Bonnefonconfigure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 6187e05652SNicolas Bonnefon 62dfb2a39cSNicolas Bonnefon# Configuration 63dfb2a39cSNicolas Bonnefoncheck_symbol_exists( symlink "unistd.h" HAVE_SYMLINK ) 649ba963cbSNicolas Bonnefon 659ba963cbSNicolas Bonnefon# find_library(WS2_LIBRARY NAMES ws2_32) 669ba963cbSNicolas Bonnefon 679ba963cbSNicolas Bonnefon# Libs 689ba963cbSNicolas Bonnefon 699ba963cbSNicolas Bonnefonset(LIBS gmock gtest) 70dfb2a39cSNicolas Bonnefon 7184af0c9bSNicolas Bonnefon# Setup testing 7284af0c9bSNicolas Bonnefonenable_testing() 7384af0c9bSNicolas Bonnefoninclude_directories( 7484af0c9bSNicolas Bonnefon $ENV{GMOCK_HOME}/include 7584af0c9bSNicolas Bonnefon $ENV{GMOCK_HOME}/gtest/include 7684af0c9bSNicolas Bonnefon $ENV{BOOST_ROOT}/ 77a0936e1eSNicolas Bonnefon ../src/ 78a0936e1eSNicolas Bonnefon) 7984af0c9bSNicolas Bonnefonlink_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest) 8084af0c9bSNicolas Bonnefon 8184af0c9bSNicolas Bonnefon# Sources 8284af0c9bSNicolas Bonnefonset(glogg_SOURCES 8384af0c9bSNicolas Bonnefon ../src/session.cpp 8484af0c9bSNicolas Bonnefon ../src/data/abstractlogdata.cpp 8584af0c9bSNicolas Bonnefon ../src/data/logdata.cpp 8684af0c9bSNicolas Bonnefon ../src/data/logfiltereddata.cpp 8784af0c9bSNicolas Bonnefon ../src/data/logfiltereddataworkerthread.cpp 8884af0c9bSNicolas Bonnefon ../src/data/logdataworkerthread.cpp 897a2f3a57SNicolas Bonnefon ../src/data/compressedlinestorage.cpp 9084af0c9bSNicolas Bonnefon ../src/mainwindow.cpp 9184af0c9bSNicolas Bonnefon ../src/crawlerwidget.cpp 9284af0c9bSNicolas Bonnefon ../src/abstractlogview.cpp 9384af0c9bSNicolas Bonnefon ../src/logmainview.cpp 9484af0c9bSNicolas Bonnefon ../src/filteredview.cpp 9584af0c9bSNicolas Bonnefon ../src/optionsdialog.cpp 9684af0c9bSNicolas Bonnefon ../src/persistentinfo.cpp 9784af0c9bSNicolas Bonnefon ../src/configuration.cpp 9884af0c9bSNicolas Bonnefon ../src/filtersdialog.cpp 9984af0c9bSNicolas Bonnefon ../src/filterset.cpp 10084af0c9bSNicolas Bonnefon ../src/savedsearches.cpp 10184af0c9bSNicolas Bonnefon ../src/infoline.cpp 10284af0c9bSNicolas Bonnefon ../src/menuactiontooltipbehavior.cpp 10384af0c9bSNicolas Bonnefon ../src/selection.cpp 10484af0c9bSNicolas Bonnefon ../src/quickfind.cpp 10584af0c9bSNicolas Bonnefon ../src/quickfindpattern.cpp 10684af0c9bSNicolas Bonnefon ../src/quickfindwidget.cpp 10784af0c9bSNicolas Bonnefon ../src/sessioninfo.cpp 10884af0c9bSNicolas Bonnefon ../src/recentfiles.cpp 10984af0c9bSNicolas Bonnefon ../src/overview.cpp 11084af0c9bSNicolas Bonnefon ../src/overviewwidget.cpp 11184af0c9bSNicolas Bonnefon ../src/marks.cpp 11284af0c9bSNicolas Bonnefon ../src/quickfindmux.cpp 11384af0c9bSNicolas Bonnefon ../src/signalmux.cpp 11484af0c9bSNicolas Bonnefon ../src/tabbedcrawlerwidget.cpp 115c540156cSNicolas Bonnefon ../src/watchtowerlist.cpp 116a0936e1eSNicolas Bonnefon ../src/watchtower.cpp 117702af59eSNicolas Bonnefon ../src/viewtools.cpp 118702af59eSNicolas Bonnefon ../src/encodingspeculator.cpp 119f869e41dSNicolas Bonnefon ../src/platformfilewatcher.cpp 120f869e41dSNicolas Bonnefon ../src/filewatcher.cpp 12187e05652SNicolas Bonnefon) 12284af0c9bSNicolas Bonnefon 12384af0c9bSNicolas Bonnefonset(glogg_HEADERS 12484af0c9bSNicolas Bonnefon ../src/mainwindow.h 12584af0c9bSNicolas Bonnefon ../src/marks.h 126f869e41dSNicolas Bonnefon ../src/platformfilewatcher.h 127f869e41dSNicolas Bonnefon ../src/filewatcher.h 128f869e41dSNicolas Bonnefon) 12984af0c9bSNicolas Bonnefon 1301ee847caSNicolas Bonnefon# Unit tests 1311ee847caSNicolas Bonnefonset(glogg_UTESTS 132f869e41dSNicolas Bonnefon watchtowerTest.cpp 133f049f87fSNicolas Bonnefon linepositionarrayTest.cpp 134702af59eSNicolas Bonnefon encodingspeculatorTest.cpp 13584af0c9bSNicolas Bonnefon) 13684af0c9bSNicolas Bonnefon 1371ee847caSNicolas Bonnefon# Integration tests 1381ee847caSNicolas Bonnefonset(glogg_ITESTS 1391ee847caSNicolas Bonnefon logdataTest.cpp 14058ab9c53SNicolas Bonnefon logfiltereddataTest.cpp 1411ee847caSNicolas Bonnefon) 1421ee847caSNicolas Bonnefon 1431ee847caSNicolas Bonnefon# Performance tests 1441ee847caSNicolas Bonnefonset(glogg_PTESTS 1451ee847caSNicolas Bonnefon logdataPerfTest.cpp 14674d66bf4SNicolas Bonnefon logfiltereddataPerfTest.cpp 1471ee847caSNicolas Bonnefon) 1481ee847caSNicolas Bonnefon 1491ee847caSNicolas Bonnefon 15084af0c9bSNicolas Bonnefon# Options 15184af0c9bSNicolas Bonnefonif (WIN32) 152a0936e1eSNicolas Bonnefon set(FileWatcherEngine_SOURCES 153f09fa651SNicolas Bonnefon ../src/winwatchtowerdriver.cpp 154a0936e1eSNicolas Bonnefon ) 155702af59eSNicolas Bonnefonelseif (LINUX) 156702af59eSNicolas Bonnefon # set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 157f869e41dSNicolas Bonnefonelseif (APPLE) 158*933a5744SNicolas Bonnefon set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGLOGG_SUPPORTS_KQUEUE") 159f869e41dSNicolas Bonnefon set(FileWatcherEngine_SOURCES 160f869e41dSNicolas Bonnefon ../src/kqueuewatchtowerdriver.cpp 161f869e41dSNicolas Bonnefon ) 16284af0c9bSNicolas Bonnefonendif (WIN32) 16384af0c9bSNicolas Bonnefon 16491f7c705SNicolas Bonnefon# Compiler flags 16591f7c705SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 16684af0c9bSNicolas Bonnefon 16784af0c9bSNicolas Bonnefon# Add test cpp file 16884af0c9bSNicolas Bonnefonadd_executable(glogg_tests 16984af0c9bSNicolas Bonnefon ${glogg_SOURCES} 17084af0c9bSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1711ee847caSNicolas Bonnefon ${glogg_UTESTS} 17284af0c9bSNicolas Bonnefon) 17384af0c9bSNicolas Bonnefon 17484af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main 1759ba963cbSNicolas Bonnefontarget_link_libraries(glogg_tests ${LIBS} gtest_main pthread Qt5::Widgets) 17684af0c9bSNicolas Bonnefon 1771ee847caSNicolas Bonnefonadd_executable(glogg_itests 1781ee847caSNicolas Bonnefon ${glogg_SOURCES} 1791ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1801ee847caSNicolas Bonnefon ${glogg_ITESTS} 1811ee847caSNicolas Bonnefon itests.cpp 1821ee847caSNicolas Bonnefon) 1831ee847caSNicolas Bonnefon 1849ba963cbSNicolas Bonnefontarget_link_libraries(glogg_itests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1851ee847caSNicolas Bonnefon 1861ee847caSNicolas Bonnefonadd_executable(glogg_ptests 1871ee847caSNicolas Bonnefon ${glogg_SOURCES} 1881ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1891ee847caSNicolas Bonnefon ${glogg_PTESTS} 1901ee847caSNicolas Bonnefon itests.cpp 1911ee847caSNicolas Bonnefon) 1921ee847caSNicolas Bonnefon 1939ba963cbSNicolas Bonnefontarget_link_libraries(glogg_ptests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1941ee847caSNicolas Bonnefon 19584af0c9bSNicolas Bonnefonadd_test( 19684af0c9bSNicolas Bonnefon NAME glogg_tests 19784af0c9bSNicolas Bonnefon COMMAND glogg_tests 19884af0c9bSNicolas Bonnefon) 199