From 4897f2ae6f91064491bf694d77a038b5ad534a37 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Thu, 5 Apr 2018 08:07:40 +0200 Subject: [PATCH] Adding test build to CI --- .gitlab-ci.yml | 49 ++++++++++++++---------- chapters/intro/installing.md | 6 ++- chapters/intro/newcmake.md | 2 +- chapters/intro/running.md | 11 ++++++ examples/root-simple-3.11/CMakeLists.txt | 2 +- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4d157e9..320f263 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,28 +1,35 @@ -# requiring the environment of NodeJS 8 LTS series (carbon) -image: node:carbon -# add 'node_modules' to cache for speeding up builds -cache: - paths: - - node_modules/ # Node modules and dependencies - -before_script: - - npm install gitbook-cli -g # install gitbook - - gitbook fetch latest # fetch latest stable version - - gitbook install # add any requested plugins in book.json - #- gitbook fetch pre # fetch latest pre-release version - #- gitbook fetch 2.6.7 # fetch specific version - - -# the 'pages' job will deploy and build your site to the 'public' path -pages: - stage: deploy +test_code: + image: rootproject/root-ubuntu16:6.12 + stage: test + before_script: + - mkdir -p $HOME/.local + - curl -s "https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local + - export PATH=$HOME/.local/bin:$PATH script: - - gitbook build . public # build to public path + - mkdir -p build + - cd build + - cmake ../examples + - cmake --build . + - ctest + - cd .. + +pages: + image: node:carbon + stage: deploy + only: + - master + cache: + paths: + - node_modules/ + before_script: + - npm install gitbook-cli -g # + - gitbook fetch latest + - gitbook install + script: + - gitbook build . public artifacts: paths: - public expire_in: 1 week - only: - - master # this job will affect only the 'master' branch diff --git a/chapters/intro/installing.md b/chapters/intro/installing.md index c976cc4..8efb3d2 100644 --- a/chapters/intro/installing.md +++ b/chapters/intro/installing.md @@ -19,13 +19,15 @@ On Linux, there are binaries provided, but you'll need to pick an install locati If you just want a local folder with CMake only: {% term %} -~ $ mkdir -p cmake-3.11 && wget -qO- "https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake39 +~ $ mkdir -p cmake-3.11 && wget -qO- "https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.11 ~ $ export PATH=`pwd`/cmake-3.11/bin:$PATH {% endterm %} You'll obviously want to append to the PATH every time you start a new terminal, or add it to your `.bashrc` or to an [LMod] system. -And, if you want a system install, install to `/usr/local`. (I'm only brave enough to do this in Docker). +And, if you want a system install, install to `/usr/local`; this is an excellent choice in a Docker container, for example on GitLab CI. I don't think I'd try it on a non-containerized system. + +If you are on a system without wget, replace `wget -qO-` with `curl -s`. You can also build CMake on any system, it's pretty easy, but binaries are faster. diff --git a/chapters/intro/newcmake.md b/chapters/intro/newcmake.md index e6abc44..922484a 100644 --- a/chapters/intro/newcmake.md +++ b/chapters/intro/newcmake.md @@ -105,7 +105,7 @@ Even more modules provide imported targets, including MPI. * CUDA supported for Windows * Better object library support in several situations * `DESCRIPTION` added to `project` -* `seperate_arguments` gets `NATIVE_COMMAND` +* `separate_arguments` gets `NATIVE_COMMAND` * `INTERPROCEDURAL_OPTIMIZATION` enforced (and `CMAKE_*` initializer added, CheckIPOSupported added, Clang and GCC support) * New `GoogleTest` module * `FindDoxygen` drastically improved diff --git a/chapters/intro/running.md b/chapters/intro/running.md index 86320a7..8f4df11 100644 --- a/chapters/intro/running.md +++ b/chapters/intro/running.md @@ -59,3 +59,14 @@ These are common CMake options to most packages: * `-DCMAKE_BUILD_TYPE=` Pick from Release, RelWithDebInfo, Debug, or sometimes more. * `-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. * `-D BUILD_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) + +## Special commands for CMake + +We've already mentioned several special commands, like `-G` for generator, but here is a listing of some other useful flags: + +| Flag | Description | +|-----:|:------------| +| `-G"Generator"` | Select a generator | +| `--trace` | Print every line of CMake that is run. Very verbose. | +| `--trace-source="filename"` | Print out every line of a CMake file when it runs. Very useful. | + diff --git a/examples/root-simple-3.11/CMakeLists.txt b/examples/root-simple-3.11/CMakeLists.txt index f344e6c..b066590 100644 --- a/examples/root-simple-3.11/CMakeLists.txt +++ b/examples/root-simple-3.11/CMakeLists.txt @@ -7,7 +7,7 @@ project(RootSimpleExample311 LANGUAGES CXX) find_package(ROOT CONFIG REQUIRED) message(STATUS "Found ROOT: ${ROOT_VERSION} at ${ROOT_DIR}") -seperate_arguments(ROOT_CXX_FLAGS) +separate_arguments(ROOT_CXX_FLAGS) ## [modern_fix] target_include_directories(ROOT::Core INTERFACE "${ROOT_INCLUDE_DIRS}")