Running CMake (运行 CMake)

news2024/12/20 12:36:45

Running CMake {运行 CMake}

  • 1. CLion - Create a new CMake project
  • 2. Running CMake (运行 CMake)
    • 2.1. Building a project (构建项目)
    • 2.2. Picking a compiler (指定编译器)
    • 2.3. Verbose and partial builds (详细和部分的构建)
    • 2.4. Options (选项)
      • 2.4.1. Standard options (标准选项)
    • 2.5. Debugging your CMake files (调试你的 CMake 文件)
    • 2.6. Setting options (设置选项)
    • 2.7. Picking a generator (指定生成器)
  • References

1. CLion - Create a new CMake project

  • Welcome to CLion

在这里插入图片描述

  • New Project

/home/yongqiang/CLionProjects/yongqiang/

在这里插入图片描述

  • Open Project Wizard

在这里插入图片描述

  • Theme: Intellij Light

在这里插入图片描述

File -> Settings -> Appearance & Behavior -> Appearance

在这里插入图片描述

在这里插入图片描述

Classic UI

在这里插入图片描述

  • main.cpp

/home/yongqiang/CLionProjects/yongqiang/main.cpp

#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

  • CMakeLists.txt

/home/yongqiang/CLionProjects/yongqiang/CMakeLists.txt

cmake_minimum_required(VERSION 3.22)
project(yongqiang)

set(CMAKE_CXX_STANDARD 14)

add_executable(yongqiang main.cpp)

  • Build

在这里插入图片描述

  • Run

在这里插入图片描述

2. Running CMake (运行 CMake)

https://cliutils.gitlab.io/modern-cmake/chapters/intro/running.html
https://modern-cmake-cn.github.io/Modern-CMake-zh_CN/chapters/intro/running.html

2.1. Building a project (构建项目)

Unless otherwise noted, you should always make a build directory and build from there.
除非另行说明,你始终应该建立一个专用于构建的目录并在那里构建项目。

You can technically do an in-source build, but you’ll have to be careful not to overwrite files or add them to git, so just don’t.
从技术上来讲,你可以在源代码目录下执行 CMake 构建命令,但是必须注意不要覆盖文件或者把它们添加到 git,所以别这么做就好。

Here’s the Classic CMake Build Procedure (经典的 CMake 构建流程):

~/package $ mkdir build
~/package $ cd build
~/package/build $ cmake ..
~/package/build $ make
(base) yongqiang@yongqiang:~$ cd CLionProjects/
(base) yongqiang@yongqiang:~/CLionProjects$ ls
yongqiang
(base) yongqiang@yongqiang:~/CLionProjects$ cd yongqiang/
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$

