This is a patch that uses octave-config to help find the octave headers and libraries. I've tested this in a couple situations and it should be backwards compatible.

Motivation - With octave-3.4.0 in Fedora we have moved the libraries to /usr/lib/octave/3.4.0 instead of /usr/lib/octave-3.4.0. Not sure if this will be permanent, but it any case this patch supports any possible future moves as well.

Note - in octave 3.2 octave-config -p OCTINCLUDEDIR returns /usr/include/octave-VERSION. In 3.4 it returns /usr/include/octave-VERSION/octave. This patch handles both cases by continuing to use find_path.

- Orion

--
Orion Poplawski
Technical Manager                     303-415-9701 x222
NWRA/CoRA Division                    FAX: 303-415-9702
3380 Mitchell Lane                  or...@cora.nwra.com
Boulder, CO 80301              http://www.cora.nwra.com
--- plplot-5.9.7/cmake/modules/octave.cmake.octave-config	2010-10-03 07:11:57.000000000 -0600
+++ plplot-5.9.7/cmake/modules/octave.cmake	2011-04-05 15:31:46.647860788 -0600
@@ -67,16 +67,21 @@
 endif(ENABLE_octave)
 
 if(ENABLE_octave)
+  find_program(OCTAVE_CONFIG octave-config)
+  if(OCTAVE_CONFIG)
+    message(STATUS "OCTAVE_CONFIG = ${OCTAVE_CONFIG}")
+  else(OCTAVE_CONFIG)
+    message(STATUS "WARNING: "
+    "octave-config not found. Disabling octave bindings")
+    set(ENABLE_octave OFF CACHE BOOL "Enable Octave bindings" FORCE)
+  endif(OCTAVE_CONFIG)
+endif(ENABLE_octave)
+
+if(ENABLE_octave)
   #OCTAVE_VERSION is the (dotted triplet) octave version.
   execute_process(
-  COMMAND ${OCTAVE} --version
-  OUTPUT_VARIABLE _OCTAVE_VERSION
-  )
-  string(REGEX REPLACE
-  "^.*version ([0-9]\\.[0-9]\\.[0-9]*).*$" 
-  "\\1"
-  OCTAVE_VERSION
-  ${_OCTAVE_VERSION}
+  COMMAND ${OCTAVE_CONFIG} -p VERSION
+  OUTPUT_VARIABLE OCTAVE_VERSION
   )
   message(STATUS "OCTAVE_VERSION = ${OCTAVE_VERSION}")
   # Logic that depends on octave version
@@ -106,22 +111,35 @@
   # if OCTAVE_INCLUDE_PATH is defined from the previous cmake run should be
   # fine.
   if(NOT DEFINED OCTAVE_INCLUDE_PATH)
+    execute_process(
+    COMMAND ${OCTAVE_CONFIG} -p OCTINCLUDEDIR
+    OUTPUT_VARIABLE OCTAVE_INCLUDE_DIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+    )
+
     find_path(
     OCTAVE_INCLUDE_PATH
     oct.h
-    PATH_SUFFIXES octave-${OCTAVE_VERSION}/octave
+    PATHS ${OCTAVE_INCLUDE_DIR}
+    PATH_SUFFIXES octave
+    )
+
+    execute_process(
+    COMMAND ${OCTAVE_CONFIG} -p OCTLIBDIR
+    OUTPUT_VARIABLE OCTAVE_LIB_DIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE
     )
 
     find_library(
     OCTAVE_LIBRARIES
     octave
-    PATH_SUFFIXES octave-${OCTAVE_VERSION}
+    PATHS ${OCTAVE_LIB_DIR}
     )
     
     find_library(
     OCTINTERP_LIBRARIES
     octinterp
-    PATH_SUFFIXES octave-${OCTAVE_VERSION}
+    PATHS ${OCTAVE_LIB_DIR}
     )
 
     if(OCTAVE_INCLUDE_PATH AND OCTAVE_LIBRARIES AND OCTINTERP_LIBRARIES)
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to