xuanaux / cvblob

Automatically exported from code.google.com/p/cvblob
GNU Lesser General Public License v3.0
0 stars 0 forks source link

CMake improvement #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run Cmake from cvblob folder for the first time.
2. CMake will ask for several opencv libs and include directories.

What is the expected output? What do you see instead?
CMake should find OpenCV by itself.

What version of the product are you using? On what operating system?
SVN Revision 313. Windows 7. Mingw compiler. OpenCV 2.2. CMake 2.8.2.

Please provide any additional information below.
As opencv is constantly improving and changing, setting the opencv paths and 
libs each time you update your opencv version gets tricky.

CMake can implicitly find the OpenCV required files for you by using the 
command "find_package(OpenCV REQUIRED)". To make this work, several 
CMakeLists.txt files need some tweaking :
* remove the FindOpenCV.cmake file in the CMakeScripts directory.
* remove the lines : #include_directories(${OpenCV_INCLUDE_DIR})
* replace the lines TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${OpenCV_LIBRARIES} 
) with TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${OpenCV_LIBS} )

To avoid the policy warning you should either set the minimum required version 
to 2.6 or set a cmake policy .

Original issue reported on code.google.com by recastro...@gmail.com on 18 Dec 2010 at 11:52

GoogleCodeExporter commented 8 years ago
Hi again!

I have no idea that CMake can find OpenCV automatically already.

Only one thing: do you know if there is any way to indicate the path of OpenCV 
to CMake? With my script I can do it, and it is useful for some things... 
Anyway, I will implement the changes you propose, because it will be better and 
easier for most users.

Thank you very much for your help!

Original comment by grendel....@gmail.com on 20 Dec 2010 at 8:48

GoogleCodeExporter commented 8 years ago
Done!

Original comment by grendel....@gmail.com on 20 Dec 2010 at 9:02

GoogleCodeExporter commented 8 years ago
One thing: I just have made a change in "cvBlob/CMakeLists.txt" to build 
dynamic libraries instead of static. Please, can you check if it builds a DLL 
and link it with no problems?

Thanks!!

Original comment by grendel....@gmail.com on 20 Dec 2010 at 9:29

GoogleCodeExporter commented 8 years ago
In order to make the linker work, you should add :
TARGET_LINK_LIBRARIES( cvblob ${OpenCV_LIBS} ) after the line
add_library(cvblob SHARED ${cvBlob_CVBLOB}) in the CMakeLists.txt in the cvblob 
directory.
It then creates the dll and everything works nicely.

You can change the path of OpenCV in CMake, the variable is called OpenCV_DIR. 
That's really useful when you have multiple versions of OpenCV.

Original comment by recastro...@gmail.com on 20 Dec 2010 at 10:15