]> sigrok.org Git - pulseview.git/commitdiff
cmake: check for optional libsigrokdecode features (send EOF)
authorGerhard Sittig <redacted>
Sun, 26 Dec 2021 06:54:36 +0000 (07:54 +0100)
committerGerhard Sittig <redacted>
Sun, 26 Dec 2021 13:01:10 +0000 (14:01 +0100)
Implement a feature check for the srd_session_send_eof() routine which
depends on the libsigrokdecode version. This test implementation is a
little more redundant than necessary, check_symbol_exists() would be
preferred instead but would not work in my local setup.

CMakeLists.txt
config.h.in

index add9c02f9923464ba02ed981022b49c899ad8b0f..7791b1b138daa601b888f1f59ffe1c1d445e95c3 100644 (file)
@@ -188,6 +188,29 @@ else()
   endif()
 endif()
 
+# Check availability of features which depend on library versions.
+# TODO Ideally use check_symbol_exists() instead, reduce boilerplate.
+if(ENABLE_DECODE)
+       include(CheckCSourceCompiles)
+       include(CMakePushCheckState)
+       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 <libsigrokdecode/libsigrokdecode.h>
+       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
 #-------------------------------------------------------------------------------
index 7720001a94861339fbfe0458f63c100cb405b1ac..f5855d18ac8c44ec2911bb9362669bae97c2e3aa 100644 (file)
@@ -34,6 +34,9 @@
 /* Platform properties */
 #cmakedefine HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
 
+/* Presence of features which depend on library versions. */
+#cmakedefine HAVE_SRD_SESSION_SEND_EOF 1
+
 #define PV_GLIBMM_VERSION "@PV_GLIBMM_VERSION@"
 
 #endif