skip to Main Content

Using VCPKG

I follow step on https://github.com/David-Haim/concurrencpp#building-installing-and-testing

I already did vcpkg integrate install in the first place

vcpkg.json

{
  "name": "vcpkg-test",
  "version-string": "1.0.0",
  "dependencies": ["concurrencpp"]
}

VS Studio Command Line

vcpkg x-update-baseline --add-initial-baseline

vcpkg install --triplet-x64-windows



D:project_CPPC++_studyvcpkg_projectcpp20-test>vcpkg install --triplet x64-windows
Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)...
Detecting compiler hash for triplet x64-windows...
The following packages will be built and installed:
    concurrencpp[core]:x64-windows -> 0.1.7 -- C:UsersmichaelyinAppDataLocalvcpkgregistriesgit-trees5eb63527141d7d261b6e99945f81bf43e293cc8b
  * vcpkg-cmake[core]:x64-windows -> 2023-05-04 -- C:UsersmichaelyinAppDataLocalvcpkgregistriesgit-trees88a7058fc7fa73a9c4c99cfcae9d79e2abf87a5a
  * vcpkg-cmake-config[core]:x64-windows -> 2022-02-06#1 -- C:UsersmichaelyinAppDataLocalvcpkgregistriesgit-trees8d54cc4f487d51b655abec5f9c9c3f86ca83311f
Additional packages (*) will be modified to complete this operation.
Restored 3 package(s) from C:UsersmichaelyinAppDataLocalvcpkgarchives in 1.2 s. Use --debug to see more details.
Installing 1/3 vcpkg-cmake-config:x64-windows...
Elapsed time to handle vcpkg-cmake-config:x64-windows: 43.9 ms
Installing 2/3 vcpkg-cmake:x64-windows...
Elapsed time to handle vcpkg-cmake:x64-windows: 51.1 ms
Installing 3/3 concurrencpp:x64-windows...
Elapsed time to handle concurrencpp:x64-windows: 214 ms
Total install time: 1.5 s
concurrencpp provides CMake targets:

    # this is heuristically generated, and may not be correct
    find_package(concurrencpp CONFIG REQUIRED)
    target_link_libraries(main PRIVATE concurrencpp::concurrencpp)

my test code, same as documentation above

#include "concurrencpp/concurrencpp.h"
#include <iostream>

int main() {
   
    return 0;
}



I expect the linking is handled automatically, but in fact not the case

Error :Error (active)   E1696   cannot open source file "concurrencpp/concurrencpp.h"   cpp20new    D:project_CPPC++_studycpp20newcpp20newcpp20new.cpp 4

only use CMake approach, for reference

this seems working?

Without using vcpkg, and only use CMAKE, it will work

(1)create a cmake project in Visual Studio
(2)in same root, follow instruction there
https://github.com/David-Haim/concurrencpp#building-installing-and-
testing

$ git clone https://github.com/David-Haim/concurrencpp.git
$ cd concurrencpp
$ cmake -S . -B build/lib

edit my project cmake

project ("CMakeProject1")

# Add source to this project's executable.
add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h")


include(concurrencpp/cmake/coroutineOptions.cmake)
include(FetchContent)
FetchContent_Declare(concurrencpp SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/concurrencpp")
FetchContent_MakeAvailable(concurrencpp)
target_compile_features(CMakeProject1 PRIVATE cxx_std_20)
target_link_libraries(CMakeProject1 PRIVATE concurrencpp::concurrencpp)

But my main question is, how can I use vcpkg to manage library, can I do it without CMAKE?

2

Answers


  1. Chosen as BEST ANSWER

    Let me answer myself question, in case it is blocking for someone

    For VS Studio, above is correct, but there is one extra config missing(The exact anwer I'm looking for)

    !. No need to create a CMAke project, creat a normal Console project is enough 2.Assume you did above steps, in VS studio, you need to do extra config enter image description here

    Will leave VS code config to other people


  2. So there are two questions here:

    1. how can I use vcpkg to manage library?

    You already answered this yourself. Write a vcpkg.json and invoke vcpkg with it. Simply do the same as vcpkg.cmake here manually:
    https://github.com/microsoft/vcpkg/blob/c75ff8cf3b784f67aa614552f32a6b2c7b9d8efc/scripts/buildsystems/vcpkg.cmake#L522-L536

    1. can I do it without CMAKE?

    Es but you need to setup all required lookup paths (e.g. include/library paths etc.) on your own which is a tedious endaveour.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search