首页 > 解决方案 > Can someone expand what is meant by 'configure' and 'build' with CMake files

问题描述

I am downloading this code from GitHub (subdivision-regression), and am getting stuck following the instructions:

To build doosabin_regression:

    Run CMake with an out of source build.
    Set COMMON_CPP_INCLUDE_DIR to the full path to rstebbing/common/cpp.
    Set DOOSABIN_INCLUDE_DIR to the full path to rstebbing/subdivision/cpp/doosabin/include.
    Set Ceres_DIR to the directory containing CeresConfig.cmake.
    Set GFLAGS_INCLUDE_DIR, GFLAGS_LIBRARY and RAPID_JSON_INCLUDE_DIR. (Add -std=c++11 to CMAKE_CXX_FLAGS if compiling with gcc.)
    Configure.
    Build.

I have edited the CMakeLists.txt file to put the correct paths in. I then created a new directory called subdivision-regression-bin and ran:

cmake ../subdivision-regression/src

It completes this and displays:

-- Configuring done
-- Generating done
-- Build files have been written to: /home/hert5584/RStebbing/subdivision-regression-bin

However, when I try and run the example code, it cannot find the files listed in CMakeLists.txt (I know they are the right paths as otherwise CMake does not run).

I have tried running:

sudo make install 

But get the following error:

make: *** No rule to make target 'install'. Stop.

Any ideas why this isn't working? Have the above steps Configured and Built the files?

标签: buildcmakeconfigure

解决方案


要理解的有序 CMake 习惯用法是:

  1. 配置步骤_
  2. 生成步骤(这通常包含在配置步骤中,并且在本例中未明确提及。)
  3. 构建步骤(您在其中实际将代码编译/链接到库/可执行文件中)

查看此资源以获取有关配置生成阶段的信息。

您似乎没有执行设置 CMake 缓存变量的步骤。对于这些,您必须使用 CMake 命令行选项-D特别是)。所以像这样运行 CMake 来设置所有六个变量:

cmake -DCOMMON_CPP_INCLUDE_DIR=/rstebbing/common/cp -DDOOSABIN_INCLUDE_DIR=...[More CMake Cache variables]...  ../subdivision-regression/src

对于构建,请尝试在make没有sudo或的情况下运行install

make

推荐阅读