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 359ba963cbSNicolas Bonnefonset(CMAKE_REQUIRED_FLAGS "-std=c++11") 369ba963cbSNicolas 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 459ba963cbSNicolas 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 ) 639ba963cbSNicolas Bonnefoncheck_symbol_exists( htons "arpa/inet.h" HAVE_HTONS ) 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/qtfilewatcher.cpp 11584af0c9bSNicolas Bonnefon ../src/tabbedcrawlerwidget.cpp 11684af0c9bSNicolas Bonnefon ../src/filewatcher.cpp 117c540156cSNicolas Bonnefon ../src/watchtowerlist.cpp 118a0936e1eSNicolas Bonnefon ../src/watchtower.cpp 119*702af59eSNicolas Bonnefon ../src/viewtools.cpp 120*702af59eSNicolas Bonnefon ../src/encodingspeculator.cpp 121*702af59eSNicolas Bonnefon # ../src/platformfilewatcher.cpp 12287e05652SNicolas Bonnefon) 12384af0c9bSNicolas Bonnefon 12484af0c9bSNicolas Bonnefonset(glogg_HEADERS 12584af0c9bSNicolas Bonnefon ../src/mainwindow.h 12684af0c9bSNicolas Bonnefon ../src/marks.h 12784af0c9bSNicolas Bonnefon ../src/filewatcher.h) 12884af0c9bSNicolas Bonnefon 1291ee847caSNicolas Bonnefon# Unit tests 1301ee847caSNicolas Bonnefonset(glogg_UTESTS 131*702af59eSNicolas Bonnefon # watchtowerTest.cpp 132f049f87fSNicolas Bonnefon linepositionarrayTest.cpp 133*702af59eSNicolas Bonnefon encodingspeculatorTest.cpp 13484af0c9bSNicolas Bonnefon) 13584af0c9bSNicolas Bonnefon 1361ee847caSNicolas Bonnefon# Integration tests 1371ee847caSNicolas Bonnefonset(glogg_ITESTS 1381ee847caSNicolas Bonnefon logdataTest.cpp 13958ab9c53SNicolas Bonnefon logfiltereddataTest.cpp 1401ee847caSNicolas Bonnefon) 1411ee847caSNicolas Bonnefon 1421ee847caSNicolas Bonnefon# Performance tests 1431ee847caSNicolas Bonnefonset(glogg_PTESTS 1441ee847caSNicolas Bonnefon logdataPerfTest.cpp 14574d66bf4SNicolas Bonnefon logfiltereddataPerfTest.cpp 1461ee847caSNicolas Bonnefon) 1471ee847caSNicolas Bonnefon 1481ee847caSNicolas Bonnefon 14984af0c9bSNicolas Bonnefon# Options 15084af0c9bSNicolas Bonnefonif (WIN32) 151a0936e1eSNicolas Bonnefon set(FileWatcherEngine_SOURCES 152f09fa651SNicolas Bonnefon ../src/winwatchtowerdriver.cpp 153a0936e1eSNicolas Bonnefon ) 154*702af59eSNicolas Bonnefonelseif (LINUX) 155*702af59eSNicolas Bonnefon # set(FileWatcherEngine_SOURCES ../src/inotifywatchtowerdriver.cpp) 15684af0c9bSNicolas Bonnefonendif (WIN32) 15784af0c9bSNicolas Bonnefon 15891f7c705SNicolas Bonnefon# Compiler flags 15991f7c705SNicolas Bonnefonset(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARANOID_FLAGS} -fPIC -DGLOGG_VERSION=\\\"unit_tests\\\" -g -gdwarf-2") 16084af0c9bSNicolas Bonnefon 16184af0c9bSNicolas Bonnefon# Add test cpp file 16284af0c9bSNicolas Bonnefonadd_executable(glogg_tests 16384af0c9bSNicolas Bonnefon ${glogg_SOURCES} 16484af0c9bSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1651ee847caSNicolas Bonnefon ${glogg_UTESTS} 16684af0c9bSNicolas Bonnefon) 16784af0c9bSNicolas Bonnefon 16884af0c9bSNicolas Bonnefon# Link test executable against gtest & gtest_main 1699ba963cbSNicolas Bonnefontarget_link_libraries(glogg_tests ${LIBS} gtest_main pthread Qt5::Widgets) 17084af0c9bSNicolas Bonnefon 1711ee847caSNicolas Bonnefonadd_executable(glogg_itests 1721ee847caSNicolas Bonnefon ${glogg_SOURCES} 1731ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1741ee847caSNicolas Bonnefon ${glogg_ITESTS} 1751ee847caSNicolas Bonnefon itests.cpp 1761ee847caSNicolas Bonnefon) 1771ee847caSNicolas Bonnefon 1789ba963cbSNicolas Bonnefontarget_link_libraries(glogg_itests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1791ee847caSNicolas Bonnefon 1801ee847caSNicolas Bonnefonadd_executable(glogg_ptests 1811ee847caSNicolas Bonnefon ${glogg_SOURCES} 1821ee847caSNicolas Bonnefon ${FileWatcherEngine_SOURCES} 1831ee847caSNicolas Bonnefon ${glogg_PTESTS} 1841ee847caSNicolas Bonnefon itests.cpp 1851ee847caSNicolas Bonnefon) 1861ee847caSNicolas Bonnefon 1879ba963cbSNicolas Bonnefontarget_link_libraries(glogg_ptests ${LIBS} pthread Qt5::Widgets Qt5::Test) 1881ee847caSNicolas Bonnefon 18984af0c9bSNicolas Bonnefonadd_test( 19084af0c9bSNicolas Bonnefon NAME glogg_tests 19184af0c9bSNicolas Bonnefon COMMAND glogg_tests 19284af0c9bSNicolas Bonnefon) 193