Often to build library when you get the source code, you're asked to build it with a cmake command. Sometimes it happens that framework ask you to build your code with cmake too (for example Qt).
通常在获取源代码时构建库,您需要使用cmake命令构建它。有时会发生框架要求您使用cmake构建代码(例如Qt)。
I'm currently using Qt for a personal project and I am totally able to compile with it a good batch file. So, is it always possible to avoid using cmake ? Or should I definitively learn to get over it at some point ?
我目前正在使用Qt进行个人项目,我完全能够用它编译一个好的批处理文件。那么,总是可以避免使用cmake吗?或者我应该在某个时候明确地学会克服它?
2 个解决方案
#1
5
The goal of make/cmake is precisely to avoid using batch scripts to compile your program.
make / cmake的目标正是为了避免使用批处理脚本来编译程序。
- Make let you execute shell commands, but comes with built-in dependency resolution, and check whether each target needs to be rebuilt. It also handle multi threaded compilation (assuming you wrote your
Makefile
correctly) - CMake does everything make does, but also comes with tons of goodies like portability, very good support of C/C++, and
find_package
, which is definitely a must-have feature.
让您执行shell命令,但附带内置依赖项解析,并检查是否需要重建每个目标。它还处理多线程编译(假设您正确编写了Makefile)
CMake做的一切都做了,但也带来了很多好东西,比如可移植性,非常好的C / C ++支持,以及find_package,这绝对是必备功能。
In the long run, you will save a lot of time and avoid a lot of troubles by using a good build system.
从长远来看,通过使用良好的构建系统,您将节省大量时间并避免许多麻烦。
#2
1
CMake, make and all those other build tools just execute a sequence of commands. If you can replicate the commands without actually calling CMake, then you will get the same end result.
CMake,make和所有其他构建工具只执行一系列命令。如果您可以在不实际调用CMake的情况下复制命令,那么您将获得相同的最终结果。
BUT... those tools are used by developers for a reason. Typically the sequence of commands varies from system to system in non-trivial ways. The build system will prevent rebuild of unchanged components, and ensure changed ones are rebuilt.
但是......开发人员使用这些工具是有原因的。通常,命令序列以不平凡的方式因系统而异。构建系统将阻止重建未更改的组件,并确保重建更改的组件。
So you can do it your way, but you should still get over your avoidance of build-systems and embrace them for the time savers they are.
因此,您可以按照自己的方式进行操作,但是您仍然应该避免使用构建系统,并在节省时间的情况下接受它们。
#1
5
The goal of make/cmake is precisely to avoid using batch scripts to compile your program.
make / cmake的目标正是为了避免使用批处理脚本来编译程序。
- Make let you execute shell commands, but comes with built-in dependency resolution, and check whether each target needs to be rebuilt. It also handle multi threaded compilation (assuming you wrote your
Makefile
correctly) - CMake does everything make does, but also comes with tons of goodies like portability, very good support of C/C++, and
find_package
, which is definitely a must-have feature.
让您执行shell命令,但附带内置依赖项解析,并检查是否需要重建每个目标。它还处理多线程编译(假设您正确编写了Makefile)
CMake做的一切都做了,但也带来了很多好东西,比如可移植性,非常好的C / C ++支持,以及find_package,这绝对是必备功能。
In the long run, you will save a lot of time and avoid a lot of troubles by using a good build system.
从长远来看,通过使用良好的构建系统,您将节省大量时间并避免许多麻烦。
#2
1
CMake, make and all those other build tools just execute a sequence of commands. If you can replicate the commands without actually calling CMake, then you will get the same end result.
CMake,make和所有其他构建工具只执行一系列命令。如果您可以在不实际调用CMake的情况下复制命令,那么您将获得相同的最终结果。
BUT... those tools are used by developers for a reason. Typically the sequence of commands varies from system to system in non-trivial ways. The build system will prevent rebuild of unchanged components, and ensure changed ones are rebuilt.
但是......开发人员使用这些工具是有原因的。通常,命令序列以不平凡的方式因系统而异。构建系统将阻止重建未更改的组件,并确保重建更改的组件。
So you can do it your way, but you should still get over your avoidance of build-systems and embrace them for the time savers they are.
因此,您可以按照自己的方式进行操作,但是您仍然应该避免使用构建系统,并在节省时间的情况下接受它们。