test/CMakeLists.txt: Fix MinGW build of the tests.
[pulseview.git] / test / CMakeLists.txt
index fdf674f50f6449b330774ec68e0c5856c8c59baf..57ca26f0026de927c6fb60a0c77e3fd2271ed415 100644 (file)
 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ##
 
+option(ENABLE_DECODE "Build with libsigrokdecode" FALSE)
+
+list(APPEND PKGDEPS libsigrok>=0.2.0)
+
+if(ENABLE_DECODE)
+       list(APPEND PKGDEPS libsigrokdecode>=0.2.0)
+endif()
+
+find_package(PkgConfig)
+pkg_check_modules(PKGDEPS REQUIRED ${PKGDEPS})
+
 # Find the platform's thread library (needed for boost-thread).
 # This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
 find_package(Threads)
 
-find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
+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 system thread_win32 unit_test_framework REQUIRED)
+else()
+       find_package(Boost 1.42 COMPONENTS system thread unit_test_framework REQUIRED)
+endif()
+
+
+find_program(QT_QMAKE_EXECUTABLE NAMES qmake4 qmake-qt4 qmake-mac)
+find_package(Qt4 REQUIRED)
 
 set(pulseview_TEST_SOURCES
-       ${PROJECT_SOURCE_DIR}/pv/data/snapshot.cpp
+       ${PROJECT_SOURCE_DIR}/pv/devicemanager.cpp
+       ${PROJECT_SOURCE_DIR}/pv/sigsession.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/analog.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/analogsnapshot.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/logic.cpp
        ${PROJECT_SOURCE_DIR}/pv/data/logicsnapshot.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/snapshot.cpp
+       ${PROJECT_SOURCE_DIR}/pv/data/signaldata.cpp
+       ${PROJECT_SOURCE_DIR}/pv/prop/int.cpp
+       ${PROJECT_SOURCE_DIR}/pv/prop/property.cpp
+       ${PROJECT_SOURCE_DIR}/pv/prop/string.cpp
+       ${PROJECT_SOURCE_DIR}/pv/prop/binding/binding.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/analogsignal.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/cursor.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/cursorpair.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/header.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/ruler.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/signal.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/timemarker.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/trace.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/tracepalette.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/view.cpp
+       ${PROJECT_SOURCE_DIR}/pv/view/viewport.cpp
+       ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.cpp
+       ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.cpp
+       ${PROJECT_SOURCE_DIR}/pv/widgets/popup.cpp
+       ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.cpp
+       data/analogsnapshot.cpp
        data/logicsnapshot.cpp
        test.cpp
 )
 
+# This list includes only QObject derived class headers.
+set(pulseview_TEST_HEADERS
+       ${PROJECT_SOURCE_DIR}/pv/sigsession.h
+       ${PROJECT_SOURCE_DIR}/pv/prop/int.h
+       ${PROJECT_SOURCE_DIR}/pv/prop/property.h
+       ${PROJECT_SOURCE_DIR}/pv/prop/string.h
+       ${PROJECT_SOURCE_DIR}/pv/view/cursor.h
+       ${PROJECT_SOURCE_DIR}/pv/view/header.h
+       ${PROJECT_SOURCE_DIR}/pv/view/logicsignal.h
+       ${PROJECT_SOURCE_DIR}/pv/view/marginwidget.h
+       ${PROJECT_SOURCE_DIR}/pv/view/ruler.h
+       ${PROJECT_SOURCE_DIR}/pv/view/selectableitem.h
+       ${PROJECT_SOURCE_DIR}/pv/view/signal.h
+       ${PROJECT_SOURCE_DIR}/pv/view/timemarker.h
+       ${PROJECT_SOURCE_DIR}/pv/view/trace.h
+       ${PROJECT_SOURCE_DIR}/pv/view/view.h
+       ${PROJECT_SOURCE_DIR}/pv/view/viewport.h
+       ${PROJECT_SOURCE_DIR}/pv/widgets/colourbutton.h
+       ${PROJECT_SOURCE_DIR}/pv/widgets/colourpopup.h
+       ${PROJECT_SOURCE_DIR}/pv/widgets/popup.h
+       ${PROJECT_SOURCE_DIR}/pv/widgets/wellarray.h
+)
+
+if(ENABLE_DECODE)
+       list(APPEND pulseview_TEST_SOURCES
+               ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.cpp
+               ${PROJECT_SOURCE_DIR}/pv/data/decode/decoder.cpp
+               ${PROJECT_SOURCE_DIR}/pv/data/decode/annotation.cpp
+               ${PROJECT_SOURCE_DIR}/pv/prop/binding/decoderoptions.cpp
+               ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.cpp
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.cpp
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.cpp
+               data/decoderstack.cpp
+       )
+
+       list(APPEND pulseview_TEST_HEADERS
+               ${PROJECT_SOURCE_DIR}/pv/data/decoderstack.h
+               ${PROJECT_SOURCE_DIR}/pv/view/decodetrace.h
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodergroupbox.h
+               ${PROJECT_SOURCE_DIR}/pv/widgets/decodermenu.h
+       )
+endif()
+
+qt4_wrap_cpp(pulseview_TEST_HEADERS_MOC ${pulseview_TEST_HEADERS})
+
+if(ENABLE_DECODE)
+       add_definitions(-DENABLE_DECODE)
+endif()
+
+# On MinGW we need to use static linking.
+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}
        ${CMAKE_THREAD_LIBS_INIT}
+       ${PKGDEPS_LIBRARIES}
+       ${QT_LIBRARIES}
 )
 
 add_executable(pulseview-test
        ${pulseview_TEST_SOURCES}
+       ${pulseview_TEST_HEADERS_MOC}
 )
 
 target_link_libraries(pulseview-test ${PULSEVIEW_LINK_LIBS})