我正在尝试在 https://github.com/rgaufman/live555 上集成 CMake 构建
它使用传统的 ./genMakefiles && make -j4
因此我只需要创建一个 CMakeLists.txt
来执行此操作,对吗?
我知道正确的方法是添加所有 cpp 文件并构建所有内容,但这不是我的项目,我不会维护它,所以对于这种情况,最好的方法是像我一样集成'建议
这是我的原型(prototype):
cmake_minimum_required(VERSION 3.9)
project(live555)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/live555
COMMAND ./genMakefiles linux
COMMENT "=================== Generating makefiles for linux"
COMMAND make -j4
COMMENT "=================== make..."
)
我不明白 OUTPUT
是干什么用的。 OUTPUT
不是由make -j4
决定的吗?另外,我做了 cmake 。 && make
,查看输出:
lz@vm:~/JSCam/src/jscam/live555$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lz/JSCam/src/jscam/live555
lz@vm:~/JSCam/src/jscam/live555$ make
我既看不到我添加的评论,也没有构建文件。
最佳答案
在 CMake 中,如果您需要构建一些您“不打算维护”的其他项目,ExternalProject_Add通常是一个不错的选择:
The
ExternalProject_Add
function creates a custom target to drive download, update/patch, configure, build, install and test steps of an external project
它的用法很简单:
include(ExternalProject) # Include definition of 'ExternalProject_Add' function
ExternalProject_Add(live555 # Name of the target. Could be any
# Setup source directory
SOURCE_DIR <path-to-directory-with-external-project>
# Setup build directory. Here it is the same as source one.
BUILD_IN_SOURCE 1
# Configuration step
CONFIGURE_COMMAND ./genMakefiles linux
# Build step. It is actually `make`, but in a wise manner.
BUILD_COMMAND ${CMAKE_MAKE_COMMAND}
# Disable install step
INSTALL_COMMAND ""
)
关于c++ - 使用 Cmake 来做 ./genMakefiles && make -j4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50195584/