On 02/14/2013 12:26 PM, Andreas Haferburg wrote:
Does CMake find 2.4.3 if you remove 2.3.1? CMake probably doesn't even
look in /tmp/. You could try moving it to /usr/share/OpenCV-2.4.3/.

If the version arg doesn't work, I think your best bet is to use a
naming convention for the library directories (or create symlinks), e.g.
<lib>-<version>-<arch>, then use that directory in the find script.

Andreas

The link_directories() command seems to do the trick...

I'm currently at this, which seems to work:

----------------------------------------------------------------------------
# Change this depending on what you need.
set(USE_TMP_OPENCV TRUE)

if(USE_TMP_OPENCV)

  #Manual setting: OpenCV from /tmp/opencv_install
  set(OpenCV_INCLUDE_DIR "/tmp/opencv_install/include/opencv")
  include_directories(${OpenCV_INCLUDE_DIR})
set(OpenCV_LIBS "opencv_gpu;opencv_contrib;opencv_legacy;opencv_objdetect;opencv_calib3d;opencv_features2d;opencv_video;opencv_highgui;opencv_ml;opencv_imgproc;opencv_flann;opencv_core")
  link_directories(/tmp/opencv_install/lib)

elseif(USE_FAT_OPENCV)

  # Manual setting: OpenCV from FAT
  set(OpenCV_INCLUDE_DIR "/bla/bla/bla/opencv")
  include_directories(${OpenCV_INCLUDE_DIR})
set(OpenCV_LIBS "opencv_gpu;opencv_contrib;opencv_legacy;opencv_objdetect;opencv_calib3d;opencv_features2d;opencv_video;opencv_highgui;opencv_ml;opencv_imgproc;opencv_flann;opencv_core")
  link_directories(/bla/bla/bla/lib)

else()

  # Automatic discovery.
  find_package( OpenCV REQUIRED )

endif()
----------------------------------------------------------------------------

This still has the disadvantage that I have to change my CMakeLists.txt each time I want to switch. I would like to be able to switch using command-line arguments. I tried with cmake -d USE_TMP_OPENCV and stuff like that, but somehow the wrong version was used if i did not specify a -D argument (hoping for the automatic discovery). I guess I'll have to freshen up my understanding of if-elseif-else control flow and specifying variables on the cmake command line... tim to rtfm! ;-)

Regards,
Bart
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to