Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
CMakeLists for OpenCV
cmake_minimum_required( VERSION 3.6 )
# Create Project
project( solution )
add_executable( project main.cpp )
# Set StartUp Project
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find Package
set( OpenCV_DIR "C:/Program Files/opencv/build" )
option( OpenCV_STATIC OFF )
find_package( OpenCV REQUIRED )
# Set Static Link Runtime Library
if( OpenCV_STATIC )
foreach( flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO )
if( ${flag_var} MATCHES "/MD" )
string( REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}" )
endif()
endforeach()
endif()
if( OpenCV_FOUND )
# Additional Include Directories
include_directories( ${OpenCV_INCLUDE_DIRS} )
# Additional Library Directories
link_directories( ${OpenCV_LIB_DIR} )
# Additional Dependencies
target_link_libraries( project ${OpenCV_LIBS} )
endif()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment