1

So I am currently trying to get my CMake Project to build after installing packages via vcpkg for the first time. I am using WSL2 under Win10 with Ubuntu 20.04 for the project, but building throws the following:

philip@DESKTOP-2CHKCMO:/mnt/c/Users/phili/_Documents/Projects/pixelator$ cmake .
-- OpenCV ARCH: 
-- OpenCV RUNTIME: 
-- OpenCV STATIC: ON
CMake Warning at /mnt/c/Users/phili/anaconda3/Library/opencvConfig.cmake:140 (message):
  Found OpenCV Windows Pack but it has no binaries compatible with your
  configuration.

  You should manually point CMake variable OpenCV_DIR to your build of OpenCV
  library.
Call Stack (most recent call first):
  CMakeLists.txt:13 (find_package)


-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/c/Users/phili/_Documents/Projects/pixelator

This is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.16)
project(pixelator LANGUAGES CXX)

#include("~/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE "~/vcpkg/scripts/buildsystems/vcpkg.cmake")

set(OpenCV_DIR "~/vcpkg/packages/opencv4_x64-linux/share/opencv")

find_package(protobuf CONFIG REQUIRED)
find_package(opencv CONFIG REQUIRED)
find_package(gflags CONFIG REQUIRED)

add_library(pixeling ${CMAKE_SOURCE_DIR}/source/pixeling.cpp)
target_link_libraries(pixeling ${OpenCV_LIBS})
add_executable(io ${CMAKE_SOURCE_DIR}/source/io.cpp)
target_link_libraries(io pixeling gflags)

The Folder is located in Windows10, but I am building via Ubuntu. Apparently CMake seems to ignore that I set the OpenCV_DIR and returns an openCV installation for my python anaconda environment (which is not located in wsl, but Windows), which it can't use. Also, I was under the impression that I would not even be required to set the OpenCV_DIR after linking the Toolchain file?

How do I get it to find the right openCV installation?

  • Setting `CMAKE_TOOLCHAIN_FILE` after the `project()` call is useless. Setting non-CACHE `OpenCV_DIR` variable is useless too. Normally, `CMAKE_TOOLCHAIN_FILE` should be set when invoke `cmake` (in the command line or in the GUI). The same place is preferred for `OpenCV_DIR` variable (but with working toolchain setting this variable is redudant). – Tsyvarev Apr 05 '21 at 18:44
  • 1
    Okay, I removed both lines from the CMakeLists and invoked with the following toolchain argument, but event then the error remains: `philip@DESKTOP-2CHKCMO:/mnt/c/Users/phili/_Documents/Projects/pixelator/build$ cmake . -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake` – DoubleSteakHouse Apr 05 '21 at 18:57

0 Answers0