X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=CMakeLists.txt;h=ffea00ef56b2dd17061699ff5c93e7d839d858ed;hb=723ac3f8c56bb5ed0b20f5911f6c449f114d35b6;hp=f429553ebba2c26edec055f013e50daa1eba3962;hpb=24d69d27584c7adec70bc0d6db764a3db04fce3c;p=pulseview.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f429553e..ffea00ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,9 @@ cmake_minimum_required(VERSION 2.8.12) -include(GNUInstallDirs) +project(pulseview C CXX) -project(pulseview) +include(GNUInstallDirs) # Let AUTOMOC and AUTOUIC process GENERATED files. if(POLICY CMP0071) @@ -74,6 +74,13 @@ add_subdirectory(manual) #= Dependencies #------------------------------------------------------------------------------- +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) +include(CMakePushCheckState) +include(memaccess) + +find_package(PkgConfig) + list(APPEND PKGDEPS glib-2.0>=2.28.0) list(APPEND PKGDEPS glibmm-2.4>=2.28.0) @@ -93,7 +100,6 @@ if(ANDROID) list(APPEND PKGDEPS libsigrokandroidutils>=0.1.0) endif() -find_package(PkgConfig) pkg_check_modules(LIBSRCXX ${LIBSR_CXX_BINDING}) if(NOT LIBSRCXX_FOUND OR NOT LIBSRCXX_VERSION) message(FATAL_ERROR "libsigrok C++ bindings missing, check libsigrok's 'configure' output (missing dependencies?)") @@ -151,48 +157,66 @@ find_package(Threads REQUIRED) # Helper for checking for atomics function(check_working_cxx_atomics varname additional_lib) - include(CheckCXXSourceCompiles) - include(CMakePushCheckState) - cmake_push_check_state() - set(CMAKE_REQUIRED_FLAGS "-std=c++11") - set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}") - set(CMAKE_REQUIRED_QUIET 1) - CHECK_CXX_SOURCE_COMPILES(" + cmake_push_check_state() + set(CMAKE_REQUIRED_FLAGS "-std=c++11") + set(CMAKE_REQUIRED_LIBRARIES "${additional_lib}") + set(CMAKE_REQUIRED_QUIET 1) + CHECK_CXX_SOURCE_COMPILES(" #include std::atomic x; int main() { - return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst); + return std::atomic_fetch_add_explicit(&x, 1, std::memory_order_seq_cst); } " ${varname}) - cmake_pop_check_state() + cmake_pop_check_state() endfunction(check_working_cxx_atomics) # First check if atomics work without the library. # If not, check if the library exists, and atomics work with it. check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITHOUT_LIB "") if(HAVE_CXX_ATOMICS_WITHOUT_LIB) - message(STATUS "Atomics provided by the C-library - yes") + message(STATUS "Atomics provided by the C-library - yes") else() - message(STATUS "Atomics provided by the C-library - no") - find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib) - if(LIBATOMIC_LIBRARY) - check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}") - if (HAVE_CXX_ATOMICS_WITH_LIB) - message(STATUS "Atomics provided by libatomic - yes") - else() - message(STATUS "Atomics provided by libatomic - no") - message(FATAL_ERROR "Compiler must support std::atomic!") - endif() - else() - message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.") - endif() + message(STATUS "Atomics provided by the C-library - no") + find_library(LIBATOMIC_LIBRARY NAMES atomic PATH_SUFFIXES lib) + if(LIBATOMIC_LIBRARY) + check_working_cxx_atomics(HAVE_CXX_ATOMICS_WITH_LIB "${LIBATOMIC_LIBRARY}") + if (HAVE_CXX_ATOMICS_WITH_LIB) + message(STATUS "Atomics provided by libatomic - yes") + else() + message(STATUS "Atomics provided by libatomic - no") + message(FATAL_ERROR "Compiler must support std::atomic!") + endif() + else() + message(FATAL_ERROR "Compiler appears to require libatomic, but cannot find it.") + endif() +endif() + +# Check availability of features which depend on library versions. +# TODO Ideally use check_symbol_exists() instead, reduce boilerplate. +if(ENABLE_DECODE) + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES "${PKGDEPS_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "sigrokdecode") + foreach (LPATH ${PKGDEPS_LIBRARY_DIRS}) + list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-L${LPATH}") + endforeach () + check_c_source_compiles(" + #include + int main(int argc, char *argv[]) + { + (void)argc; + (void)argv; + return srd_session_send_eof(NULL); + } + " HAVE_SRD_SESSION_SEND_EOF) + cmake_pop_check_state() endif() #=============================================================================== #= System Introspection #------------------------------------------------------------------------------- -include(memaccess) memaccess_check_unaligned_le(HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS) #=============================================================================== @@ -247,6 +271,7 @@ set(pulseview_SOURCES pv/globalsettings.cpp pv/logging.cpp pv/mainwindow.cpp + pv/metadata_obj.cpp pv/session.cpp pv/storesession.cpp pv/util.cpp @@ -257,6 +282,7 @@ set(pulseview_SOURCES pv/data/analogsegment.cpp pv/data/logic.cpp pv/data/logicsegment.cpp + pv/data/mathsignal.cpp pv/data/signalbase.cpp pv/data/signaldata.cpp pv/data/segment.cpp @@ -284,6 +310,7 @@ set(pulseview_SOURCES pv/views/trace/cursorpair.cpp pv/views/trace/flag.cpp pv/views/trace/header.cpp + pv/views/trace/mathsignal.cpp pv/views/trace/marginwidget.cpp pv/views/trace/logicsignal.cpp pv/views/trace/ruler.cpp @@ -319,9 +346,11 @@ set(pulseview_SOURCES # This list includes only QObject derived class headers. set(pulseview_HEADERS + pv/exprtk.hpp pv/logging.hpp pv/globalsettings.hpp pv/mainwindow.hpp + pv/metadata_obj.hpp pv/session.hpp pv/storesession.hpp pv/binding/device.hpp @@ -329,6 +358,7 @@ set(pulseview_HEADERS pv/data/analogsegment.hpp pv/data/logic.hpp pv/data/logicsegment.hpp + pv/data/mathsignal.hpp pv/data/signalbase.hpp pv/dialogs/connect.hpp pv/dialogs/inputoutputoptions.hpp @@ -349,6 +379,7 @@ set(pulseview_HEADERS pv/views/trace/flag.hpp pv/views/trace/header.hpp pv/views/trace/logicsignal.hpp + pv/views/trace/mathsignal.hpp pv/views/trace/marginwidget.hpp pv/views/trace/ruler.hpp pv/views/trace/signal.hpp @@ -399,7 +430,6 @@ if(ENABLE_DECODE) pv/subwindows/decoder_selector/subwindow.cpp pv/views/decoder_binary/view.cpp pv/views/decoder_binary/QHexView.cpp - pv/views/tabular_decoder/item.cpp pv/views/tabular_decoder/model.cpp pv/views/tabular_decoder/view.cpp pv/views/trace/decodetrace.cpp @@ -459,6 +489,9 @@ add_definitions(-D__STDC_LIMIT_MACROS) add_definitions(-Wall -Wextra) add_definitions(-std=c++11) add_definitions(-DBOOST_MATH_DISABLE_FLOAT128=1) +if(WIN32) + add_definitions(-Wa,-mbig-obj -O3) +endif() if(ENABLE_FLOW) add_definitions(-DENABLE_FLOW)