cmake-js icon indicating copy to clipboard operation
cmake-js copied to clipboard

vcpkg not working

Open mupchurch-verys opened this issue 6 years ago • 10 comments

trying to get vcpkg to work... I set it to compile with -DCMAKE_TOOLCHAIN_FILE=... but it still seems to not pick it up.

mupchurch-verys avatar Apr 15 '20 01:04 mupchurch-verys

So... part of the problem is when I send the commands needed for vcpkg support in cmake -DCMAKE_TOOLCHAIN_FILE... For some reason cmake-js does not want to pass that along to cmake... I've worked around the issue by updating my local copy of cmake.js... might create a PR to add a new command for vcpkg support... will also need to do documentation etc... it's a big pain thats for sure.

mupchurch-verys avatar Apr 15 '20 20:04 mupchurch-verys

if anyone has found another way to do this I'm all ears

mupchurch-verys avatar Apr 15 '20 20:04 mupchurch-verys

@mupchurch-verys you should be able to do something like this at the top of your CMakeLists.txt

set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

I am using this mechanism at https://github.com/japj/pa-opus-audio/blob/master/CMakeLists.txt#L4

Note that I followed this from a best practice as described at https://github.com/marketplace/actions/run-vcpkg#use-vcpkg-as-a-submodule-of-your-repository

japj avatar May 01 '20 19:05 japj

I have the same issue. cmake don't find packages it's like CMAKE_TOOLCHAIN_FILE is ignore

nebnes avatar May 07 '20 08:05 nebnes

@mupchurch-verys you need to call cmake-js compile --CDCMAKE_TOOLCHAIN_FILE="..."

mathisloge avatar Jul 02 '21 11:07 mathisloge

@mupchurch-verys you need to call cmake-js compile --CDCMAKE_TOOLCHAIN_FILE="..."

still not working...it's been a year

KaivnD avatar Aug 25 '21 09:08 KaivnD

It works quite well for me.

mathisloge avatar Aug 25 '21 09:08 mathisloge

@KaivnD have you tried it with something like this:

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
    set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
endif()
project(top-level-projeczt)

make sure, that the toolchain will get set before the very first project(...) call

mathisloge avatar Aug 25 '21 12:08 mathisloge

@KaivnD have you tried it with something like this:


if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)

    set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")

endif()

project(top-level-projeczt)

make sure, that the toolchain will get set before the very first project(...) call

Ok, I'll try it. But I think this way will mess my work director up. One of reason I choose vcpkg is I don't need add so many dependencies to my source code, to do so I need add vcpkg it self, that's wired, vcpkg don't have binary release, like nuget, perhaps I haven't totally get the vcpkg install way is more effective. Thanks anyway.

KaivnD avatar Aug 26 '21 01:08 KaivnD

@KaivnD it's really common to add vcpkg as a submodule. But if you have a local installation of vcpkg, you can pass it as a tool_chain_file, too. If cmake-js compile --CDCMAKE_TOOLCHAIN_FILE="..." won't work for you, you can try to use

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)

    set(CMAKE_TOOLCHAIN_FILE "${MY_TOOLCHAIN}")

endif()

project(top-level-project)

and call cmake-js with cmake-js compile --CDMY_TOOLCHAIN="<path_to_vcpkg>"

mathisloge avatar Aug 27 '21 13:08 mathisloge