Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake, C++ and Jenkins/Continuous integration

Tags:

c++

jenkins

cmake

I have a CMake sample project that I would like to build on Jenkins running on Ubuntu 15.10. I have installed:

https://wiki.jenkins-ci.org/display/JENKINS/CMake+Plugin

And created two build steps:

  1. Run CMake to generate makefiles
  2. Run make all from the build dir

enter image description here

It works fine:

[build] $ cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug /var/lib/jenkins/workspace/cmake-test/cmake-gtest/src
-- Configuring done
-- Generating done
-- Build files have been written to: /var/lib/jenkins/workspace/cmake-test/cmake-gtest/build
[build] $ /usr/bin/make
[  4%] Built target libfoo
[  9%] Built target libbar
[ 14%] Built target myApp
[ 52%] Built target gmock
[ 90%] Built target gtest
[100%] Built target testfoo
[cmake-test] $ /bin/sh -xe /tmp/hudson1792271459427590561.sh
+ cd cmake-gtest/build
+ make all
[  4%] Built target libfoo
[  9%] Built target libbar
[ 14%] Built target myApp
[ 52%] Built target gmock
[ 90%] Built target gtest
[100%] Built target testfoo
Finished: SUCCESS

But is this the recommended approach for using CMake in a CI/Jenkins setup?

Currently, my CMake/Jenkins build will on each push; 1) generate the makefiles, 2) build the project.

I am a bit worried that the first step 1) generate makefiles would eat up build time and it does not really seem optimal to do this step on each push. Especially since I would not expect to change CMakeLists.txt files that often, but when they change newly generated files should, of course, be used.

Is the above approach common practices that I just have to get used to or have I missed something?

like image 644
u123 Avatar asked Feb 27 '16 16:02

u123


Video Answer


1 Answers

I am not even sure you need this plugin. AFAIR the plugin webpage it is only useful if you want Jenkins to use a specific CMake version, or you want a GUI for which CMake variables you might want to set. I just execute CMake from the command line.

For your second part of the question, If you change CMakeLists.txt, the Makefile will automatically rerun CMake, so strictly speaking it is not necessary to run CMake each time. But on the other side, CMake configuring is quite fast and most likely takes less time than compiling.

like image 106
arved Avatar answered Sep 25 '22 11:09

arved