CMake is not able to link to vcpkg library

Viewed 3169

I installed a new library in vcpkg, i.e, ITK and now I am trying to compile a very first code example available in its guide, I installed it via vcpkg so I skipped the installation part(provided in that guide) and immediately created a new cmake project in visual studio.

+ ItkProjects
    - ItkProjects
        - main.cpp
        - CMakeLists.txt  #1
    - CMakeLists.txt   #2

CMakeLists.txt #2

cmake_minimum_required (VERSION 3.8)

project ("ItkProjects")

# Include sub-projects.
add_subdirectory ("ItkProjects")

CMakeLists.txt #1

cmake_minimum_required (VERSION 3.8)

find_package(ITK CONFIG REQUIRED)

include_directories(${ITK_INCLUDE_DIRS})

add_executable (ItkProjects "main.cpp")

target_link_libraries(ItkProjects ${ITK_LIBRARIES})

main.cpp

#include "itkImage.h"

using namespace std;

int main()
{
    using ImageType = itk::Image<unsigned char, 3>;

    ImageType::Pointer image = ImageType::New();

    return EXIT_SUCCESS;
}

CMake configured and generated with no errors but when compiling I end up with this error:

ninja : error : '/lib/double-conversion.lib', needed by 'ItkProjects/ItkProjects.exe', missing and no known rule to make it

I am sure that this file exist in D:\vcpkg\installed\x64-windows\lib (my installation path) but I am not sure why ninja can't link to it. Please any help..

2 Answers

Have you tried to run cmake with the vcpkg cmake-tool like:

cmake CMakeLists.txt "-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake"

If I have understood this right this will held to add the correct foldernames. Just found this here: using vcpkg with cmake

Locate the "vcpkg/scripts/buildsystems/vcpkg.cmake" file. Search "VS_GLOBAL_VcpkgEnabled" and change property from false to true.

Related