(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ mkdir build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cd build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (7.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yongqiang/CLionProjects/yongqiang/build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ make
[ 50%] Building CXX object CMakeFiles/yongqiang.dir/main.cpp.o
[100%] Linking CXX executable yongqiang
[100%] Built target yongqiang
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake  yongqiang
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ ./yongqiang
Hello, World!
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$

You can replace the make line with cmake --build . if you’d like, and it will call make or whatever build tool you are using.
你可以用 cmake --build . 替换 make 这一行。它会调用 make 或者任何你正在使用的构建工具。

~/package $ mkdir build
~/package $ cd build
~/package/build $ cmake ..
~/package/build $ cmake --build .
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ mkdir build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cd build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (4.9s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yongqiang/CLionProjects/yongqiang/build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ cmake --build .
[ 50%] Building CXX object CMakeFiles/yongqiang.dir/main.cpp.o
[100%] Linking CXX executable yongqiang
[100%] Built target yongqiang
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ ./yongqiang
Hello, World!
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$

If you are using a newer version of CMake (which you usually should be, except for checking compatibility with older CMake), you can instead do this.
如果你正在使用版本比较新的 CMake (除非你正在检查对于老版本 CMake 的兼容性,否则应该使用较新的版本),你也可以这样做。

~/package $ cmake -S . -B build
~/package $ cmake --build build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cmake -S . -B build
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yongqiang/CLionProjects/yongqiang/build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  build  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cmake --build build
[ 50%] Building CXX object CMakeFiles/yongqiang.dir/main.cpp.o
[100%] Linking CXX executable yongqiang
[100%] Built target yongqiang
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  build  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cd build/
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ ls
CMakeCache.txt  CMakeFiles  Makefile  cmake_install.cmake  yongqiang
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ ./yongqiang
Hello, World!
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$

以下任何一条命令都能够执行安装:

# From the build directory (pick one)

~/package/build $ make install
~/package/build $ cmake --build . --target install
~/package/build $ cmake --install .  # CMake 3.15+ only

# From the source directory (pick one)

~/package $ make -C build install
~/package $ cmake --build build --target install
~/package $ cmake --install build  # CMake 3.15+ only

As long as you do not forget to type the build directory as the argument, staying out of the build directory is shorter, and making source changes is easier from the source directory. You should try to get used to using --build, as that will free you from using only make to build.
只要你别忘记输入构建目录作为参数,在构建目录之外的时间较短,并且从源代码目录更改源代码比较方便就行。你应该试着习惯使用 --build,因为它能让你免于只用 make 来构建。

Note that working from the build directory is historically much more common, and some tools and commands (including CTest < 3.20) still require running from the build directory.
需要注意的是,在构建目录下进行工作一直都非常普遍,并且一些工具和命令 (including CTest < 3.20) 仍然需要在 build 目录中才能工作。

You can point CMake at either the source directory from the build directory, or at an existing build directory from anywhere.
你可以指定 CMake 工作在来自构建目录的源代码目录,也可以工作在任何现有的构建目录。

If you use cmake --build instead of directly calling the underlying build system, you can use -v for verbose builds (CMake 3.14+), -j N for parallel builds on N cores (CMake 3.12+), and --target (any version of CMake) or -t (CMake 3.15+) to pick a target.
如果你使用 cmake --build 而不是直接调用更底层的构建系统 (make),你可以用 -v 参数在构建时获得详细的输出 (CMake 3.14+),用 -j N 指定用 N 个 CPU 核心并行构建项目 (CMake 3.12+),以及用 --target (any version of CMake) or -t (CMake 3.15+) 来选择一个目标进行部分地构建。

Otherwise, these commands vary between build systems, such as VERBOSE=1 make and ninja -v. You can instead use the environment variables for these, as well, such as CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) and VERBOSE (CMake 3.14+).
这些命令因不同的构建系统而异,例如 VERBOSE=1 make and ninja -v。你也可以使用环境变量替代它们,例如 CMAKE_BUILD_PARALLEL_LEVEL (CMake 3.12+) and VERBOSE (CMake 3.14+)。

2.2. Picking a compiler (指定编译器)

Selecting a compiler must be done on the first run in an empty directory. It’s not CMake syntax per se, but you might not be familiar with it.
指定编译器必须在第一次运行时在空目录中进行。这种命令并不属于 CMake 语法。

To pick Clang:

~/package/build $ CC=clang CXX=clang++ cmake ..

That sets the environment variables in bash for CC and CXX, and CMake will respect those variables. This sets it just for that one line, but that’s the only time you’ll need those; afterwards CMake continues to use the paths it deduces from those values.
这条命令设置了 bash 里的环境变量 CCCXX,并且 CMake 会使用这些参数。这一行命令就够了,你也只需要调用一次;之后 CMake 会继续使用从这些变量里推导出来的路径。

2.3. Verbose and partial builds (详细和部分的构建)

Although not all build tools support it, you can get verbose builds (pick one):

~/package $ cmake --build build --verbose  # CMake 3.14+ only
~/package/build $ VERBOSE=1 make

You can actually write make VERBOSE=1, and make will also do the right thing, though that’s a feature of make and not the command line in general.
实际上你写成 make VERBOSE=1make 也能正确工作,但这是 make 的一个特性而不是命令行的惯用写法。

You can also build just a part of a build by specifying a target, such as the name of a library or executable you’ve defined in CMake, and make will just build that target.
你也可以通过指定一个目标来仅构建一部分,例如指定你已经在 CMake 中定义的库或可执行文件的名称,然后 make 将会只构建这一个目标。

~/package $ mkdir build
~/package $ cd build
~/package/build $ cmake ..
~/package/build $ VERBOSE=1 make
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ ls
CMakeLists.txt  cmake-build-debug  main.cpp
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ mkdir build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang$ cd build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ cmake ..
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (4.2s)
-- Generating done (0.0s)
-- Build files have been written to: /home/yongqiang/CLionProjects/yongqiang/build
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ VERBOSE=1 make
/home/yongqiang/miniconda3/bin/cmake -S/home/yongqiang/CLionProjects/yongqiang -B/home/yongqiang/CLionProjects/yongqiang/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/yongqiang/miniconda3/bin/cmake -E cmake_progress_start /home/yongqiang/CLionProjects/yongqiang/build/CMakeFiles /home/yongqiang/CLionProjects/yongqiang/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/yongqiang/CLionProjects/yongqiang/build'
make  -f CMakeFiles/yongqiang.dir/build.make CMakeFiles/yongqiang.dir/depend
make[2]: Entering directory '/home/yongqiang/CLionProjects/yongqiang/build'
cd /home/yongqiang/CLionProjects/yongqiang/build && /home/yongqiang/miniconda3/bin/cmake -E cmake_depends "Unix Makefiles" /home/yongqiang/CLionProjects/yongqiang /home/yongqiang/CLionProjects/yongqiang /home/yongqiang/CLionProjects/yongqiang/build /home/yongqiang/CLionProjects/yongqiang/build /home/yongqiang/CLionProjects/yongqiang/build/CMakeFiles/yongqiang.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/home/yongqiang/CLionProjects/yongqiang/build'
make  -f CMakeFiles/yongqiang.dir/build.make CMakeFiles/yongqiang.dir/build
make[2]: Entering directory '/home/yongqiang/CLionProjects/yongqiang/build'
[ 50%] Building CXX object CMakeFiles/yongqiang.dir/main.cpp.o
/usr/bin/c++    -MD -MT CMakeFiles/yongqiang.dir/main.cpp.o -MF CMakeFiles/yongqiang.dir/main.cpp.o.d -o CMakeFiles/yongqiang.dir/main.cpp.o -c /home/yongqiang/CLionProjects/yongqiang/main.cpp
[100%] Linking CXX executable yongqiang
/home/yongqiang/miniconda3/bin/cmake -E cmake_link_script CMakeFiles/yongqiang.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/yongqiang.dir/main.cpp.o -o yongqiang
make[2]: Leaving directory '/home/yongqiang/CLionProjects/yongqiang/build'
[100%] Built target yongqiang
make[1]: Leaving directory '/home/yongqiang/CLionProjects/yongqiang/build'
/home/yongqiang/miniconda3/bin/cmake -E cmake_progress_start /home/yongqiang/CLionProjects/yongqiang/build/CMakeFiles 0
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$

2.4. Options (选项)

CMake has support for cached options. A Variable in CMake can be marked as “cached”, which means it will be written to the cache (a file called CMakeCache.txt in the build directory) when it is encountered. You can preset (or change) the value of a cached option on the command line with -D. When CMake looks for a cached variable, it will use the existing value and will not overwrite it.
CMake 支持缓存选项。CMake 中的变量可以被标记为 “cached”,这意味着它会被写入缓存(构建目录中名为 CMakeCache.txt 的文件)。你可以在命令行中用 -D 预先设定或更改缓存选项的值。CMake 查找一个缓存的变量时,它就会使用已有的值并且不会覆盖这个值。

2.4.1. Standard options (标准选项)

These are common CMake options to most packages:

  • -DCMAKE_BUILD_TYPE= Pick from Release, RelWithDebInfo, Debug, or sometimes more.
    Release, RelWithDebInfo, Debug 或者可能存在的更多参数中选择。
  • -DCMAKE_INSTALL_PREFIX= The location to install to. System install on UNIX would often be /usr/local (the default), user directories are often ~/.local, or you can pick a folder.
    这是安装位置。UNIX 系统默认的位置是 /usr/local,用户目录是 ~/.local,也可以是你自己指定的文件夹。
  • -DBUILD_SHARED_LIBS= You can set this ON or OFF to control the default for shared libraries (the author can pick one vs. the other explicitly instead of using the default, though)
    你可以把这里设置为 ON 或 OFF 来控制共享库的默认值 (不过,你也可以明确选择其他值而不是默认值)
  • -DBUILD_TESTING= This is a common name for enabling tests, not all packages use it, though, sometimes with good reason.
    这是启用测试的通用名称,当然不会所有软件包都会使用它,有时这样做确实不错。

2.5. Debugging your CMake files (调试你的 CMake 文件)

We’ve already mentioned verbose output for the build, but you can also see verbose CMake configure output too. The --trace option will print every line of CMake that is run. Since this is very verbose, CMake 3.7 added --trace-source="filename", which will print out every executed line of just the file you are interested in when it runs. If you select the name of the file you are interested in debugging (usually by selecting the parent directory when debugging a CMakeLists.txt, since all of those have the same name), you can just see the lines that run in that file.
我们已经提到了在构建时可以有详细输出,但你也可以看到详细的 CMake 配置输出。--trace 选项能够打印出运行的 CMake 的每一行。由于它过于冗长,CMake 3.7 添加了 --trace-source="filename" 选项,这让你可以打印出你想看的特定文件运行时执行的每一行。如果你选择了要调试的文件的名称 (在调试 CMakeLists.txt 时通常选择父目录,因为它的名字在任何项目中都一样),你就会只看到这个文件里运行的那些行。

2.6. Setting options (设置选项)

You set options in CMake with -D. You can see a list of options with -L, or a list with human-readable help with -LH. If you don’t list the source/build directory, the listing will not rerun CMake (cmake -L instead of cmake -L .).
在 CMake 中,你可以使用 -D 设置选项。你能使用 -L 列出所有选项,或者用 -LH 列出人类更易读的选项列表。如果你没有列出源代码目录或构建目录,这条命令将不会重新运行 CMake (使用 cmake -L 而不是 cmake -L .)。

2.7. Picking a generator (指定生成器)

You can build with a variety of tools; make is usually the default.
你可以选择的构建工具有很多,通常默认的是 make。要显示在你的系统上 CMake 可以调用的所有构建工具,运行

~/package/build $ cmake --help
(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$ cmake --help
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>
  cmake [options] -S <path-to-source> -B <path-to-build>

Specify a source directory to (re-)generate a build system for it in the
current working directory.  Specify an existing build directory to
re-generate its build system.

Options
  -S <path-to-source>          = Explicitly specify a source directory.
  -B <path-to-build>           = Explicitly specify a build directory.
  -C <initial-cache>           = Pre-load a script to populate the cache.
  -D <var>[:<type>]=<value>    = Create or update a cmake cache entry.
  -U <globbing_expr>           = Remove matching entries from CMake cache.
  -G <generator-name>          = Specify a build system generator.
  -T <toolset-name>            = Specify toolset name if supported by
                                 generator.
  -A <platform-name>           = Specify platform name if supported by
                                 generator.
  --toolchain <file>           = Specify toolchain file
                                 [CMAKE_TOOLCHAIN_FILE].
  --install-prefix <directory> = Specify install directory
                                 [CMAKE_INSTALL_PREFIX].
  -Wdev                        = Enable developer warnings.
  -Wno-dev                     = Suppress developer warnings.
  -Werror=dev                  = Make developer warnings errors.
  -Wno-error=dev               = Make developer warnings not errors.
  -Wdeprecated                 = Enable deprecation warnings.
  -Wno-deprecated              = Suppress deprecation warnings.
  -Werror=deprecated           = Make deprecated macro and function warnings
                                 errors.
  -Wno-error=deprecated        = Make deprecated macro and function warnings
                                 not errors.
  --preset <preset>,--preset=<preset>
                               = Specify a configure preset.
  --list-presets[=<type>]      = List available presets.
  -E                           = CMake command mode.
  -L[A][H]                     = List non-advanced cached variables.
  --fresh                      = Configure a fresh build tree, removing any
                                 existing cache file.
  --build <dir>                = Build a CMake-generated project binary tree.
  --install <dir>              = Install a CMake-generated project binary
                                 tree.
  --open <dir>                 = Open generated project in the associated
                                 application.
  -N                           = View mode only.
  -P <file>                    = Process script mode.
  --find-package               = Legacy pkg-config like mode.  Do not use.
  --graphviz=<file>            = Generate graphviz of dependencies, see
                                 CMakeGraphVizOptions.cmake for more.
  --system-information [file]  = Dump information about this system.
  --log-level=<ERROR|WARNING|NOTICE|STATUS|VERBOSE|DEBUG|TRACE>
                               = Set the verbosity of messages from CMake
                                 files.  --loglevel is also accepted for
                                 backward compatibility reasons.
  --log-context                = Prepend log messages with context, if given
  --debug-trycompile           = Do not delete the try_compile build tree.
                                 Only useful on one try_compile at a time.
  --debug-output               = Put cmake in a debug mode.
  --debug-find                 = Put cmake find in a debug mode.
  --debug-find-pkg=<pkg-name>[,...]
                               = Limit cmake debug-find to the
                                 comma-separated list of packages
  --debug-find-var=<var-name>[,...]
                               = Limit cmake debug-find to the
                                 comma-separated list of result variables
  --trace                      = Put cmake in trace mode.
  --trace-expand               = Put cmake in trace mode with variable
                                 expansion.
  --trace-format=<human|json-v1>
                               = Set the output format of the trace.
  --trace-source=<file>        = Trace only this CMake file/module.  Multiple
                                 options allowed.
  --trace-redirect=<file>      = Redirect trace output to a file instead of
                                 stderr.
  --warn-uninitialized         = Warn about uninitialized values.
  --no-warn-unused-cli         = Don't warn about command line options.
  --check-system-vars          = Find problems with variable usage in system
                                 files.
  --compile-no-warning-as-error= Ignore COMPILE_WARNING_AS_ERROR property and
                                 CMAKE_COMPILE_WARNING_AS_ERROR variable.
  --profiling-format=<fmt>     = Output data for profiling CMake scripts.
                                 Supported formats: google-trace
  --profiling-output=<file>    = Select an output path for the profiling data
                                 enabled through --profiling-format.
  -h,-H,--help,-help,-usage,/? = Print usage information and exit.
  --version,-version,/V [<file>]
                               = Print version number and exit.
  --help-full [<file>]         = Print all help manuals and exit.
  --help-manual <man> [<file>] = Print one help manual and exit.
  --help-manual-list [<file>]  = List help manuals available and exit.
  --help-command <cmd> [<file>]= Print help for one command and exit.
  --help-command-list [<file>] = List commands with help available and exit.
  --help-commands [<file>]     = Print cmake-commands manual and exit.
  --help-module <mod> [<file>] = Print help for one module and exit.
  --help-module-list [<file>]  = List modules with help available and exit.
  --help-modules [<file>]      = Print cmake-modules manual and exit.
  --help-policy <cmp> [<file>] = Print help for one policy and exit.
  --help-policy-list [<file>]  = List policies with help available and exit.
  --help-policies [<file>]     = Print cmake-policies manual and exit.
  --help-property <prop> [<file>]
                               = Print help for one property and exit.
  --help-property-list [<file>]= List properties with help available and
                                 exit.
  --help-properties [<file>]   = Print cmake-properties manual and exit.
  --help-variable var [<file>] = Print help for one variable and exit.
  --help-variable-list [<file>]= List variables with help available and exit.
  --help-variables [<file>]    = Print cmake-variables manual and exit.

Generators

The following generators are available on this platform (* marks default):
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
* Unix Makefiles               = Generates standard UNIX makefiles.
  Ninja                        = Generates build.ninja files.
  Ninja Multi-Config           = Generates build-<Config>.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.

(base) yongqiang@yongqiang:~/CLionProjects/yongqiang/build$

And you can pick a tool with -G"My Tool" (quotes only needed if spaces are in the tool name). You should pick a tool on your first CMake call in a directory, just like the compiler. Feel free to have several build directories, like build/ and buildXcode.
你也可以用 -G"My Tool" (仅当构建工具的名字中包含空格时才需要引号) 来指定构建工具。像指定编译器一样,你应该在一个目录中第一次调用 CMake 时就指定构建工具。如果有好几个构建目录也没关系,比如 build/ and buildXcode

You can set the environment variable CMAKE_GENERATOR to control the default generator (CMake 3.15+).
你可以用环境变量 CMAKE_GENERATOR 来指定默认的生成器 (CMake 3.15+)。

Note that makefiles will only run in parallel if you explicitly pass a number of threads, such as make -j2, while Ninja will automatically run in parallel. You can directly pass a parallelization option such as -j2 to the cmake --build . command in recent versions of CMake.
makefiles 只会在你明确地指出线程数目之时才会并行运行,比如 make -j2,而 Ninja 却会自动地并行运行。在较新版本的 CMake 中,你能直接传递并行选项,比如 -j2,到命令 cmake --build .

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/
[2] Quick start guide, https://www.jetbrains.com/help/clion/clion-quick-start-guide.html
[3] 轻松上手, https://www.jetbrains.com/zh-cn/clion/features/start-your-project.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2262712.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

穷举vs暴搜vs深搜vs回溯vs剪枝专题一>子集

题目&#xff1a; 两个方法本质就是决策树的画法不同 方法一解析&#xff1a; 代码&#xff1a; class Solution {private List<List<Integer>> ret;//返回结果private List<Integer> path;//记录路径&#xff0c;注意返回现场public List<List<Int…

MTU 使用使用解释

MTU (Maximum Transmission Unit&#xff0c;最大传输单元) 指的是网络链路层 (例如以太网) 能够传输的最大数据帧大小&#xff0c;以字节为单位。理解 MTU 对网络性能和可靠性至关重要&#xff0c;因为它直接影响数据包的分片 (Fragmentation) 和重组。本文档将详细解释 MTU 的…

uniapp v-tabs修改了几项功能,根据自己需求自己改

根据自己的需求都可以改 这里写自定义目录标题 1.数组中的名字过长&#xff0c;导致滑动异常2.change 事件拿不到当前点击的数据&#xff0c;通过index在原数组中查找得到所需要的id 各种字段麻烦3.添加指定下标下新加红点显示样式 1.数组中的名字过长&#xff0c;导致滑动异常…

iOS - 超好用的隐私清单修复脚本(持续更新)

文章目录 前言开发环境项目地址下载安装隐私访问报告隐私清单模板最后 前言 在早些时候&#xff0c;提交应用到App Store审核&#xff0c;大家应该都收到过类似这样的邮件&#xff1a; Although submission for App Store review was successful, you may want to correct th…

c语言-----数组

基本概念 数组是C语言中一种用于存储多个相同类型数据的数据结构。这些数据在内存中是连续存储的&#xff0c;可以通过索引&#xff08;下标&#xff09;来访问数组中的各个元素。数组的索引从0开始&#xff0c;这是C语言的规定。例如&#xff0c;一个有n个元素的数组&#xff…

社区版 IDEA 开发webapp 配置tomcat

1.安装tomcat 参考Tomcat配置_tomcat怎么配置成功-CSDN博客 2.构建webapp项目结构 新建一个普通项目 然后添加webapp的目录结构&#xff1a; main目录下新建 webapp 文件夹 webapp文件夹下新建WEB_INF文件夹 *WEB_INF目录下新建web.xml wenapp文件夹下再新建index.html …

全面解析 Kubernetes 流量负载均衡:iptables 与 IPVS 模式

目录 Kubernetes 中 Service 的流量负载均衡模式 1. iptables 模式 工作原理 数据路径 优点 缺点 适用场景 2. IPVS 模式 工作原理 数据路径 优点 缺点 适用场景 两种模式的对比 如何切换模式 启用 IPVS 模式 验证模式 总结 Kubernetes 中 Service 的流量负载…

C 语言数据类型详解

目录 一、引言 二、基本数据类型 &#xff08;一&#xff09;整型 &#xff08;二&#xff09;浮点型 &#xff08;三&#xff09;字符型 三、构造数据类型 &#xff08;一&#xff09;数组 &#xff08;二&#xff09;结构体 &#xff08;三&#xff09;联合体&#…

Python图注意力神经网络GAT与蛋白质相互作用数据模型构建、可视化及熵直方图分析...

全文链接&#xff1a;https://tecdat.cn/?p38617 本文聚焦于图注意力网络GAT在蛋白质 - 蛋白质相互作用数据集中的应用。首先介绍了研究背景与目的&#xff0c;阐述了相关概念如归纳设置与转导设置的差异。接着详细描述了数据加载与可视化的过程&#xff0c;包括代码实现与分析…

LeetCode 1925 统计平方和三元组的数目

探索平方和三元组&#xff1a;从问题到 Java 代码实现 在数学与编程的交叉领域&#xff0c;常常会遇到一些有趣且富有挑战性的问题。今天&#xff0c;就让我们深入探讨一下 “平方和三元组” 这个有趣的话题&#xff0c;并使用 Java 语言来实现计算满足特定条件的平方和三元组…

回归预测 | MATLAB实现CNN-BiGRU-Attention卷积神经网络结合双向门控循环单元融合注意力机制多输入单输出回归预测

回归预测 | MATLAB实现CNN-BiGRU-Attention卷积神经网络结合双向门控循环单元融合注意力机制多输入单输出回归预测 目录 回归预测 | MATLAB实现CNN-BiGRU-Attention卷积神经网络结合双向门控循环单元融合注意力机制多输入单输出回归预测预测效果基本介绍程序设计参考资料 预测效…

vue横向滚动日期选择器组件

vue横向滚动日期选择器组件 组件使用到了element-plus组件库和dayjs库&#xff0c;使用前先保证项目中已经下载导入 主要功能&#xff1a;选择日期&#xff0c;点击日期可以让此日期滚动到视图中间&#xff0c;左滑右滑同理&#xff0c;支持跳转至任意日期&#xff0c;支持自…

Firecrawl教程①:自动化抓取与数据转化,赋能AI应用

Firecrawl教程①:自动化抓取与数据转化,赋能AI应用 前言一、功能特点1. 支持 LLM 可处理的数据格式2. 全面抓取网站3. 强大的操作支持4. 灵活的定制选项5. 支持多种编程语言 SDK二、如何开始使用 Firecrawl第一步:获取 API 密钥第二步:官网在线工具使用第三步:安装 Firecr…

WatchAlert - 开源多数据源告警引擎

概述 在现代 IT 环境中&#xff0c;监控和告警是确保系统稳定性和可靠性的关键环节。然而&#xff0c;随着业务规模的扩大和数据源的多样化&#xff0c;传统的单一数据源告警系统已经无法满足复杂的需求。为了解决这一问题&#xff0c;我开发了一个开源的多数据源告警引擎——…

svn版本丢失导致无法访问临时解决方法

#svn异常问题# 在使用svn的过程中&#xff0c;有时候在数据量比较大的情况下&#xff0c;有涉及到数据迁移或者是文件移动操作时容易出现迁移过程中有人还提交了数据&#xff0c;导致迁移的数据出现版本丢失的情况。 比如说&#xff0c;我实际遇到的情况是迁移数据的时候记录…

0009.基于springboot+layui的ERP企业进销存管理系统

一、系统说明 基于springbootlayui的ERP企业进销存管理系统,系统功能齐全, 代码简洁易懂&#xff0c;适合小白学编程,课程设计&#xff0c;毕业设计。 二、系统架构 前端&#xff1a;html| layui 后端&#xff1a;springboot | mybatis| thymeleaf 环境&#xff1a;jdk1.8 |…

Latex+VsCode+Win10搭建

最近在写论文&#xff0c;overleaf的免费使用次数受限&#xff0c;因此需要使用本地的形式进行编译。 安装TEXLive 下载地址&#xff1a;https://mirror-hk.koddos.net/CTAN/systems/texlive/Images/ 下载完成直接点击iso进行安装操作。 安装LATEX Workshop插件 设置VsCode文…

[创业之路-199]:《华为战略管理法-DSTE实战体系》- 3 - 价值转移理论与利润区理论

目录 一、价值转移理论 1.1. 什么是价值&#xff1f; 1.2. 什么价值创造 &#xff08;1&#xff09;、定义 &#xff08;2&#xff09;、影响价值创造的因素 &#xff08;3&#xff09;、价值创造的三个过程 &#xff08;4&#xff09;、价值创造的实践 &#xff08;5&…

如何在单选按钮中添加图标和文字

文章目录 1. 概念介绍2. 使用方法3. 示例代码我们在上一章回中介绍了Radio Widget相关的内容,本章回中将介绍RadioListTile Widget.闲话休提,让我们一起Talk Flutter吧。 1. 概念介绍 我们在这里介绍的RadioListTile和上一章回中介绍的Radio类似,不同之处在于RadioListTile组…

启动异常:Caused by: java.lang.IllegalStateException: Failed to introspect Class

背景 今天项目需要&#xff0c;导入一个本地的jar包&#xff0c;在pom文件&#xff0c;添加自定义依赖后&#xff0c;并通过mvn命令&#xff1a; mvn install:install-file -Dfilejar包的位置 -DgroupId自定义的groupId -DartifactId自定义的artifactId -Dversion自定义的ver…