... | ... | @@ -30,3 +30,23 @@ Build the OpenCV libraries from source |
|
|
## Hello OpenCV World
|
|
|
|
|
|
see https://gitlab.com/opencv6/hello_opencv_world
|
|
|
|
|
|
# Building your own project
|
|
|
|
|
|
The following generic `CMakeLists.txt` template from the "Hello OpenCV World" project can be used to generate the build files for any supported toolchain by cmake:
|
|
|
|
|
|
```
|
|
|
cmake_minimum_required(VERSION 3.5)
|
|
|
project( MyProject VERSION 1.0 DESCRIPTION "MyProject" LANGUAGES CXX)
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
find_package( OpenCV REQUIRED HINTS "C:/OpenCV4.5.2" )
|
|
|
add_executable( MyProject )
|
|
|
target_sources( MyProject PRIVATE "MyProject.cpp" )
|
|
|
target_link_libraries( MyProject PRIVATE ${OpenCV_LIBS} )
|
|
|
```
|
|
|
|
|
|
The three `set` lines are recommended for maximum portability. The OpenCV path can be overridden on the command line by using a cmake `-DOpenCV_DIR=D:/OpenCV` like option.
|
|
|
|
|
|
When using Visual Studio toolchain, you can open the `.sln` solution file and use the IDE for editing and building. Or, you call `cmake --build .` from a cmd shell for building your project. |
|
|
\ No newline at end of file |