Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake cache generation fails. #1072

Open
ShadowMonster99 opened this issue Jul 3, 2024 · 0 comments
Open

Cmake cache generation fails. #1072

ShadowMonster99 opened this issue Jul 3, 2024 · 0 comments

Comments

@ShadowMonster99
Copy link

Description

Cmake cache generation fails while generating on x86-linux with vcpkg

heres my condensed CMakeUserPresets.json

{
  "version": 2,
  "configurePresets": [
    {
      "name": "default",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build",
      "hidden": true,
      "architecture": {
        "value": "x86",
        "strategy": "external"
      },
      "cacheVariables": {
        "CMAKE_TOOLCHAIN_FILE": "./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake"
      }
    },
    {
      "name": "linux",
      "inherits": "default",
      "generator": "Ninja",
      "displayName": "linux-x86",
      "description": "Default build for Linux",
      "cacheVariables": {
        "VCPKG_TARGET_TRIPLET": "x86-linux",
        "CMAKE_SYSTEM_PROCESSOR": "x86"
      }
    }
  ]
}

vcpkg.json

{
  "dependencies": [
    "libgit2",
    "cpr"
  ]
}

CmakeLists.txt

set(MILLENNIUM_VERSION "2.1.0")

cmake_minimum_required(VERSION 3.5.0)
set(BUILD_SHARED_LIBS OFF)

# set c++ directives
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD_REQUIRED ON)

project(Millennium LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "-fpermissive")

add_subdirectory(vendor/boxer)

add_compile_definitions(
  CURL_STATICLIB
)

find_package(cpr CONFIG REQUIRED)
find_package(unofficial-git2 CONFIG REQUIRED)

include_directories(${LIBGIT2_INCLUDE_DIRS})

set(SOURCE_FILES 
  "src/main.cc"
  ...
)
 add_executable(Millennium "${SOURCE_FILES}")

target_link_libraries(Millennium 
  Boxer
  cpr::cpr
  unofficial::git2::git2
)

Configuration Output:

[main] Configuring project: Millennium 
[proc] Executing command: /usr/bin/cmake -DVCPKG_TARGET_TRIPLET=x86-linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DCMAKE_TOOLCHAIN_FILE=./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake -S/home/shadow/Documents/Millennium -B/home/shadow/Documents/Millennium/build -G Ninja
[cmake] -- Running vcpkg install
[cmake] Detecting compiler hash for triplet x64-linux...
[cmake] Compiler found: /usr/bin/c++
[cmake] Detecting compiler hash for triplet x86-linux...
[cmake] Compiler found: /usr/bin/c++
[cmake] All requested packages are currently installed.
[cmake] Total install time: 341 ns
[cmake] cpr provides CMake targets:
[cmake] 
[cmake]   # this is heuristically generated, and may not be correct
[cmake]   find_package(cpr CONFIG REQUIRED)
[cmake]   target_link_libraries(main PRIVATE cpr::cpr)
[cmake] 
[cmake] libgit2 provides CMake targets:
[cmake] 
[cmake]   # this is heuristically generated, and may not be correct
[cmake]   find_package(unofficial-git2 CONFIG REQUIRED)
[cmake]   target_link_libraries(main PRIVATE unofficial::git2::git2)
[cmake] 
[cmake] libgit2 provides pkg-config modules:
[cmake] 
[cmake]   # The git library, take 2
[cmake]   libgit2
[cmake] 
[cmake] -- Running vcpkg install - done
[cmake] CMake Error at vendor/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
[cmake]   Could not find a configuration file for package "cpr" that is compatible
[cmake]   with requested version "".
[cmake] 
[cmake]   The following configuration files were considered but not accepted:
[cmake] 
[cmake]     /home/shadow/Documents/Millennium/build/vcpkg_installed/x86-linux/share/cpr/cprConfig.cmake, version: 1.9.0 (32bit)
[cmake] 
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt:53 (find_package)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[proc] The command: /usr/bin/cmake -DVCPKG_TARGET_TRIPLET=x86-linux -DCMAKE_SYSTEM_PROCESSOR=x86 -DCMAKE_TOOLCHAIN_FILE=./vendor/vcpkg/scripts/buildsystems/vcpkg.cmake -S/home/shadow/Documents/Millennium -B/home/shadow/Documents/Millennium/build -G Ninja exited with code: 1

Everything seems to run smoothly on x64, with no issues. It might be a problem with vcpkg not supporting x86-linux officially, however I see no reason why that would break anything.

Example/How to Reproduce

  1. setup vcpkg with x86, and VCPKG_TARGET_TRIPLET as x86-linux
  2. configure cmake, in my case with CMakeUserPresets.json as cmake --preset=linux

Possible Fix

No response

Where did you get it from?

vcpkg

Additional Context/Your Environment

  • OS: Linux, Arch
  • Version: 6.9.7-arch1-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant