]> sigrok.org Git - pulseview.git/commitdiff
Build system: Fix issue with unit tests, simplify code.
authorUwe Hermann <redacted>
Sat, 29 Nov 2014 16:42:10 +0000 (17:42 +0100)
committerUwe Hermann <redacted>
Sat, 29 Nov 2014 16:48:08 +0000 (17:48 +0100)
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
test/CMakeLists.txt

index 49358505fe81dd4891a0fc0c4777cb8b9ca89201..eb5d0f15de2945b2f07e343eccaac22627589c77 100644 (file)
@@ -96,12 +96,20 @@ else()
 endif()
 
 if(WIN32)
 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*).
        # 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)
        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()
 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.
 
 # Find the platform's thread library (needed for C++11 threads).
 # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
index 7c454c027a1f89a2bb9e8b155025e6850b755308..22612b91d05e59378fd96df74238f4759194a24a 100644 (file)
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ##
 
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ##
 
-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
 set(pulseview_TEST_SOURCES
        ${PROJECT_SOURCE_DIR}/pv/devicemanager.cpp
        ${PROJECT_SOURCE_DIR}/pv/sigsession.cpp
@@ -134,10 +108,11 @@ if(ENABLE_DECODE)
        )
 endif()
 
        )
 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.
 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(-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}
 add_executable(pulseview-test
        ${pulseview_TEST_SOURCES}
        ${pulseview_TEST_HEADERS_MOC}