From 57aa3118aa5c915213d4665c93a37e83e33415f2 Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Thu, 27 Feb 2020 10:02:32 +0100 Subject: [PATCH] Added --with-ci-flags option to build scripts. --- .gitlab-ci.yml | 3 ++- CMakeLists.txt | 5 +++++ build | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 624a197299..fa4c3725da 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,7 +46,7 @@ stages: - export CTEST_OUTPUT_ON_FAILURE=1 - export CTEST_PARALLEL_LEVEL=4 # enforce (more or less) warning-free builds - - export CXXFLAGS="-Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=uninitialized -Wno-error=vla" + #- export CXXFLAGS="-Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=uninitialized -Wno-error=vla" - mkdir -p "./builddir/$CI_JOB_NAME" - pushd "./builddir/$CI_JOB_NAME" - cmake ../.. @@ -64,6 +64,7 @@ stages: -DWITH_EXAMPLES=${WITH_EXAMPLES} -DWITH_TOOLS=${WITH_TOOLS} -DWITH_PYTHON=${WITH_PYTHON} + -DWITH_CI_FLAGS=yes # "install" implies the "all" target - ninja ${NINJAFLAGS} install - if [[ ${WITH_TESTS} == "yes" ]]; then diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d1666163b..a312b00cb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,11 @@ set( CMAKE_SHARED_LINKER_FLAGS "" ) set( CMAKE_SHARED_LINKER_FLAGS_DEBUG "-rdynamic" ) set( CMAKE_SHARED_LINKER_FLAGS_RELEASE "" ) +if( ${WITH_CI_FLAGS} ) + # enforce (more or less) warning-free builds + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=deprecated -Wno-error=deprecated-declarations -Wno-error=uninitialized -Wno-error=vla" ) +endif() + # set additional Debug/Release options using generator expressions # (that way we can exclude some options for specific targets, see https://stackoverflow.com/a/59734798 for details) add_compile_options( diff --git a/build b/build index 9deb12d10a..5a26cbb619 100755 --- a/build +++ b/build @@ -31,6 +31,7 @@ WITH_EXAMPLES="yes" WITH_PYTHON="yes" WITH_TOOLS="yes" WITH_BENCHMARKS="yes" +WITH_CI_FLAGS="no" for option in "$@" do @@ -63,6 +64,7 @@ do --with-benchmarks=* ) WITH_BENCHMARKS="${option#*=}" ;; --with-python=* ) WITH_PYTHON="${option#*=}" ;; --with-cxx-flags=* ) WITH_CXX_FLAGS="${option#*=}" ;; + --with-ci-flags=* ) WITH_CI_FLAGS="${option#*=}" ;; * ) echo "Unknown option ${option}. Use --help for more information." exit 1 ;; @@ -93,6 +95,7 @@ if [[ ${HELP} == "yes" ]]; then echo " --with-python=yes/no Compile the Python bindings. 'yes' by default." echo " --with-benchmarks=yes/no Compile the 'src/Benchmarks' directory. 'yes' by default." echo " --with-cxx-flags=FLAGS Additional flags for C++ compiler." + echo " --with-cxx-flags=yes/no Turns on more strict C++ flags for CI. 'no' by default." echo " --cmake=CMAKE Path to cmake. 'cmake' by default." echo " --verbose It enables verbose build." echo " --root-dir=PATH Path to the TNL source code root dir." @@ -145,6 +148,7 @@ cmake_command=( -DWITH_PYTHON=${WITH_PYTHON} -DWITH_BENCHMARKS=${WITH_BENCHMARKS} -DWITH_CXX_FLAGS=${WITH_CXX_FLAGS} + -DWITH_CI_FLAGS=${WITH_CI_FLAGS} -DDCMTK_DIR=${DCMTK_DIR} ) -- GitLab