0

when I try to run this command ./vcpkg integrate install output:

Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/media/mohamed/C03CCDB43CCDA62E/tutorials/Innopolis/2nd/BCR/vcpkg/scripts/buildsystems/vcpkg.cmake"

then I used these commands:

cd toolsrc/
cmake . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake

output:

.cmake
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:
    CMAKE_TOOLCHAIN_FILE
-- Build files have been written to: /media/mohamed/C03CCDB43CCDA62E/tutorials/Innopolis/2nd/BCR/vcpkg/toolsrc

when I run this command again ./vcpkg integrate install I got the same error as above
the output of ./vcpkg list
box2d:x64-linux 2019-12-31 An open source C++ engine for simulating rigid b...

Here is the CMakeLists.txt it is in this directory /home/mohamed/vcpkg/toolsrc/CMakeLists.txt

cmake_minimum_required(VERSION 3.14)

project(vcpkg CXX)
include(cmake/utilities.cmake)

# ===============
# === Options ===
# ===============

include(CMakeDependentOption)

option(BUILD_TESTING "Option for enabling testing" ON)
option(VCPKG_DISABLE_METRICS "Option for disabling metrics" OFF)
option(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang, even versions that we don't know will work" OFF)
option(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings" ON)
option(VCPKG_WARNINGS_AS_ERRORS "Set warnings to be errors" ${VCPKG_DEVELOPMENT_WARNINGS})
option(VCPKG_BUILD_FUZZING "Option for enabling vcpkg-fuzz support" OFF)

CMAKE_DEPENDENT_OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF
    "BUILD_TESTING" OFF)

if(WERROR)
    message(DEPRECATION "-DWERROR is no longer a supported flag. It doesn't do anything.")
endif()
if(DEFINE_DISABLE_METRICS)
    message(DEPRECATION "DEFINE_DISABLE_METRICS is now called VCPKG_DISABLE_METRICS.")
    set(VCPKG_DISABLE_METRICS ${DEFINE_DISABLE_METRICS} CACHE BOOL "Option for disabling metrics" FORCE)
endif()

vcpkg_detect_compiler()
vcpkg_detect_standard_library()
vcpkg_detect_std_filesystem()

# ======================
# === Compiler Flags ===
# ======================

set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)

if(MSVC)
    # either MSVC, or clang-cl
    add_compile_options(-FC)

    if (MSVC_VERSION GREATER 1900)
        # Visual Studio 2017 or later
        add_compile_options(-permissive- -utf-8)
    endif()

    if(VCPKG_DEVELOPMENT_WARNINGS)
        string(REGEX REPLACE "[-/]W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

        add_compile_options(-W4)
        if(VCPKG_COMPILER STREQUAL "clang")
            add_compile_options(-Wmissing-prototypes -Wno-missing-field-initializers)
        endif()
    endif()

    if(VCPKG_WARNINGS_AS_ERRORS)
        add_compile_options(-WX)
    endif()
else()
    if(VCPKG_DEVELOPMENT_WARNINGS)
        add_compile_options(-Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-missing-field-initializers -Wno-redundant-move)

        # GCC and clang have different names for the same warning
        if(VCPKG_COMPILER STREQUAL "gcc")
            add_compile_options(-Wmissing-declarations)
        elseif(VCPKG_COMPILER STREQUAL "clang")
            add_compile_options(-Wmissing-prototypes)
        endif()
    endif()

    if(VCPKG_WARNINGS_AS_ERRORS)
        add_compile_options(-Werror)
    endif()
endif()

# ========================
# === System Libraries ===
# ========================

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)

add_compile_definitions(VCPKG_USE_STD_FILESYSTEM=$<BOOL:${VCPKG_USE_STD_FILESYSTEM}>)
if(VCPKG_REQUIRE_LINK_CXXFS)
    if(VCPKG_STANDARD_LIBRARY STREQUAL "libstdc++")
        link_libraries(stdc++fs)
    elseif(VCPKG_STANDARD_LIBRARY STREQUAL "libc++")
        link_libraries(c++fs)
    endif()
endif()

if (MINGW)
    add_compile_definitions(
        UNICODE
        _WIN32_WINNT=0x0601
        WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY=4
        __fastfail=exit)
    link_libraries(winhttp bcrypt version ole32 uuid)
endif()


# ===============
# === Targets ===
# ===============

