我有一个cmake项目,我一直在通过Visual Studio 17 2022编辑,使用Ninja作为生成器。这个项目还使用boost和其他一些库。Boost安装在默认位置C:\Boost。所有其他库都安装在我的用户文件夹中,因此它们已添加到我的%PATH%环境变量中。这个设置奏效了。我安装了Qt Creator,开始添加UI组件。安装Qt 6后5.0 MSVC 2019 64位,我无法编译该项目了。我最初尝试用Qt Creator构建,但失败了。我回到visual studio来构建这个项目,但失败了。但是,从命令行使用cmake编译仍然有效。
当我从命令行编译时,我注意到Visual Studio 17 2022被用作生成器。因此,我更改了CMakeUserPresets。json生成器转换为Visual Studio 17 2022,我将Qt构建工具包的生成器更改为Visual Studio 17 2022,但Qt和Visual Studio仍然无法编译该项目。我在构建项目Qt时得到的错误是:LINK : fatal error LNK1104: cannot open file 'libboost_log_setup-vc143-mt-gd-x64-1_78.lib' [C:\Users\calvin.bunge\git\build-ande-Desktop_Qt_6_5_0_MSVC2019_64bit-Debug\MotionLogicTest\MotionLogicTests.vcxproj]
。我从Visual Studio构建项目时得到的错误是:C:\Users\calvin.bunge\git\ande\out\build\x64-debug\LINK : fatal error LNK1104: cannot open file 'libboost_log_setup-vc143-mt-gd-x64-1_78.lib'
。当我用cmake编译时,这些链接错误不会发生。
当我用Visual Studio配置CMake时,我得到以下输出:
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- Found Boost: C:/Boost/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.71.0")
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Infrastructure/CMakeLists.txt:5 (find_package)
-- Boost_INCLUDE_DIR="C:/Boost/include/boost-1_78"
-- Boost_LIBRARY_DIR_RELEASE=""
-- Boost_LIBRARY_DIR_DEBUG=""
-- Boost_LIBRARY_DIRS=""
-- BOOST_ROOT=""
CMake Warning (dev) at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1264 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogic/CMakeLists.txt:63 (find_package)
CMake Warning (dev) at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1264 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Domain/CMakeLists.txt:50 (find_package)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Found Boost: C:/Boost/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.71.0") found components: log
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/calvin.bunge/git/ande/out/build/x64-debug
使用Qt配置CMake时:
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- CMAKE_CXX_COMPILER_ID="MSVC"
-- CMAKE_CXX_COMPILER_VERSION="19.34.31937.0"
-- CMAKE_VERSION="3.24.0-rc2"
-- CMAKE_GENERATOR="Visual Studio 17 2022"
MSVC
-- Found Boost: C:/Boost/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.71.0")
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Infrastructure/CMakeLists.txt:5 (find_package)
-- Boost_INCLUDE_DIR="C:/Boost/include/boost-1_78"
-- Boost_LIBRARY_DIR_RELEASE=""
-- Boost_LIBRARY_DIR_DEBUG="C:/Boost/lib"
-- Boost_LIBRARY_DIRS="C:/Boost/lib"
-- BOOST_ROOT=""
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1237 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogic/CMakeLists.txt:63 (find_package)
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1237 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Domain/CMakeLists.txt:50 (find_package)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
-- Found Boost: C:/Boost/lib/cmake/Boost-1.78.0/BoostConfig.cmake (found suitable version "1.78.0", minimum required is "1.71.0") found components: log
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/calvin.bunge/git/build-ande-Desktop_Qt_6_5_0_MSVC2019_64bit-Debug
当我从命令行配置时:
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- CMAKE_CXX_COMPILER_ID="MSVC"
-- CMAKE_CXX_COMPILER_VERSION="19.34.31937.0"
-- CMAKE_VERSION="3.24.0-rc2"
-- CMAKE_GENERATOR="Visual Studio 17 2022"
MSVC
-- Found Boost: C:/Boost/include/boost-1_78 (found suitable version "1.78.0", minimum required is "1.71.0")
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Infrastructure/CMakeLists.txt:5 (find_package)
-- Boost_INCLUDE_DIR="C:/Boost/include/boost-1_78"
-- Boost_LIBRARY_DIR_RELEASE=""
-- Boost_LIBRARY_DIR_DEBUG="C:/Boost/lib"
-- Boost_LIBRARY_DIRS="C:/Boost/lib"
-- BOOST_ROOT=""
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1237 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
InfrastructureTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogic/CMakeLists.txt:63 (find_package)
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1237 (message):
The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
not set. The policy's OLD behavior will be used. When using a URL
download, the timestamps of extracted files should preferably be that of
the time of extraction, otherwise code that depends on the extracted
contents might not be rebuilt if the URL changes. The OLD behavior
preserves the timestamps from the archive instead, but this is usually not
what you want. Update your project to the NEW behavior or specify the
DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
robustness issue.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:2 (FetchContent_Declare)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
MotionLogicTest/CMakeLists.txt:22 (find_package)
CMake Deprecation Warning at C:/Users/calvin.bunge/Open3D/CMake/Open3DConfig.cmake:18 (cmake_policy):
The OLD behavior for policy CMP0072 will be removed from a future version
of CMake.
The cmake-policies(7) manual explains that the OLD behaviors of all
policies are deprecated and that a policy should be set to OLD only under
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
Domain/CMakeLists.txt:50 (find_package)
-- Found Boost: C:/Boost/include/boost-1_78 (found suitable version "1.78.0", minimum required is "1.71.0") found components: log log_setup filesystem thread regex chrono atomic
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/calvin.bunge/git/ande/build
编译器版本是相同的,cmake版本是相同的,但是找到boost的消息是不同的。IDE在C:/Boost/lib/cmake/Boost-1中找到boost。78.0/BoostConfig.cmake,但命令行在C:/Boost/include/boost-1_78找到boost。另一个区别是命令行设置Boost_LIBRARY_DIRS、Boost_LIBRARY_DIR_RELEASE、Boost_LIBRARY_DIR_DEBUG,而IDE不设置。另外,-- Boost toolset is unknown (compiler MSVC 19.34.31937.0)
在IDE配置cmake时出现,但在IDE配置cmake时不出现。
我主要困惑的事实是,这个问题出现后,我安装了Qt的MSVC。我在安装Qt前半小时用Visual Studio编译了这个程序,没有更改任何cmake脚本,而且自从安装Qt后就不能从Visual Studio编译了。
**更新:**下面是使用boost log的模块的CMakeLists.txt
:
add_library(Common
Logger.cpp
Logger.h
MathUtility.cpp
MathUtility.h
StringUtility.cpp
StringUtility.h
)
target_include_directories(Common PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:>
)
# Eigen
target_link_libraries (Common Eigen3::Eigen)
find_package (Eigen3 3.4 REQUIRED)
# Boost
# Use static lib. Must specify or else log will look for shared lib
SET(Boost_USE_STATIC_LIBS ON)
find_package (Boost 1.71.0 REQUIRED COMPONENTS log)
target_link_libraries (Common Boost::boost)
target_link_libraries (Common Boost::log)
以下是项目的CMakeLists.txt
:
# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.14)
set(CMAKE_CXX_STANDARD 14)
project ("ANDE")
# Include sub-projects.
add_subdirectory("Infrastructure")
enable_testing()
add_subdirectory("InfrastructureTest")
add_subdirectory("MotionLogic")
add_subdirectory("MotionLogicTest")
add_subdirectory("Domain")
add_subdirectory("Common")
一些模块如Infrastucture
依赖于Common
。如果使用静态库,Boost Log只能链接到应用程序中的一个位置,我们正在这样做。然而,我不认为这是一个问题,因为代码以前工作得很好。我能够毫无问题地执行单元测试。
下面是Qt和Visual Studio用来配置和构建项目的命令,下面是我在cmd中使用的命令:
Visual Studio:
配置:
"C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Visual Studio 17 2022" -DCMAKE_C_COMPILER:STRING="cl.exe" -DCMAKE_CXX_COMPILER:STRING="cl.exe" -DCMAKE_PREFIX_PATH:STRING="" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:/Users/calvin.bunge/git/ande/out/install/x64-debug" "C:\Users\calvin.bunge\git\ande" 2>&1"
内部版本:不可用
Qt:
配置:
C:\Program Files\CMake\bin\cmake.exe -S C:/Users/calvin.bunge/git/ande -B C:/Users/calvin.bunge/git/build-ande-Desktop_Qt_6_5_0_MSVC2019_64bit-Debug in C:\Users\calvin.bunge\git\build-ande-Desktop_Qt_6_5_0_MSVC2019_64bit-Debug
构建:
"C:\Program Files\CMake\bin\cmake.exe" --build C:/Users/calvin.bunge/git/build-ande-Desktop_Qt_6_5_0_MSVC2019_64bit-Debug --target ALL_BUILD --config Debug
命令行:
配置:(从项目根目录中的构建)cmake ..
版本:cmake --build .
1条答案
按热度按时间kfgdxczn1#
我已经删除了boost日志记录,并将其替换为一个简单的写入文本文件函数。这不是最好的解决方案,但这是发展中的一个主要障碍,不能继续下去。