[CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Bart Vandewoestyne

Hello list,

To compile and link my code with the OpenCV library, I use

find_package( OpenCV REQUIRED )
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

and this works just fine: the OpenCV library that got installed using my 
package management system on Ubuntu 12.10 is being used.


However, under the directory /tmp/opencv_install I have another manual 
installation of a more recent OpenCV library, and I would like to use 
that one instead of the default on my system, or easily switch between 
the two versions.  How should I specify that in my CMakeLists.txt file? 
 I have tried


set(OpenCV_FOUND 1)
set(OpenCV_INCLUDE_DIR 
/home/bart/Git/Research/fat/inc/TraficonOpenCv/opencv)
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)

include_directories(${OpenCV_INCLUDE_DIR})
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

but even with these commands, still the default libs on my system are 
being used...


What is the correct way to specify that I want to build with the install 
under /tmp/opencv_install ?  And how can I easily switch between 
versions without needing to remove one or the other version?


Thanks!
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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Andreas Haferburg

Have you tried specifying the version?

FIND_PACKAGE(OpenCV 2.2.0 EXACT REQUIRED)

FIND_PACKAGE(OpenCV 2.4.0 EXACT REQUIRED)

Not sure if the FindOpenCV script can handle the version argument.

Andreas

On 14.02.2013 11:42, Bart Vandewoestyne wrote:

Hello list,

To compile and link my code with the OpenCV library, I use

find_package( OpenCV REQUIRED )
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

and this works just fine: the OpenCV library that got installed using my 
package management system
on Ubuntu 12.10 is being used.

However, under the directory /tmp/opencv_install I have another manual 
installation of a more recent
OpenCV library, and I would like to use that one instead of the default on my 
system, or easily
switch between the two versions.  How should I specify that in my 
CMakeLists.txt file?  I have tried

set(OpenCV_FOUND 1)
set(OpenCV_INCLUDE_DIR /home/bart/Git/Research/fat/inc/TraficonOpenCv/opencv)
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)

include_directories(${OpenCV_INCLUDE_DIR})
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

but even with these commands, still the default libs on my system are being 
used...

What is the correct way to specify that I want to build with the install under 
/tmp/opencv_install
?  And how can I easily switch between versions without needing to remove one 
or the other version?

Thanks!
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



--

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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Bart Vandewoestyne

On 02/14/2013 11:47 AM, Andreas Haferburg wrote:

Have you tried specifying the version?

FIND_PACKAGE(OpenCV 2.2.0 EXACT REQUIRED)

FIND_PACKAGE(OpenCV 2.4.0 EXACT REQUIRED)

Not sure if the FindOpenCV script can handle the version argument.

Andreas


Doesn't seem to work.  I have 2.4.3 installed under /tmp/opencv_install 
and I now used


  find_package( OpenCV 2.4.3 EXACT REQUIRED )

in my CMakeLists.txt, but I get:


CMake Error at CMakeLists.txt:7 (find_package):
  Could not find a configuration file for package OpenCV that exactly
  matches requested version 2.4.3.

  The following configuration files were considered but not accepted:

/usr/share/OpenCV/OpenCVConfig.cmake, version: 2.3.1



-- Configuring incomplete, errors occurred!


Any other suggestions?  It would really be nice for me to be able to 
easily switch between different OpenCV installs...


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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Petr Kmoch
Hi Bart.

When you look into the documentation of find_package() (in its
Configure mode), you'll find a list of paths and prefixes the find
machanism uses. You should be able to set some of those prefixes to
where your local installation of OpenCV is.

Petr

On Thu, Feb 14, 2013 at 12:09 PM, Bart Vandewoestyne
bart.vandewoest...@telenet.be wrote:
 On 02/14/2013 11:47 AM, Andreas Haferburg wrote:

 Have you tried specifying the version?

 FIND_PACKAGE(OpenCV 2.2.0 EXACT REQUIRED)

 FIND_PACKAGE(OpenCV 2.4.0 EXACT REQUIRED)

 Not sure if the FindOpenCV script can handle the version argument.

 Andreas


 Doesn't seem to work.  I have 2.4.3 installed under /tmp/opencv_install and
 I now used

   find_package( OpenCV 2.4.3 EXACT REQUIRED )

 in my CMakeLists.txt, but I get:


 CMake Error at CMakeLists.txt:7 (find_package):
   Could not find a configuration file for package OpenCV that exactly
   matches requested version 2.4.3.

   The following configuration files were considered but not accepted:

 /usr/share/OpenCV/OpenCVConfig.cmake, version: 2.3.1



 -- Configuring incomplete, errors occurred!


 Any other suggestions?  It would really be nice for me to be able to easily
 switch between different OpenCV installs...

 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
--

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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Andreas Haferburg
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



On 14.02.2013 12:09, Bart Vandewoestyne wrote:

On 02/14/2013 11:47 AM, Andreas Haferburg wrote:

