gpt4 book ai didi

linux - Q : conan error: Incorrect 'clang' , 不是 CMake 检测到的那个: 'GNU' 当我使用选项 "-s build_type=Debug"

转载 作者:行者123 更新时间:2023-12-05 06:10:44 25 4
gpt4 key购买 nike

我试图在我的项目中通过 conan 管理 gtest 包。 conanfile.txt 如下:

[requires]  
gtest/1.10.0

[generators]
cmake

我的 CMakeLists.txt 如下:

cmake_minimum_required(VERSION 3.5)

project(TinyWebServer)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()


set(CMAKE_CXX_STANDARD 11)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)


if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wthread-safety )
endif()


add_compile_options(
# -DVALGRIND
-DCHECK_PTHREAD_RETURN_VALUE
-D_FILE_OFFSET_BITS=64
-Wall
-Wno-unused-parameter
-Woverloaded-virtual
-Wpointer-arith
-Wwrite-strings
)


enable_testing()

add_subdirectory(Logger)
add_subdirectory(Tools)
add_subdirectory(Pools)
add_subdirectory(Http)
add_subdirectory(Timer)
add_subdirectory(Net)
add_subdirectory(Test)

add_executable(${PROJECT_NAME} main.cc Config.cc)
target_link_libraries(${PROJECT_NAME}
Threads::Threads
Log::lib
Tools::lib
Pools::lib
Http::lib
Net::lib
Timer::lib
)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_SOURCE_DIR})

当我使用如下所示的命令构建我的项目时,一切顺利。

mkdir -p build/
cd build/
conan install .. --build missing -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++11 -s build_type=Release
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
make install -j4

但是当我将 build_type 选项从 Release 切换到 Debug 时,就像:

conan install .. --build missing -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++11 -s build_type=Debug

我收到一些错误信息:

phoenix@phoenix-virtual-machine:~/MyProject/MyTinyWebServer/build$ conan install .. --build missing -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++11 -s build_type=Debug
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=clang
compiler.libcxx=libstdc++11
compiler.version=3.8
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

gtest/1.10.0: WARN: Package is corrupted, removing folder: /home/phoenix/.conan/data/gtest/1.10.0/_/_/package/d5608ac34c43db836b618b9cfd33cb77c7dec959
conanfile.txt: Installing package
Requirements
gtest/1.10.0 from 'conan-center' - Cache
Packages
gtest/1.10.0:d5608ac34c43db836b618b9cfd33cb77c7dec959 - Build

Installing (downloading, building) binaries...
gtest/1.10.0: WARN: Build folder is dirty, removing it: /home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959
gtest/1.10.0: Copying sources to build folder
gtest/1.10.0: Building your package in /home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959
gtest/1.10.0: Generator cmake created conanbuildinfo.cmake
gtest/1.10.0: Calling build()
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: called by CMake conan helper
-- Conan: called inside local cache
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Adjusting fPIC flag (ON)
CMake Error at conanbuildinfo.cmake:578 (message):
Incorrect 'clang', is not the one detected by CMake: 'GNU'
Call Stack (most recent call first):
conanbuildinfo.cmake:141 (conan_check_compiler)
CMakeLists.txt:5 (conan_basic_setup)


-- Configuring incomplete, errors occurred!
See also "/home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959/CMakeFiles/CMakeOutput.log".
gtest/1.10.0:
gtest/1.10.0: ERROR: Package 'd5608ac34c43db836b618b9cfd33cb77c7dec959' build failed
gtest/1.10.0: WARN: Build folder /home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959
ERROR: gtest/1.10.0: Error in build() method, line 59
cmake = self._configure_cmake()
while calling '_configure_cmake', line 53
cmake.configure()
ConanException: Error 1 while executing cd '/home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959' && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="clang" -DCONAN_COMPILER_VERSION="3.8" -DCONAN_CXX_FLAGS="-m64" -DCONAN_SHARED_LINKER_FLAGS="-m64" -DCONAN_C_FLAGS="-m64" -DCONAN_LIBCXX="libstdc++11" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="/home/phoenix/.conan/data/gtest/1.10.0/_/_/package/d5608ac34c43db836b618b9cfd33cb77c7dec959" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCONAN_CMAKE_POSITION_INDEPENDENT_CODE="ON" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DCUSTOM_DEBUG_POSTFIX="d" -DBUILD_GMOCK="True" -DGTEST_NO_MAIN="False" -Dgtest_hide_internal_symbols="False" -Wno-dev '/home/phoenix/.conan/data/gtest/1.10.0/_/_/build/d5608ac34c43db836b618b9cfd33cb77c7dec959'

这让我很困惑。命令 conan install .. --build missing -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++11 -s build_type=Debug 已将编译器指定为铛。但是从消息 Incorrect 'clang', is not the one detected by CMake: 'GNU' 看来,柯南似乎检测到了 gcc 编译器。为什么会这样?如果我想将我的项目构建为调试版本,我应该怎么做?谢谢~

最佳答案

哦,我想我犯了一些错误。使用 conan 安装 gtest 包和将我的项目构建为调试版本是两件完全不同的事情。因此,如果我想将我的项目构建为调试版本,我应该像这样使用命令:

conan install .. --build missing -s compiler=clang -s compiler.version=3.8 -s compiler.libcxx=libstdc++11 -s build_type=Release
cmake .. -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug

gtest 的版本是 Release 并不能阻止我将我的项目编译为调试版本。 😂

关于linux - Q : conan error: Incorrect 'clang' , 不是 CMake 检测到的那个: 'GNU' 当我使用选项 "-s build_type=Debug",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64306231/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com