libspnav doesn't announce its version in CMake "Summary report"

This subforum is specifically to discuss packaging issues on different platforms (windows, mac, linux), and using different packaging systems (conda, etc...)
User avatar
waebbl
Posts: 164
Joined: Thu Aug 16, 2018 3:12 pm

Re: libspnav doesn't announce its version in CMake "Summary report"

Post by waebbl »

This patch gives the desired output on my machine

Code: Select all

diff --git a/cMake/FindSpnav.cmake b/cMake/FindSpnav.cmake
index a9d234f235..c7f7efef75 100644
--- a/cMake/FindSpnav.cmake
+++ b/cMake/FindSpnav.cmake
@@ -9,20 +9,13 @@
 IF(UNIX)
 
     FIND_PATH(SPNAV_INCLUDE_DIR spnav.h)
-
-    FIND_LIBRARY(SPNAV_LIBRARY
-        NAMES
-        spnav libspnav
-    )
-
-# Support the REQUIRED and QUIET arguments, and set SPNAV_FOUND if found.
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Spnav DEFAULT_MSG SPNAV_LIBRARY
-                                  SPNAV_INCLUDE_DIR)
-
-if(SPNAV_FOUND)
-    set(SPNAV_LIBRARIES ${SPNAV_LIBRARY})
-endif()
+    FIND_PACKAGE(PkgConfig)
+    IF(PKG_CONFIG_FOUND)
+        PKG_CHECK_MODULES(SPNAV spnav)
+        IF(SPNAV_FOUND)
+            set(SPNAV_LIBRARY ${pkgcfg_lib_SPNAV_spnav})
+        ENDIF()
+    ENDIF()
 
 mark_as_advanced(SPNAV_LIBRARY SPNAV_INCLUDE_DIR)
 
diff --git a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake
index 926deff843..a17dc94bdf 100644
--- a/cMake/FreeCAD_Helpers/PrintFinalReport.cmake
+++ b/cMake/FreeCAD_Helpers/PrintFinalReport.cmake
@@ -167,7 +167,7 @@ macro(PrintFinalReport)
     #message(STATUS "SPNAV:               not available yet for your OS") # FREECAD_USE_3DCONNEXION instead...
     else(WIN32)
         if(DEFINED SPNAV_FOUND)
-            message(STATUS "SPNAV:               [${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]")
+            message(STATUS "SPNAV:               ${SPNAV_VERSION} [${SPNAV_LIBRARY}] [${SPNAV_INCLUDE_DIR}]")
         else(DEFINED SPNAV_FOUND)
             message(STATUS "SPNAV:               not found")
         endif(DEFINED SPNAV_FOUND)
with output

Code: Select all

-- Pivy:                0.6.6
-- SPNAV:               1.0 [/usr/lib64/libspnav.so] [/usr/include]
-- Matplotlib:          3.5.1
We could also get the include directories from the pkg-config file by requesting the Cflags variable, but it didn't work ad hoc on my test.
User avatar
chennes
Veteran
Posts: 2236
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: libspnav doesn't announce its version in CMake "Summary report"

Post by chennes »

As @wmayer points out, that pkgconf file is very new, so that's not going to be universal. Does this cause any problems if there is no pkgconf info for spnav?
Chris Hennes
Pioneer Library System
Post Reply