Have you tried specifying the version?

FIND_PACKAGE(OpenCV 2.2.0 EXACT REQUIRED)

FIND_PACKAGE(OpenCV 2.4.0 EXACT REQUIRED)

Not sure if the FindOpenCV script can handle the version argument.

Andreas


Doesn't seem to work.  I have 2.4.3 installed under /tmp/opencv_install and I 
now used

   find_package( OpenCV 2.4.3 EXACT REQUIRED )

in my CMakeLists.txt, but I get:


CMake Error at CMakeLists.txt:7 (find_package):
   Could not find a configuration file for package OpenCV that exactly
   matches requested version 2.4.3.

   The following configuration files were considered but not accepted:

 /usr/share/OpenCV/OpenCVConfig.cmake, version: 2.3.1



-- Configuring incomplete, errors occurred!


Any other suggestions?  It would really be nice for me to be able to easily 
switch between different
OpenCV installs...

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



--
--

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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Bart Vandewoestyne

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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Bart Vandewoestyne

On 02/14/2013 04:35 PM, Andreas Stahl wrote:

Hello Bart,

have you tried setting OpenCV_DIR before calling find_package()? I'm
basing this on http://opencv.willowgarage.com/wiki/FindOpenCV.cmake
Most package PKGFind.cmake scripts look if PKG_DIR is set to a valid
directory and look there first for all the libraries before checking
default install paths. You would use it like this:

if(USE_TMP_OPENCV)
set(OpenCV_DIR /tmp/opencv_install)
elseif(USE_FAT_OPENCV)
set(OpenCV_DIR /bla/bla/bla/opencv)
endif()

find_package(OpenCV REQUIRED)


I quickly tested this, but seems not to work.  Currently, this is my 
best solution:


-
# Set this to the version of OpenCV that you need.
set(OPENCV_LIB latest)

if(OPENCV_LIB STREQUAL latest)

  message(STATUS Using my own compiled OpenCV.)
  include_directories(/opt/opencv/latest/include/opencv)
  link_directories(/opt/opencv/latest/lib)
  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)


elseif(OPENCV_LIB STREQUAL fat)

  message(STATUS Using OpenCV from foobar repository.)
  include_directories($ENV{HOME}/foo/bar)
  link_directories($ENV{HOME}/foo/bar)
  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)


elseif(OPENCV_LIB STREQUAL system)

  message(STATUS Using OpenCV that got automatically detected.)
  find_package( OpenCV REQUIRED )

else()
  message(ERROR No OpenCV library found!)
endif()



Not that clean, but works well enough for now :-)  I'm always interested 
in suggestions for making this shorter, cleaner, more elegant,...


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


Re: [CMake] Using different installs/versions of the OpenCV library

2013-02-14 Thread Andreas Stahl

Hello Bart,

have you tried setting OpenCV_DIR before calling find_package()? I'm 
basing this on http://opencv.willowgarage.com/wiki/FindOpenCV.cmake
Most package PKGFind.cmake scripts look if PKG_DIR is set to a valid 
directory and look there first for all the libraries before checking 
default install paths. You would use it like this:


if(USE_TMP_OPENCV)
set(OpenCV_DIR /tmp/opencv_install)
elseif(USE_FAT_OPENCV)
set(OpenCV_DIR /bla/bla/bla/opencv)
endif()

find_package(OpenCV REQUIRED)

Cheers,
Andreas S.

Am 14.02.2013 11:42, schrieb Bart Vandewoestyne:

Hello list,

To compile and link my code with the OpenCV library, I use

find_package( OpenCV REQUIRED )
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

and this works just fine: the OpenCV library that got installed using
my package management system on Ubuntu 12.10 is being used.

However, under the directory /tmp/opencv_install I have another manual
installation of a more recent OpenCV library, and I would like to use
that one instead of the default on my system, or easily switch between
the two versions.  How should I specify that in my CMakeLists.txt
file?  I have tried

set(OpenCV_FOUND 1)
set(OpenCV_INCLUDE_DIR
/home/bart/Git/Research/fat/inc/TraficonOpenCv/opencv)
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)
include_directories(${OpenCV_INCLUDE_DIR})
...
add_executable(framecountertest framecountertest.cpp)
target_link_libraries(framecountertest ${OpenCV_LIBS})

but even with these commands, still the default libs on my system are
being used...

What is the correct way to specify that I want to build with the
install under /tmp/opencv_install ?  And how can I easily switch
between versions without needing to remove one or the other version?

Thanks!
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



--
Andreas Stahl, Dipl. Medien-Inf.

Technische Universität Dresden
Fakultät Informatik
Institut für Software- und Multimediatechnik
Professur Mediengestaltung
01062 Dresden
Tel.: +49 (351) 463-37928
Fax:  +49 (351) 463-39261
E-Mail: andreas.st...@tu-dresden.de





smime.p7s
Description: S/MIME Kryptografische Unterschrift
--

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