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) 1184af0c9bSNicolas Bonnefonfind_package(Qt5Widgets REQUIRED) 121ee847caSNicolas Bonnefonfind_package(Qt5Test REQUIRED) 1384af0c9bSNicolas Bonnefon 1484af0c9bSNicolas Bonnefonset(CMAKE_AUTOMOC ON) 1584af0c9bSNicolas Bonnefonset(CMAKE_AUTOUIC ON) 1684af0c9bSNicolas Bonnefonset(CMAKE_INCLUDE_CURRENT_DIR ON) 1784af0c9bSNicolas Bonnefon 183104b268SNicolas Bonnefoncheck_cxx_compiler_flag(-Wall HAS_WALL) 193104b268SNicolas Bonnefon 203104b268SNicolas Bonnefonif(HAS_WALL) 213104b268SNicolas Bonnefon set(PARANOID_FLAGS "${PARANOID_FLAGS} -Wall") 223104b268SNicolas Bonnefonendif(HAS_WALL) 233104b268SNicolas Bonnefon 24dfb2a39cSNicolas Bonnefon# Compiler 25dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11) 26dfb2a39cSNicolas Bonnefoncheck_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X) 27dfb2a39cSNicolas Bonnefonif(COMPILER_SUPPORTS_CXX11) 28dfb2a39cSNicolas Bonnefon set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 29dfb2a39cSNicolas Bonnefonelseif(COMPILER_SUPPORTS_CXX0X) 30dfb2a39cSNicolas Bonnefon set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") 31dfb2a39cSNicolas Bonnefonelse() 32dfb2a39cSNicolas Bonnefon message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.") 33dfb2a39cSNicolas Bonnefonendif() 3487e05652SNicolas Bonnefon 35*9ba963cbSNicolas Bonnefonset(CMAKE_REQUIRED_FLAGS "-std=c++11") 36*9ba963cbSNicolas Bonnefoncheck_cxx_source_compiles(" 37f09fa651SNicolas Bonnefon #include <memory> 38f09fa651SNicolas Bonnefon int main(int, int) 39f09fa651SNicolas Bonnefon { 40f09fa651SNicolas Bonnefon auto test = std::make_unique<void>(); 41f09fa651SNicolas Bonnefon return 0; 42f09fa651SNicolas Bonnefon } 43f09fa651SNicolas Bonnefon" HAVE_MAKE_UNIQUE) 44f09fa651SNicolas Bonnefon 45*9ba963cbSNicolas Bonnefoncheck_cxx_source_compiles(" 46dfb2a39cSNicolas Bonnefon #include <memory> 47dfb2a39cSNicolas Bonnefon struct Base { 48dfb2a39cSNicolas Bonnefon virtual void func() {} 49dfb2a39cSNicolas Bonnefon }; 50dfb2a39cSNicolas Bonnefon struct Derived : public Base { 51dfb2a39cSNicolas Bonnefon void func() override {} 52dfb2a39cSNicolas Bonnefon } 53dfb2a39cSNicolas Bonnefon int main(int, int) 54dfb2a39cSNicolas Bonnefon { 55dfb2a39cSNicolas Bonnefon return 0; 56dfb2a39cSNicolas Bonnefon } 57dfb2a39cSNicolas Bonnefon" HAVE_OVERRIDE) 58dfb2a39cSNicolas Bonnefon 5987e05652SNicolas Bonnefonconfigure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 6087e05652SNicolas Bonnefon 61dfb2a39cSNicolas Bonnefon# Configuration 62dfb2a39cSNicolas Bonnefoncheck_symbol_exists( symlink "unistd.h" HAVE_SYMLINK ) 63*9ba963cbSNicolas Bonnefoncheck_symbol_exists( htons "arpa/inet.h" HAVE_HTONS ) 64*9ba963cbSNicolas Bonnefon 65*9ba963cbSNicolas Bonnefon# find_library(WS2_LIBRARY NAMES ws2_32) 66*9ba963cbSNicolas Bonnefon 67*9ba963cbSNicolas Bonnefon# Libs 68*9ba963cbSNicolas Bonnefon 69*9ba963cbSNicolas 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/qtfilewatcher.cpp 11584af0c9bSNicolas Bonnefon ../src/tabbedcrawlerwidget.cpp 11684af0c9bSNicolas Bonnefon ../src/filewatcher.cpp 117c540156cSNicolas Bonnefon ../src/watchtowerlist.cpp 118a0936e1eSNicolas Bonnefon ../src/watchtower.cpp 11984b2179eSNicolas Bonnefon ../src/platformfilewatcher.cpp 12087e05652SNicolas Bonnefon) 12184af0c9bSNicolas Bonnefon 12284af0c9bSNicolas Bonnefonset(glogg_HEADERS 12384af0c9bSNicolas Bonnefon ../src/mainwindow.h 12484af0c9bSNicolas Bonnefon ../src/marks.h 12584af0c9bSNicolas Bonnefon ../src/filewatcher.h) 12684af0c9bSNicolas Bonnefon 1271ee847caSNicolas Bonnefon# Unit tests 1281ee847caSNicolas Bonnefonset(glogg_UTESTS 12984af0c9bSNicolas Bonnefon watchtowerTest.cpp 130f049f87fSNicolas Bonnefon linepositionarrayTest.cpp 13184af0c9bSNicolas Bonnefon) 13284af0c9bSNicolas Bonnefon 1331ee847caSNicolas Bonnefon# Integration tests 1341ee847caSNicolas Bonnefonset(glogg_ITESTS 1351ee847caSNicolas Bonnefon logdataTest.cpp 13658ab9c53SNicolas Bonnefon logfiltereddataTest.cpp 1371ee847caSNicolas Bonnefon) 1381ee847caSNicolas Bonnefon 1391ee847caSNicolas Bonnefon# Performance tests 1401ee847caSNicolas Bonnefonset(glogg_PTESTS 1411ee847caSNicolas Bonnefon logdataPerfTest.cpp 14274d66bf4SNicolas Bonnefon logfiltereddataPerfTest.cpp 1431ee847caSNicolas Bonnefon) 1441ee847caSNicolas Bonnefon 1451ee847caSNicolas Bonnefon 14684af0c9bSNicolas Bonnefon# Options 14784af0c9bSNicolas Bonnefonif (WIN32) 148a0936e1eSNicolas Bonnefon set(FileWatcherEngine_SOURCES 149f09fa651SNicolas Bonnefon ../src/winwatchtowerdriver.cpp 150a0936e1eSNicolas Bonnefon ) 15187e05652SNicolas Bonnefonelse (WIN32) 152c540156cSNicolas Bonnefon set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 15384af0c9bSNicolas Bonnefonendif (WIN32) 15484af0c9bSNicolas Bonnefon 15591f7c705SNicolas Bonnefon# Compiler flags 15691f7c705SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 15784af0c9bSNicolas Bonnefon 15884af0c9bSNicolas Bonnefon# Add test cpp file 15984af0c9bSNicolas Bonnefonadd_executable(glogg_tests 16084af0c9bSNicolas Bonnefon ${glogg_SOURCES} 16184af0c9bSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1621ee847caSNicolas Bonnefon ${glogg_UTESTS} 16384af0c9bSNicolas Bonnefon) 16484af0c9bSNicolas Bonnefon 16584af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main 166*9ba963cbSNicolas Bonnefontarget_link_libraries(glogg_tests ${LIBS} gtest_main pthread Qt5::Widgets) 16784af0c9bSNicolas Bonnefon 1681ee847caSNicolas Bonnefonadd_executable(glogg_itests 1691ee847caSNicolas Bonnefon ${glogg_SOURCES} 1701ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1711ee847caSNicolas Bonnefon ${glogg_ITESTS} 1721ee847caSNicolas Bonnefon itests.cpp 1731ee847caSNicolas Bonnefon) 1741ee847caSNicolas Bonnefon 175*9ba963cbSNicolas Bonnefontarget_link_libraries(glogg_itests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1761ee847caSNicolas Bonnefon 1771ee847caSNicolas Bonnefonadd_executable(glogg_ptests 1781ee847caSNicolas Bonnefon ${glogg_SOURCES} 1791ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1801ee847caSNicolas Bonnefon ${glogg_PTESTS} 1811ee847caSNicolas Bonnefon itests.cpp 1821ee847caSNicolas Bonnefon) 1831ee847caSNicolas Bonnefon 184*9ba963cbSNicolas Bonnefontarget_link_libraries(glogg_ptests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1851ee847caSNicolas Bonnefon 18684af0c9bSNicolas Bonnefonadd_test( 18784af0c9bSNicolas Bonnefon NAME glogg_tests 18884af0c9bSNicolas Bonnefon COMMAND glogg_tests 18984af0c9bSNicolas Bonnefon) 190