microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.27k stars 6.42k forks source link

[spdlog] build failure #42153

Open simaocat opened 3 days ago

simaocat commented 3 days ago

Operating system

arm64-osx

Compiler

AppleClang 15.0.0.15000309

Steps to reproduce the behavior

1. my dependencies are gflags spdlog brpc braft
2. here is my CMakeLists:
cmake_minimum_required(VERSION 3.18)

set(VCPKG_ROOT ${CMAKE_SOURCE_DIR}/vcpkg)
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
include(${CMAKE_TOOLCHAIN_FILE})

if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
    set(CMAKE_OSX_ARCHITECTURES arm64)
endif()

project(controller)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# install gflags
execute_process(
        COMMAND ${VCPKG_ROOT}/vcpkg install gflags
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        RESULT_VARIABLE result
)
if (result)
    message(FATAL_ERROR "-- Failed to install gflags")
endif()
set(GFLAGS_USE_TARGET_NAMESPACE ON)
find_package(gflags CONFIG REQUIRED)

# include spdlog
execute_process(
        COMMAND ${VCPKG_ROOT}/vcpkg install spdlog
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        RESULT_VARIABLE result
)
if (result)
    message(FATAL_ERROR "-- Failed to install spdlog")
endif()
find_package(spdlog CONFIG REQUIRED)

# install brpc
execute_process(
        COMMAND ${VCPKG_ROOT}/vcpkg install brpc
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        RESULT_VARIABLE result
)
if (result)
    message(FATAL_ERROR "-- Failed to install brpc")
endif()
find_package(unofficial-brpc CONFIG REQUIRED)

## include braft
execute_process(
        COMMAND ${VCPKG_ROOT}/vcpkg install braft
        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
        RESULT_VARIABLE result
)
if (result)
    message(FATAL_ERROR "-- Failed to install braft")
endif()
find_package(unofficial-braft CONFIG REQUIRED)

# target binary file
add_executable(controller main.cc)
target_link_libraries(controller PRIVATE
        gflags::gflags
        spdlog::spdlog
        unofficial::brpc::brpc-static
        unofficial::braft::braft-static
)

3. here are my directories:
cmake  CMakeLists.txt  main.cc  vcpkg
enter cmake and execute: cmake ..

Failure logs

CMake Warning at vcpkg/scripts/buildsystems/vcpkg.cmake:338 (message): Unable to determine target architecture, continuing without vcpkg. Call Stack (most recent call first): CMakeLists.txt:5 (include)

-- The C compiler identification is GNU 11.3.0 -- The CXX compiler identification is GNU 11.3.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done Computing installation plan... The following packages are already installed: gflags:x64-linux@2.2.2#9 gflags:x64-linux is already installed Total install time: 10.7 us gflags provides CMake targets:

set(GFLAGS_USE_TARGET_NAMESPACE ON)
find_package(gflags CONFIG REQUIRED)
target_link_libraries(main PRIVATE gflags::gflags)

Computing installation plan... The following packages are already installed: spdlog:x64-linux@1.15.0 spdlog:x64-linux is already installed Total install time: 9.8 us The package spdlog provides CMake targets:

find_package(spdlog CONFIG REQUIRED)
target_link_libraries(main PRIVATE spdlog::spdlog)

# Or use the header-only version
find_package(spdlog CONFIG REQUIRED)
target_link_libraries(main PRIVATE spdlog::spdlog_header_only)

CMake Error at CMakeLists.txt:36 (find_package): Could not find a package configuration file provided by "spdlog" with any of the following names:

spdlogConfig.cmake
spdlog-config.cmake

Add the installation prefix of "spdlog" to CMAKE_PREFIX_PATH or set "spdlog_DIR" to a directory containing one of the above files. If "spdlog" provides a separate development package or SDK, be sure it has been installed.

Additional context

I wonder why gflags is found correctly while spdlog is missing. I comment out the line: find_package(spdlog CONFIG REQUIRED), and then the new error is : could not find package unofficial-brpcConfig.cmake. I comment out the line: find_package(unofficial-brpc CONFIG REQUIRED), and then the new error is: could not find package unofficial-braftConfig.cmake I also test on Ubuntu platform, the same error again.

dg0yt commented 2 days ago

Use proper CMake integration:
You are not meant to run execute_process in your CMake project.
Either use manifest mode (vcpkg runs automatically during project), or use classic mode (i.e. you run vcpkg in advance).

Learn about using triplets: The issue says arm64-osx and AppleClang 15.0.0.15000309.
But the execute_process output shows x64-linux. spdlog:x64-linux provides nothing for arm64-osx.

Nosenzor commented 2 days ago

Yeah, use the manifest mode, that would avoid those lines in your cmake. Cleaner and more robust (i'm using spdlog on the same configuration and have no build issue)