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 35f09fa651SNicolas Bonnefoncheck_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" " 36f09fa651SNicolas Bonnefon #include <memory> 37f09fa651SNicolas Bonnefon int main(int, int) 38f09fa651SNicolas Bonnefon { 39f09fa651SNicolas Bonnefon auto test = std::make_unique<void>(); 40f09fa651SNicolas Bonnefon return 0; 41f09fa651SNicolas Bonnefon } 42f09fa651SNicolas Bonnefon" HAVE_MAKE_UNIQUE) 43f09fa651SNicolas Bonnefon 44dfb2a39cSNicolas Bonnefoncheck_cxx_source_compiles(CMAKE_REQUIRED_FLAGS="-std=c++11" " 45dfb2a39cSNicolas Bonnefon #include <memory> 46dfb2a39cSNicolas Bonnefon struct Base { 47dfb2a39cSNicolas Bonnefon virtual void func() {} 48dfb2a39cSNicolas Bonnefon }; 49dfb2a39cSNicolas Bonnefon struct Derived : public Base { 50dfb2a39cSNicolas Bonnefon void func() override {} 51dfb2a39cSNicolas Bonnefon } 52dfb2a39cSNicolas Bonnefon int main(int, int) 53dfb2a39cSNicolas Bonnefon { 54dfb2a39cSNicolas Bonnefon return 0; 55dfb2a39cSNicolas Bonnefon } 56dfb2a39cSNicolas Bonnefon" HAVE_OVERRIDE) 57dfb2a39cSNicolas Bonnefon 5887e05652SNicolas Bonnefonconfigure_file(../config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) 5987e05652SNicolas Bonnefon 60dfb2a39cSNicolas Bonnefon# Configuration 61dfb2a39cSNicolas Bonnefoncheck_symbol_exists( symlink "unistd.h" HAVE_SYMLINK ) 62dfb2a39cSNicolas Bonnefon 6384af0c9bSNicolas Bonnefon# Setup testing 6484af0c9bSNicolas Bonnefonenable_testing() 6584af0c9bSNicolas Bonnefoninclude_directories( 6684af0c9bSNicolas Bonnefon $ENV{GMOCK_HOME}/include 6784af0c9bSNicolas Bonnefon $ENV{GMOCK_HOME}/gtest/include 6884af0c9bSNicolas Bonnefon $ENV{BOOST_ROOT}/ 69a0936e1eSNicolas Bonnefon ../src/ 70a0936e1eSNicolas Bonnefon) 7184af0c9bSNicolas Bonnefonlink_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/mybuild/gtest) 7284af0c9bSNicolas Bonnefon 7384af0c9bSNicolas Bonnefon# Sources 7484af0c9bSNicolas Bonnefonset(glogg_SOURCES 7584af0c9bSNicolas Bonnefon ../src/session.cpp 7684af0c9bSNicolas Bonnefon ../src/data/abstractlogdata.cpp 7784af0c9bSNicolas Bonnefon ../src/data/logdata.cpp 7884af0c9bSNicolas Bonnefon ../src/data/logfiltereddata.cpp 7984af0c9bSNicolas Bonnefon ../src/data/logfiltereddataworkerthread.cpp 8084af0c9bSNicolas Bonnefon ../src/data/logdataworkerthread.cpp 817a2f3a57SNicolas Bonnefon ../src/data/compressedlinestorage.cpp 8284af0c9bSNicolas Bonnefon ../src/mainwindow.cpp 8384af0c9bSNicolas Bonnefon ../src/crawlerwidget.cpp 8484af0c9bSNicolas Bonnefon ../src/abstractlogview.cpp 8584af0c9bSNicolas Bonnefon ../src/logmainview.cpp 8684af0c9bSNicolas Bonnefon ../src/filteredview.cpp 8784af0c9bSNicolas Bonnefon ../src/optionsdialog.cpp 8884af0c9bSNicolas Bonnefon ../src/persistentinfo.cpp 8984af0c9bSNicolas Bonnefon ../src/configuration.cpp 9084af0c9bSNicolas Bonnefon ../src/filtersdialog.cpp 9184af0c9bSNicolas Bonnefon ../src/filterset.cpp 9284af0c9bSNicolas Bonnefon ../src/savedsearches.cpp 9384af0c9bSNicolas Bonnefon ../src/infoline.cpp 9484af0c9bSNicolas Bonnefon ../src/menuactiontooltipbehavior.cpp 9584af0c9bSNicolas Bonnefon ../src/selection.cpp 9684af0c9bSNicolas Bonnefon ../src/quickfind.cpp 9784af0c9bSNicolas Bonnefon ../src/quickfindpattern.cpp 9884af0c9bSNicolas Bonnefon ../src/quickfindwidget.cpp 9984af0c9bSNicolas Bonnefon ../src/sessioninfo.cpp 10084af0c9bSNicolas Bonnefon ../src/recentfiles.cpp 10184af0c9bSNicolas Bonnefon ../src/overview.cpp 10284af0c9bSNicolas Bonnefon ../src/overviewwidget.cpp 10384af0c9bSNicolas Bonnefon ../src/marks.cpp 10484af0c9bSNicolas Bonnefon ../src/quickfindmux.cpp 10584af0c9bSNicolas Bonnefon ../src/signalmux.cpp 10684af0c9bSNicolas Bonnefon ../src/qtfilewatcher.cpp 10784af0c9bSNicolas Bonnefon ../src/tabbedcrawlerwidget.cpp 10884af0c9bSNicolas Bonnefon ../src/filewatcher.cpp 109c540156cSNicolas Bonnefon ../src/watchtowerlist.cpp 110a0936e1eSNicolas Bonnefon ../src/watchtower.cpp 11184b2179eSNicolas Bonnefon ../src/platformfilewatcher.cpp 11287e05652SNicolas Bonnefon) 11384af0c9bSNicolas Bonnefon 11484af0c9bSNicolas Bonnefonset(glogg_HEADERS 11584af0c9bSNicolas Bonnefon ../src/mainwindow.h 11684af0c9bSNicolas Bonnefon ../src/marks.h 11784af0c9bSNicolas Bonnefon ../src/filewatcher.h) 11884af0c9bSNicolas Bonnefon 1191ee847caSNicolas Bonnefon# Unit tests 1201ee847caSNicolas Bonnefonset(glogg_UTESTS 12184af0c9bSNicolas Bonnefon watchtowerTest.cpp 122f049f87fSNicolas Bonnefon linepositionarrayTest.cpp 12384af0c9bSNicolas Bonnefon) 12484af0c9bSNicolas Bonnefon 1251ee847caSNicolas Bonnefon# Integration tests 1261ee847caSNicolas Bonnefonset(glogg_ITESTS 1271ee847caSNicolas Bonnefon logdataTest.cpp 128*58ab9c53SNicolas Bonnefon logfiltereddataTest.cpp 1291ee847caSNicolas Bonnefon) 1301ee847caSNicolas Bonnefon 1311ee847caSNicolas Bonnefon# Performance tests 1321ee847caSNicolas Bonnefonset(glogg_PTESTS 1331ee847caSNicolas Bonnefon logdataPerfTest.cpp 13474d66bf4SNicolas Bonnefon logfiltereddataPerfTest.cpp 1351ee847caSNicolas Bonnefon) 1361ee847caSNicolas Bonnefon 1371ee847caSNicolas Bonnefon 13884af0c9bSNicolas Bonnefon# Options 13984af0c9bSNicolas Bonnefonif (WIN32) 140a0936e1eSNicolas Bonnefon set(FileWatcherEngine_SOURCES 141f09fa651SNicolas Bonnefon ../src/winwatchtowerdriver.cpp 142a0936e1eSNicolas Bonnefon ) 14387e05652SNicolas Bonnefonelse (WIN32) 144c540156cSNicolas Bonnefon set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 14584af0c9bSNicolas Bonnefonendif (WIN32) 14684af0c9bSNicolas Bonnefon 14791f7c705SNicolas Bonnefon# Compiler flags 14891f7c705SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 14984af0c9bSNicolas Bonnefon 15084af0c9bSNicolas Bonnefon# Add test cpp file 15184af0c9bSNicolas Bonnefonadd_executable(glogg_tests 15284af0c9bSNicolas Bonnefon ${glogg_SOURCES} 15384af0c9bSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1541ee847caSNicolas Bonnefon ${glogg_UTESTS} 15584af0c9bSNicolas Bonnefon) 15684af0c9bSNicolas Bonnefon 15784af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main 15884af0c9bSNicolas Bonnefontarget_link_libraries(glogg_tests gmock gtest gtest_main pthread Qt5::Widgets) 15984af0c9bSNicolas Bonnefon 1601ee847caSNicolas Bonnefonadd_executable(glogg_itests 1611ee847caSNicolas Bonnefon ${glogg_SOURCES} 1621ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1631ee847caSNicolas Bonnefon ${glogg_ITESTS} 1641ee847caSNicolas Bonnefon itests.cpp 1651ee847caSNicolas Bonnefon) 1661ee847caSNicolas Bonnefon 1671ee847caSNicolas Bonnefontarget_link_libraries(glogg_itests gmock gtest pthread Qt5::Widgets Qt5::Test) 1681ee847caSNicolas Bonnefon 1691ee847caSNicolas Bonnefonadd_executable(glogg_ptests 1701ee847caSNicolas Bonnefon ${glogg_SOURCES} 1711ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1721ee847caSNicolas Bonnefon ${glogg_PTESTS} 1731ee847caSNicolas Bonnefon itests.cpp 1741ee847caSNicolas Bonnefon) 1751ee847caSNicolas Bonnefon 1761ee847caSNicolas Bonnefontarget_link_libraries(glogg_ptests gmock gtest pthread Qt5::Widgets Qt5::Test) 1771ee847caSNicolas Bonnefon 17884af0c9bSNicolas Bonnefonadd_test( 17984af0c9bSNicolas Bonnefon NAME glogg_tests 18084af0c9bSNicolas Bonnefon COMMAND glogg_tests 18184af0c9bSNicolas Bonnefon) 182