add_compile_definitions(VCPKG_DISABLE_METRICS=$<BOOL:${VCPKG_DISABLE_METRICS}>)
include_directories(include)
file(GLOB_RECURSE VCPKGLIB_SOURCES CONFIGURE_DEPENDS src/vcpkg/*.cpp)
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})

add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
if(WIN32 AND NOT VCPKG_DISABLE_METRICS)
    add_executable(vcpkgmetricsuploader WIN32 src/vcpkgmetricsuploader.cpp $<TARGET_OBJECTS:vcpkglib>)
endif()

if (BUILD_TESTING)
    file(GLOB_RECURSE VCPKGTEST_SOURCES CONFIGURE_DEPENDS src/vcpkg-test/*.cpp)

    enable_testing()
    add_executable(vcpkg-test ${VCPKGTEST_SOURCES} $<TARGET_OBJECTS:vcpkglib>)
    add_test(NAME default COMMAND vcpkg-test --order rand --rng-seed time)

    if (VCPKG_BUILD_BENCHMARKING)
        target_compile_options(vcpkg-test PRIVATE -DCATCH_CONFIG_ENABLE_BENCHMARKING)
    endif()
endif()

if(VCPKG_BUILD_FUZZING)
    file(GLOB_RECURSE VCPKGFUZZ_SOURCES src/vcpkg-fuzz/*.cpp)
    add_executable(vcpkg-fuzz ${VCPKGFUZZ_SOURCES} $<TARGET_OBJECTS:vcpkglib>)
endif()

find_program(CLANG_FORMAT clang-format)
if(CLANG_FORMAT)
    file(GLOB_RECURSE VCPKG_FORMAT_SOURCES CONFIGURE_DEPENDS src/*.cpp include/pch.h include/vcpkg/*.h include/vcpkg-test/*.h)
    add_custom_target(format COMMAND ${CLANG_FORMAT} -i -verbose ${VCPKG_FORMAT_SOURCES})
endif()

# ===========
# === PCH ===
# ===========

if(MSVC)
    get_target_property(_srcs vcpkglib SOURCES)

    if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
        set_property(SOURCE src/pch.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
        set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
    endif()

    set_source_files_properties(src/pch.cpp PROPERTIES COMPILE_FLAGS "/Ycpch.h")
    target_sources(vcpkglib PRIVATE src/pch.cpp)
    target_compile_options(vcpkglib PRIVATE /Yupch.h /FIpch.h /Zm200)
endif()

I'm totally new to cmake is this the right cmakelists I should use or another one? my goal is include the box2d library in vscode

  • Remove build files (`CMakeCache.txt`) from the directory and setting `CMAKE_TOOLCHAIN_FILE` should work. Also, it is highly recommended to NOT use **in-source** build (when build files are written to the source directory). Instead of `.` use other directory for build the project. – Tsyvarev May 14 '20 at 07:54
  • I removed CMakeCache.txt which is inside the toolsrc and made a folder for build i cd into it and then run this command ``` cmake /home/mohamed/vcpkg/toolsrc/ -DCMAKE_TOOLCHAIN_FILE=/home/mohamed/vcpkg/scripts/buildsystems/vcpkg.cmake``` then I tried to integrate again but the same error – mohamed sayed May 14 '20 at 09:01
  • So, have you get the warning `Manually-specified variables were not used by the project` again or not? – Tsyvarev May 14 '20 at 09:21
  • BTW, something strange about your setting of CMAKE_TOOLCHAIN_FILE as *relative* path: It seems you call `cmake` from `/media/mohamed/C03CCDB43CCDA62E/tutorials/Innopolis/2nd/BCR/vcpkg/toolsrc` directory and use relative path `vcpkg/scripts/buildsystems/vcpkg.cmake`. This does NOT correspond to the absolute path `/media/mohamed/C03CCDB43CCDA62E/tutorials/Innopolis/2nd/BCR/vcpkg/scripts/buildsystems/vcpkg.cmake` suggested by `./vcpkg integrate install`. Have you tried to use absolute path for `CMAKE_TOOLCHAIN_FILE`, as the utility suggests? – Tsyvarev May 14 '20 at 09:29
  • I got this output after`cmake ../toolsrc/ -DCMAKE_TOOLCHAIN_FILE=/home/mohamed/vcpkg/scripts/buildsystems/vcpkg.cmake` `Build files have been written to: /home/mohamed/vcpkg/build` – mohamed sayed May 14 '20 at 10:08
  • Ok. So what **exact** error message do you get on `./vcpkg integrate install`? The same as the first one in your question post, which suggests to use `/media/mohamed/C03CCDB43CCDA62E/tutorials/Innopolis/2nd/BCR/vcpkg/scripts/buildsystems/vcpkg.cmake` path as `CMAKE_TOOLCHAIN_FILE`? Or the path has been changed that time? – Tsyvarev May 14 '20 at 11:51
  • sorry for confusion, I just recloned the repo in a different place to make everything clear. the output is as follow ``` Applied user-wide integration for this vcpkg root. CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=/home/mohamed/vcpkg/scripts/buildsystems/vcpkg.cmake" ``` – mohamed sayed May 14 '20 at 13:02
  • Well, the message `CMake projects should use` is not actually an error message. It is just a hint for further usage. So, what error/problem have you get? – Tsyvarev May 14 '20 at 15:24
  • I'm trying to include the box2d library in vscode output `fatal error: box2d/box2d.h: No such file or directory #include ` – mohamed sayed May 14 '20 at 15:40
  • `./vcpkg list box2d:x64-linux 2019-12-31 An open source C++ engine for simulating rigid b...` – mohamed sayed May 14 '20 at 15:41
  • "I'm trying to include the box2d library in vscode output" - It seems something wrong with a way you doing that. Show (add to the question post) your `CMakeLists.txt`. – Tsyvarev May 14 '20 at 15:43
  • I added the CMakeLists.txt to the question – mohamed sayed May 14 '20 at 16:17
  • Not sure where do you get this `CMakeLists.txt` but it is definitely not the one which is used by your project which uses `box2d` library. `vcpkg` provides a way for `find_package` to locate a package installed with `vcpkg`. Try to google for "find_package cmake box2d" and find some example of `CMakeLists.txt`. Then try to adapt this example for your case. – Tsyvarev May 14 '20 at 16:47

0 Answers0