Member-only story

Config CMake OpenCV4.0.1 for CLion

Prepare OpenCV source

Nhan Cao
3 min readApr 3, 2019
- macOS: Install form homebrew (https://medium.com/@nhancv/macos-mojave-10-14-3-setup-environment-for-opencv4-0-1-c-develop-fcae955d6b33)- Windows: download windows pack, extract and put opencv folder to `D:/_Program Files/` (https://medium.com/@nhancv/windows-10-set-up-environment-for-opencv4-0-1-c-development-78efaabb4141)

CMakeLists.txt

# cmake needs this line
cmake_minimum_required(VERSION 3.13)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
if(NOT CMAKE_BUILD_TYPE AND NOT (MSVC_IDE OR XCODE))
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type, one of: Release, Debug" FORCE)
endif()
# Set target name, change with your favorite name
project(nc-rd-facemask CXX)
message( STATUS "Build type: ${CMAKE_BUILD_TYPE}" )
message( STATUS "Configuration types: ${CMAKE_CONFIGURATION_TYPES}" )
# Detect 64 or 32 bit
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
# 64-bit project
SET(64_BIT_OS TRUE)
message( STATUS "A 64-bit OS detected" )
else()
SET(64_BIT_OS FALSE)
message( STATUS "A 32-bit OS detected" )
endif()
# Find OpenCV, you may need to set OpenCV_DIR variable
# to the absolute path to the directory containing OpenCVConfig.cmake file
# via the command line or GUI
if(WIN32)
set(OpenCV_DIR "D:/_Program Files/opencv/build/x64/vc15/lib")
endif()…

--

--

No responses yet