Cmake - 我必须 运行 cmake --build 。两次构建二进制文件
Cmake - I have to run cmake --build . twice for a binary to be build
我对柯南和 Cmake 有疑问:
我正在使用 conan 下载我的库,我想用 Cmake 编译,这是我的 CMakeLists.txt :
cmake_minimum_required(VERSION 3.16)
project(BABEL)
set(CMAKE_CXX_STANDARD 20)
set(PROJECT_NAME BABEL)
set(SOURCES qt/main.cpp)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
conan_basic_setup(KEEP_RPATHS)
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
endif (APPLE)
file(WRITE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf [Paths]\nPrefix=${CONAN_QT_ROOT})
add_executable(${PROJECT_NAME} ${SOURCES})
find_package(portaudio REQUIRED)
find_package(opus REQUIRED)
find_package(Qt5 COMPONENTS Widgets Network Core Gui REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} opus)
if (WIN32)
target_link_libraries(${PROJECT_NAME} portaudio_x64)
else()
target_link_libraries(${PROJECT_NAME} portaudio)
endif()
如果我写这个命令:
mkdir build && cd build && conan install .. && cmake .. -G "Unix Makefiles" && cmake --build.
我将不得不编写 cmake --build 。第二次构建二进制文件,知道我在这里做错了什么吗?
编辑这是构建的结果:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Using autogenerated Findportaudio.cmake
-- Library portaudio found /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Found: /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Conan: Using autogenerated FindOpus.cmake
CMake Warning (dev) at /usr/local/Cellar/cmake/3.21.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (Opus) does
not match the name of the calling package (opus). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
build/Findopus.cmake:81 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
我放不下完整的结果。
很明显,将所有命令写成一个时出现了一个错误,一个一个地键入它们解决了问题。
我对柯南和 Cmake 有疑问:
我正在使用 conan 下载我的库,我想用 Cmake 编译,这是我的 CMakeLists.txt :
cmake_minimum_required(VERSION 3.16)
project(BABEL)
set(CMAKE_CXX_STANDARD 20)
set(PROJECT_NAME BABEL)
set(SOURCES qt/main.cpp)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
conan_basic_setup(KEEP_RPATHS)
if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
endif (APPLE)
file(WRITE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf [Paths]\nPrefix=${CONAN_QT_ROOT})
add_executable(${PROJECT_NAME} ${SOURCES})
find_package(portaudio REQUIRED)
find_package(opus REQUIRED)
find_package(Qt5 COMPONENTS Widgets Network Core Gui REQUIRED)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
target_link_libraries(${PROJECT_NAME} opus)
if (WIN32)
target_link_libraries(${PROJECT_NAME} portaudio_x64)
else()
target_link_libraries(${PROJECT_NAME} portaudio)
endif()
如果我写这个命令:
mkdir build && cd build && conan install .. && cmake .. -G "Unix Makefiles" && cmake --build.
我将不得不编写 cmake --build 。第二次构建二进制文件,知道我在这里做错了什么吗?
编辑这是构建的结果:
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting language standard
-- Current conanbuildinfo.cmake directory: /Users/laurent/Documents/Delivery/Tek3/CPP/B-CPP-500-LYN-5-1-babel-kevin.melinon/build
-- Conan: Using autogenerated Findportaudio.cmake
-- Library portaudio found /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Found: /Users/laurent/.conan/data/portaudio/19.7.0/bincrafters/stable/package/22e8f592c814313580425adf77089996d9853e39/lib/libportaudio.dylib
-- Conan: Using autogenerated FindOpus.cmake
CMake Warning (dev) at /usr/local/Cellar/cmake/3.21.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (Opus) does
not match the name of the calling package (opus). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
build/Findopus.cmake:81 (find_package_handle_standard_args)
CMakeLists.txt:24 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
我放不下完整的结果。
很明显,将所有命令写成一个时出现了一个错误,一个一个地键入它们解决了问题。