From 226a15274c4b0f3374bed48c0c4684484762ccf5 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 29 Nov 2014 17:42:10 +0100 Subject: [PATCH] Build system: Fix issue with unit tests, simplify code. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Drop some unneeded lines from test/CMakeLists.txt. Most of the variables are inherited from the main CMakeLists.txt file. This reduces the amount of duplicated code and the likelyhood that the two CMakeLists.txt files get out of sync. This fixes the following issues when building the unit tests (related to mixing Qt4 and Qt5 apparently): [ 69%] Building CXX object CMakeFiles/pulseview.dir/signalhandler.cpp.o [...]/test/__/pv/moc_sigsession.cxx:13:2: error: #error "This file was generated using the moc from 4.8.6. It" #error "This file was generated using the moc from 4.8.6. It" ^ [...]/test/__/pv/moc_sigsession.cxx:14:2: error: #error "cannot be used with the include files from this version of Qt." #error "cannot be used with the include files from this version of Qt." ^ [...]/test/__/pv/moc_sigsession.cxx:15:2: error: #error "(The moc has changed too much.)" #error "(The moc has changed too much.)" ^ [...]/test/__/pv/moc_sigsession.cxx:64:7: error: ‘QMetaObjectExtraData’ does not name a type const QMetaObjectExtraData pv::SigSession::staticMetaObjectExtraData = { ^ [...]/test/__/pv/moc_sigsession.cxx:70:37: error: ‘staticMetaObjectExtraData’ was not declared in this scope qt_meta_data_pv__SigSession, &staticMetaObjectExtraData } ^ [...]/test/__/pv/moc_sigsession.cxx: In member function ‘virtual const QMetaObject* pv::SigSession::metaObject() const’: [...]/test/__/pv/moc_sigsession.cxx:79:71: error: conditional expression between distinct pointer types ‘QDynamicMetaObjectData*’ and ‘const QMetaObject*’ lacks a cast return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; ^ [...]/test/__/pv/moc_sigsession.cxx:80:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ test/CMakeFiles/pulseview-test.dir/build.make:1362: recipe for target 'test/CMakeFiles/pulseview-test.dir/__/pv/moc_sigsession.cxx.o' failed make[2]: *** [test/CMakeFiles/pulseview-test.dir/__/pv/moc_sigsession.cxx.o] Error 1 CMakeFiles/Makefile2:110: recipe for target 'test/CMakeFiles/pulseview-test.dir/all' failed make[1]: *** [test/CMakeFiles/pulseview-test.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... --- CMakeLists.txt | 8 +++++++ test/CMakeLists.txt | 54 +++++---------------------------------------- 2 files changed, 13 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4935850..eb5d0f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,12 +96,20 @@ else() endif() if(WIN32) +if(ENABLE_TESTS) # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'. # The library is named libboost_thread_win32* (not libboost_thread*). + find_package(Boost 1.42 COMPONENTS filesystem system thread_win32 unit_test_framework REQUIRED) +else() find_package(Boost 1.42 COMPONENTS filesystem system thread_win32 REQUIRED) +endif() +else() +if(ENABLE_TESTS) + find_package(Boost 1.42 COMPONENTS filesystem system thread unit_test_framework REQUIRED) else() find_package(Boost 1.42 COMPONENTS filesystem system thread REQUIRED) endif() +endif() # Find the platform's thread library (needed for C++11 threads). # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7c454c0..22612b9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -18,32 +18,6 @@ ## along with this program. If not, see . ## -option(ENABLE_DECODE "Build with libsigrokdecode" FALSE) - -list(APPEND PKGDEPS libsigrok>=0.3.0) - -if(ENABLE_DECODE) - list(APPEND PKGDEPS libsigrokdecode>=0.3.0) -endif() - -find_package(PkgConfig) -pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS}) - -if(WIN32) - # On Windows/MinGW we need to use 'thread_win32' instead of 'thread'. - # The library is named libboost_thread_win32* (not libboost_thread*). - find_package(Boost 1.42 COMPONENTS filesystem system thread_win32 unit_test_framework REQUIRED) -else() - find_package(Boost 1.42 COMPONENTS filesystem system thread unit_test_framework REQUIRED) -endif() - -# Find the platform's thread library (needed for C++11 threads). -# This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value. -find_package(Threads REQUIRED) - -find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac) -find_package(Qt4 REQUIRED) - set(pulseview_TEST_SOURCES ${PROJECT_SOURCE_DIR}/pv/devicemanager.cpp ${PROJECT_SOURCE_DIR}/pv/sigsession.cpp @@ -134,10 +108,11 @@ if(ENABLE_DECODE) ) endif() -qt4_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS}) - -if(ENABLE_DECODE) - add_definitions(-DENABLE_DECODE) +if(Qt5Core_FOUND) + qt5_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS}) +else() + qt4_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS}) + include(${QT_USE_FILE}) endif() # On MinGW we need to use static linking. @@ -145,25 +120,6 @@ if(NOT WIN32) add_definitions(-DBOOST_TEST_DYN_LINK) endif() -add_definitions(${QT_DEFINITIONS}) - -include_directories( - ${Boost_INCLUDE_DIRS} - ${PKGDEPS_INCLUDE_DIRS} -) - -set(PULSEVIEW_LINK_LIBS - ${Boost_LIBRARIES} - ${PKGDEPS_LIBRARIES} - ${QT_LIBRARIES} - ${CMAKE_THREAD_LIBS_INIT} -) - -if(WIN32) - # Workaround for a MinGW linking issue. - list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2") -endif() - add_executable(pulseview-test ${pulseview_TEST_SOURCES} ${pulseview_TEST_HEADERS_MOC} -- 2.30.2