【发布时间】:2021-09-11 05:33:51
【问题描述】:
我安装了一些库:
sudo apt-get install libomp-dev
sudo apt-get install libarmadillo-dev
sudo apt-get install libmlpack-dev
当我尝试在 Eclipse 中构建/执行/调试应用程序时,它似乎再次构建了所有依赖项。一个简单的程序需要很长时间。 CMakeLists.txt 中的依赖关系:
find_package(OpenMP REQUIRED)
target_compile_options(${PROJECT_NAME} INTERFACE -fopenmp)
target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_CXX mlpack PUBLIC armadillo)
程序:
#include <iostream>
#include <mlpack/core.hpp>
#include <mlpack/methods/ann/layer/layer.hpp>
#include <mlpack/methods/ann/ffn.hpp>
using namespace std;
using namespace mlpack;
using namespace mlpack::ann;
int main(int argc, char **argv) {
cout << "Hello World." << endl;
return 0;
}
由于这些依赖项没有被修改,有一种方法可以避免每次我想执行/调试我的“hello world”时都构建它们?类似的东西:只构建一次依赖项。或者:仅在不存在时构建(清理并构建)。
结果:
Building in: /home/ai/Documents/ai_projects/test1/build/default
cmake --build . --target all
Scanning dependencies of target Prueba_1
[ 50%] Building CXX object CMakeFiles/test1.dir/test1.cpp.o <-- It takes 40sec
[100%] Linking CXX executable test1
[100%] Built target test1
Build complete (0 errors, 0 warnings): /home/ai/Documents/ai_projects/test1/build/default
【问题讨论】:
标签: c++ cmake build dependencies artificial-intelligence