From 5a3a60de921f38a6f27ad0d45efe0d0af5eb5cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 18 Feb 2021 09:54:08 +0100 Subject: [PATCH 1/3] build script refactoring: change some --with-* options to targets, build nothing by default --- .gitlab-ci.yml | 82 +++++------ CMakeLists.txt | 31 ++-- build | 213 +++++++++++++++++----------- src/3rdparty/CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 +- src/TNL/Experimental/CMakeLists.txt | 2 +- 6 files changed, 197 insertions(+), 145 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ad81fd81..74194a3b3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,15 +20,15 @@ stages: WITH_CUDA: "no" WITH_CUDA_ARCH: "auto" WITH_MPI: "no" - # configurations - WITH_TESTS: "no" - WITH_MATRIX_TESTS: "no" + # build targets + BUILD_TESTS: "no" + BUILD_MATRIX_TESTS: "no" WITH_COVERAGE: "no" - WITH_DOC: "no" - WITH_BENCHMARKS: "no" - WITH_EXAMPLES: "no" - WITH_TOOLS: "no" - WITH_PYTHON: "no" + BUILD_DOC: "no" + BUILD_BENCHMARKS: "no" + BUILD_EXAMPLES: "no" + BUILD_TOOLS: "no" + BUILD_PYTHON: "no" # base for OpenMP+MPI builds .openmp_mpi: @@ -81,18 +81,18 @@ stages: -DWITH_MPI=${WITH_MPI} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} - -DWITH_TESTS=${WITH_TESTS} - -DWITH_MATRIX_TESTS=${WITH_MATRIX_TESTS} - -DWITH_DOC=${WITH_DOC} + -DBUILD_TESTS=${BUILD_TESTS} + -DBUILD_MATRIX_TESTS=${BUILD_MATRIX_TESTS} + -DBUILD_DOC=${BUILD_DOC} -DWITH_COVERAGE=${WITH_COVERAGE} - -DWITH_BENCHMARKS=${WITH_BENCHMARKS} - -DWITH_EXAMPLES=${WITH_EXAMPLES} - -DWITH_TOOLS=${WITH_TOOLS} - -DWITH_PYTHON=${WITH_PYTHON} + -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} + -DBUILD_EXAMPLES=${BUILD_EXAMPLES} + -DBUILD_TOOLS=${BUILD_TOOLS} + -DBUILD_PYTHON=${BUILD_PYTHON} -DWITH_CI_FLAGS=yes # "install" implies the "all" target - ninja ${NINJAFLAGS} install - - if [[ ${WITH_TESTS} == "yes" ]] || [[ ${WITH_MATRIX_TESTS} == "yes" ]]; then + - if [[ ${BUILD_TESTS} == "yes" ]] || [[ ${BUILD_MATRIX_TESTS} == "yes" ]]; then ninja test; fi - popd @@ -137,7 +137,7 @@ cuda_tests_Debug: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Debug - WITH_TESTS: "yes" + BUILD_TESTS: "yes" cuda_tests_Release: extends: .build_template @@ -149,7 +149,7 @@ cuda_tests_Release: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Release - WITH_TESTS: "yes" + BUILD_TESTS: "yes" cuda_matrix_tests_Debug: @@ -162,7 +162,7 @@ cuda_matrix_tests_Debug: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Debug - WITH_MATRIX_TESTS: "yes" + BUILD_MATRIX_TESTS: "yes" cuda_matrix_tests_Release: extends: .build_template @@ -174,7 +174,7 @@ cuda_matrix_tests_Release: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Release - WITH_MATRIX_TESTS: "yes" + BUILD_MATRIX_TESTS: "yes" cuda_examples_Debug: @@ -187,7 +187,7 @@ cuda_examples_Debug: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Debug - WITH_EXAMPLES: "yes" + BUILD_EXAMPLES: "yes" cuda_examples_Release: extends: .build_template @@ -199,7 +199,7 @@ cuda_examples_Release: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Release - WITH_EXAMPLES: "yes" + BUILD_EXAMPLES: "yes" cuda_benchmarks_tools_python_Debug: @@ -212,9 +212,9 @@ cuda_benchmarks_tools_python_Debug: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Debug - WITH_BENCHMARKS: "yes" - WITH_TOOLS: "yes" - WITH_PYTHON: "yes" + BUILD_BENCHMARKS: "yes" + BUILD_TOOLS: "yes" + BUILD_PYTHON: "yes" cuda_benchmarks_tools_python_Release: extends: .build_template @@ -226,9 +226,9 @@ cuda_benchmarks_tools_python_Release: <<: *default_cmake_flags WITH_CUDA: "yes" BUILD_TYPE: Release - WITH_BENCHMARKS: "yes" - WITH_TOOLS: "yes" - WITH_PYTHON: "yes" + BUILD_BENCHMARKS: "yes" + BUILD_TOOLS: "yes" + BUILD_PYTHON: "yes" cuda_mpi_tests_Debug: @@ -280,60 +280,60 @@ default_tests_Debug: variables: <<: *default_cmake_flags BUILD_TYPE: Debug - WITH_TESTS: "yes" + BUILD_TESTS: "yes" default_tests_Release: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Release - WITH_TESTS: "yes" + BUILD_TESTS: "yes" default_matrix_tests_Debug: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Debug - WITH_MATRIX_TESTS: "yes" + BUILD_MATRIX_TESTS: "yes" default_matrix_tests_Release: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Release - WITH_MATRIX_TESTS: "yes" + BUILD_MATRIX_TESTS: "yes" default_examples_Debug: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Debug - WITH_EXAMPLES: "yes" + BUILD_EXAMPLES: "yes" default_examples_Release: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Release - WITH_EXAMPLES: "yes" + BUILD_EXAMPLES: "yes" default_benchmarks_tools_python_Debug: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Debug - WITH_BENCHMARKS: "yes" - WITH_TOOLS: "yes" - WITH_PYTHON: "yes" + BUILD_BENCHMARKS: "yes" + BUILD_TOOLS: "yes" + BUILD_PYTHON: "yes" default_benchmarks_tools_python_Release: extends: .build_template variables: <<: *default_cmake_flags BUILD_TYPE: Release - WITH_BENCHMARKS: "yes" - WITH_TOOLS: "yes" - WITH_PYTHON: "yes" + BUILD_BENCHMARKS: "yes" + BUILD_TOOLS: "yes" + BUILD_PYTHON: "yes" mpi_tests_Debug: @@ -472,7 +472,7 @@ documentation examples: WITH_CUDA: "yes" BUILD_TYPE: Debug # build output snippets for documentation - WITH_DOC: "yes" + BUILD_DOC: "yes" only: changes: - Documentation/**/* diff --git a/CMakeLists.txt b/CMakeLists.txt index b85842c1f..09bf1b2a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,15 +23,15 @@ set(WITH_CUDA_ARCH "auto" CACHE STRING "Build for these CUDA architectures") option(WITH_OPENMP "Build with OpenMP support" ON) option(WITH_MPI "Build with MPI support" ON) option(WITH_GMP "Build with GMP support" OFF) -option(WITH_TESTS "Build tests" ON) -option(WITH_MATRIX_TESTS "Build tests for matrices" ON) option(WITH_PROFILING "Enable code profiling compiler flags" OFF ) option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF) -option(WITH_EXAMPLES "Compile the 'src/Examples' directory" ON) -option(WITH_TOOLS "Compile the 'src/Tools' directory" ON) -option(WITH_BENCHMARKS "Compile the 'src/Benchmarks' directory" ON) -option(WITH_PYTHON "Compile the Python bindings" ON) -option(WITH_DOC "Build examples included in the documentation" ON) +option(BUILD_BENCHMARKS "Compile the 'src/Benchmarks' directory" OFF) +option(BUILD_EXAMPLES "Compile the 'src/Examples' directory" OFF) +option(BUILD_TOOLS "Compile the 'src/Tools' directory" OFF) +option(BUILD_TESTS "Build tests" OFF) +option(BUILD_MATRIX_TESTS "Build tests for matrix formats" OFF) +option(BUILD_PYTHON "Compile the Python bindings" OFF) +option(BUILD_DOC "Build examples included in the documentation" OFF) # install paths relative to the cmake's prefix set( TNL_TARGET_INCLUDE_DIRECTORY "include/TNL" ) @@ -155,7 +155,7 @@ endif() link_libraries( stdc++fs ) # gtest has to be built before we add the MPI flags -if( ${WITH_TESTS} OR ${WITH_MATRIX_TESTS} ) +if( ${BUILD_TESTS} OR ${BUILD_MATRIX_TESTS} ) enable_testing() # build gtest libs @@ -330,7 +330,7 @@ include_directories( src/3rdparty ) add_subdirectory( src ) # Add subdirectories for examples included in the documentation -if( ${WITH_DOC} ) +if( ${BUILD_DOC} ) set( TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH "${CMAKE_SOURCE_DIR}/Documentation/output_snippets" ) file(MAKE_DIRECTORY ${TNL_DOCUMENTATION_OUTPUT_SNIPPETS_PATH}) add_subdirectory( Documentation/Examples ) @@ -373,14 +373,15 @@ message( " WITH_CUDA_ARCH = ${WITH_CUDA_ARCH}" ) message( " WITH_OPENMP = ${WITH_OPENMP}" ) message( " WITH_MPI = ${WITH_MPI}" ) message( " WITH_GMP = ${WITH_GMP}" ) -message( " WITH_TESTS = ${WITH_TESTS}" ) -message( " WITH_MATRIX_TESTS = ${WITH_MATRIX_TESTS}" ) message( " WITH_PROFILING = ${WITH_PROFILING}" ) message( " WITH_COVERAGE = ${WITH_COVERAGE}" ) -message( " WITH_EXAMPLES = ${WITH_EXAMPLES}" ) -message( " WITH_TOOLS = ${WITH_TOOLS}" ) -message( " WITH_BENCHMARKS = ${WITH_BENCHMARKS}" ) -message( " WITH_PYTHON = ${WITH_PYTHON}" ) +message( " BUILD_BENCHMARKS = ${BUILD_BENCHMARKS}" ) +message( " BUILD_EXAMPLES = ${BUILD_EXAMPLES}" ) +message( " BUILD_TOOLS = ${BUILD_TOOLS}" ) +message( " BUILD_TESTS = ${BUILD_TESTS}" ) +message( " BUILD_MATRIX_TESTS = ${BUILD_MATRIX_TESTS}" ) +message( " BUILD_PYTHON = ${BUILD_PYTHON}" ) +message( " BUILD_DOC = ${BUILD_DOC}" ) # Print compiler options message( "-- Compiler options:" ) message( " CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" ) diff --git a/build b/build index 5a9e3c5f2..3a15ac510 100755 --- a/build +++ b/build @@ -22,86 +22,137 @@ WITH_CUDA="yes" WITH_CUDA_ARCH="auto" WITH_OPENMP="yes" WITH_GMP="no" -WITH_TESTS="yes" -WITH_MATRIX_TESTS="yes" +WITH_CI_FLAGS="no" + +# flags affecting only tests RUN_TESTS="yes" # whether to run tests if they were compiled (coverage script sets it to no) TESTS_JOBS="4" WITH_PROFILING="no" WITH_COVERAGE="no" -WITH_DOC="yes" -WITH_EXAMPLES="yes" -WITH_PYTHON="yes" -WITH_TOOLS="yes" -WITH_BENCHMARKS="yes" -WITH_CI_FLAGS="no" +# targets +BUILD_BENCHMARKS="no" +BUILD_EXAMPLES="no" +BUILD_PYTHON="no" +BUILD_TOOLS="no" +BUILD_TESTS="no" +BUILD_MATRIX_TESTS="no" +BUILD_DOC="no" + +function print_usage() +{ + cat << EOF +usage: $0 [options] [target ...] + +By default, the script does not select any target. Build targets available for +selection are listed below. If the --install option is used, the TNL header +files as well as the selected targets will be installed into the directory +specified by the --prefix option. + +Targets: + all Special target which includes all other targets. + benchmarks Compile the 'src/Benchmarks' directory. + examples Compile the 'src/Examples' directory. + tools Compile the 'src/Tools' directory. + tests Compile unit tests in the 'src/UnitTests' directory (except + tests for matrix formats, which have a separate target). + matrix-tests Compile unit tests for matrix formats. + python Compile the Python bindings. + doc Generate the documentation. + +General options: + --help Write this help list and exit. + --verbose Enables verbose build. + --install=yes/no Enables the installation of TNL files. '$INSTALL' by default. + --prefix=PATH Prefix for the installation directory. '$HOME/local' by default. + +Options affecting all targets: + --offline-build=yes/no Disables online updates during the build. '$OFFLINE_BUILD' by default. + --build=Debug/Release Build type. + --build-jobs=NUM Number of processes to be used for the build. It is set to the number of available CPU cores by default. + --cmake=CMAKE Path to the cmake command. '$CMAKE' by default. + --cmake-only=yes/no Run only the cmake command, don't actually build anything. '$CMAKE_ONLY' by default. + --compiler=gcc/clang/icc Selects the compiler to use. '$COMPILER' by default. + --dcmtk-dir=PATH Path to the DCMTK (Dicom Toolkit) root dir. '$DCMTK_DIR' by default. + --with-mpi=yes/no Enables MPI. '$WITH_MPI' by default (OpenMPI required). + --with-cuda=yes/no Enables CUDA. '$WITH_CUDA' by default (CUDA Toolkit is required). + --with-cuda-arch=all/auto/3.0/3.5/... Chooses CUDA architecture. '$WITH_CUDA_ARCH' by default. + --with-openmp=yes/no Enables OpenMP. '$WITH_OPENMP' by default. + --with-gmp=yes/no Enables the wrapper for GNU Multiple Precision Arithmetic Library. '$WITH_GMP' by default. + --with-profiling=yes/no Enables code profiling compiler flags. '$WITH_PROFILING' by default. + +Options for the 'tests' and 'matrix-tests' targets: + --run-tests=yes/no Runs unit tests if they were compiled. '$RUN_TESTS' by default. + --tests-jobs=NUM Number of processes to be used for the unit tests. It is $TEST_JOBS by default. + --with-coverage=yes/no Enables code coverage reports for unit tests (lcov is required). '$WITH_COVERAGE' by default. +EOF +} + +# handle --help first for option in "$@"; do - if [[ "$option" == "--help" ]]; then - echo "TNL build options:" - echo "" - echo " --help Write this help list and exit." - echo " --build=Debug/Release Build type." - echo " --build-jobs=NUM Number of processes to be used for the build. It is set to the number of available CPU cores by default." - echo " --verbose Enables verbose build." - echo " --offline-build=yes/no Disables online updates during the build. '$OFFLINE_BUILD' by default." - echo " --install=yes/no Enables the installation of TNL files. '$INSTALL' by default." - echo " --prefix=PATH Prefix for the installation directory. '$HOME/local' by default." - echo " --cmake=CMAKE Path to the cmake command. '$CMAKE' by default." - echo " --cmake-only=yes/no Run only the cmake command, don't actually build anything. '$CMAKE_ONLY' by default." - echo " --compiler=gcc/clang/icc Selects the compiler to use. '$COMPILER' by default." - echo " --dcmtk-dir=PATH Path to the DCMTK (Dicom Toolkit) root dir. '$DCMTK_DIR' by default." - echo " --with-mpi=yes/no Enables MPI. '$WITH_MPI' by default (OpenMPI required)." - echo " --with-cuda=yes/no Enables CUDA. '$WITH_CUDA' by default (CUDA Toolkit is required)." - echo " --with-cuda-arch=all/auto/3.0/3.5/... Chooses CUDA architecture. '$WITH_CUDA_ARCH' by default." - echo " --with-openmp=yes/no Enables OpenMP. '$WITH_OPENMP' by default." - echo " --with-gmp=yes/no Enables the wrapper for GNU Multiple Precision Arithmetic Library. '$WITH_GMP' by default." - echo " --with-tests=yes/no Enables compilation of unit tests. '$WITH_TESTS' by default." - echo " --run-tests=yes/no Runs unit tests if they were compiled. '$RUN_TESTS' by default." - echo " --tests-jobs=NUM Number of processes to be used for the unit tests. It is $TEST_JOBS by default." - echo " --with-profiling=yes/no Enables code profiling compiler flags. '$WITH_PROFILING' by default." - echo " --with-coverage=yes/no Enables code coverage reports for unit tests (lcov is required). '$WITH_COVERAGE' by default." - echo " --with-doc=yes/no Generate the documentation. '$WITH_DOC' by default." - echo " --with-examples=yes/no Compile the 'src/Examples' directory. '$WITH_EXAMPLES' by default." - echo " --with-python=yes/no Compile the Python bindings. '$WITH_PYTHON' by default." - echo " --with-tools=yes/no Compile the 'src/Tools' directory. '$WITH_TOOLS' by default." - echo " --with-benchmarks=yes/no Compile the 'src/Benchmarks' directory. '$WITH_BENCHMARKS' by default." - exit 1 - fi + if [[ "$option" == "--help" ]]; then + print_usage + exit 1 + fi done +# handle options for option in "$@"; do - case "$option" in - --build=* ) BUILD="${option#*=}" ;; - --build-jobs=* ) BUILD_JOBS="${option#*=}" ;; - --verbose ) VERBOSE="VERBOSE=1" ;; - --offline-build ) OFFLINE_BUILD="yes" ;; - --install=* ) INSTALL="${option#*=}" ;; - --prefix=* ) PREFIX="${option#*=}" ;; - --cmake=* ) CMAKE="${option#*=}" ;; - --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; - --compiler=* ) COMPILER="${option#*=}" ;; - --dcmtk-dir=* ) DCMTK_DIR="${option#*=}" ;; - --with-mpi=* ) WITH_MPI="${option#*=}" ;; - --with-cuda=* ) WITH_CUDA="${option#*=}" ;; - --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; - --with-openmp=* ) WITH_OPENMP="${option#*=}" ;; - --with-gmp=* ) WITH_GMP="${option#*=}" ;; - --with-tests=* ) WITH_TESTS="${option#*=}" ;; - --with-matrix-tests=* ) WITH_MATRIX_TESTS="${option#*=}" ;; - --run-tests=* ) RUN_TESTS="${option#*=}" ;; - --tests-jobs=* ) TESTS_JOBS="${option#*=}" ;; - --with-profiling=* ) WITH_PROFILING="${option#*=}" ;; - --with-coverage=* ) WITH_COVERAGE="${option#*=}" ;; - --with-doc=* ) WITH_DOC="${option#*=}" ;; - --with-examples=* ) WITH_EXAMPLES="${option#*=}" ;; - --with-tools=* ) WITH_TOOLS="${option#*=}" ;; - --with-benchmarks=* ) WITH_BENCHMARKS="${option#*=}" ;; - --with-python=* ) WITH_PYTHON="${option#*=}" ;; - --with-ci-flags=* ) WITH_CI_FLAGS="${option#*=}" ;; - * ) - echo "Unknown option ${option}. Use --help for more information." >&2 - exit 1 - esac + case "$option" in + --build=* ) BUILD="${option#*=}" ;; + --build-jobs=* ) BUILD_JOBS="${option#*=}" ;; + --verbose ) VERBOSE="VERBOSE=1" ;; + --offline-build ) OFFLINE_BUILD="yes" ;; + --install=* ) INSTALL="${option#*=}" ;; + --prefix=* ) PREFIX="${option#*=}" ;; + --cmake=* ) CMAKE="${option#*=}" ;; + --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; + --compiler=* ) COMPILER="${option#*=}" ;; + --dcmtk-dir=* ) DCMTK_DIR="${option#*=}" ;; + --with-mpi=* ) WITH_MPI="${option#*=}" ;; + --with-cuda=* ) WITH_CUDA="${option#*=}" ;; + --with-cuda-arch=* ) WITH_CUDA_ARCH="${option#*=}";; + --with-openmp=* ) WITH_OPENMP="${option#*=}" ;; + --with-gmp=* ) WITH_GMP="${option#*=}" ;; + --run-tests=* ) RUN_TESTS="${option#*=}" ;; + --tests-jobs=* ) TESTS_JOBS="${option#*=}" ;; + --with-profiling=* ) WITH_PROFILING="${option#*=}" ;; + --with-coverage=* ) WITH_COVERAGE="${option#*=}" ;; + --with-ci-flags=* ) WITH_CI_FLAGS="${option#*=}" ;; + -* ) + echo "Unknown option $option. Use --help for more information." >&2 + exit 1 + ;; + *) break ;; + esac + shift +done + +# handle targets +for target in "$@"; do + case "$target" in + all) + BUILD_BENCHMARKS="yes" + BUILD_EXAMPLES="yes" + BUILD_TOOLS="yes" + BUILD_TESTS="yes" + BUILD_MATRIX_TESTS="yes" + BUILD_PYTHON="yes" + BUILD_DOC="yes" + ;; + benchmarks) BUILD_BENCHMARKS="yes" ;; + examples) BUILD_EXAMPLES="yes" ;; + tools) BUILD_TOOLS="yes" ;; + tests) BUILD_TESTS="yes" ;; + matrix-tests) BUILD_MATRIX_TESTS="yes" ;; + python) BUILD_PYTHON="yes" ;; + doc) BUILD_DOC="yes" ;; + *) + echo "Unknown target $target. The available targets are: all, benchmarks, examples, tools, tests, matrix-tests, python, doc." >&2 + echo "Use --help for more information." >&2 + exit 1 + esac + shift done if [[ "$COMPILER" == "gcc" ]]; then @@ -141,23 +192,23 @@ cmake_command=( -G "${generator}" -DCMAKE_BUILD_TYPE=${BUILD} -DCMAKE_INSTALL_PREFIX=${PREFIX} + -DDCMTK_DIR=${DCMTK_DIR} -DOFFLINE_BUILD=${OFFLINE_BUILD} -DWITH_CUDA=${WITH_CUDA} -DWITH_CUDA_ARCH=${WITH_CUDA_ARCH} -DWITH_OPENMP=${WITH_OPENMP} -DWITH_MPI=${WITH_MPI} -DWITH_GMP=${WITH_GMP} - -DWITH_TESTS=${WITH_TESTS} - -DWITH_MATRIX_TESTS=${WITH_MATRIX_TESTS} -DWITH_PROFILING=${WITH_PROFILING} -DWITH_COVERAGE=${WITH_COVERAGE} - -DWITH_DOC=${WITH_DOC} - -DWITH_EXAMPLES=${WITH_EXAMPLES} - -DWITH_TOOLS=${WITH_TOOLS} - -DWITH_PYTHON=${WITH_PYTHON} - -DWITH_BENCHMARKS=${WITH_BENCHMARKS} -DWITH_CI_FLAGS=${WITH_CI_FLAGS} - -DDCMTK_DIR=${DCMTK_DIR} + -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} + -DBUILD_EXAMPLES=${BUILD_EXAMPLES} + -DBUILD_TOOLS=${BUILD_TOOLS} + -DBUILD_TESTS=${BUILD_TESTS} + -DBUILD_MATRIX_TESTS=${BUILD_MATRIX_TESTS} + -DBUILD_PYTHON=${BUILD_PYTHON} + -DBUILD_DOC=${BUILD_DOC} ) # Skip running cmake if it was already run and the cmake command is the same. @@ -224,11 +275,11 @@ if ! $make ${VERBOSE} $make_target; then exit 1 fi -if [[ ${WITH_DOC} == "yes" ]]; then +if [[ ${BUILD_DOC} == "yes" ]]; then "$ROOT_DIR/Documentation/build" --prefix="$PREFIX" fi -if [[ ${WITH_TESTS} == "yes" ]] || [[ ${WITH_MATRIX_TESTS} == "yes" ]]; then +if [[ ${BUILD_TESTS} == "yes" ]] || [[ ${BUILD_MATRIX_TESTS} == "yes" ]]; then if [[ ${RUN_TESTS} == "yes" ]]; then OMP_NUM_THREADS=${TESTS_JOBS} CTEST_PARALLEL_LEVEL=${TESTS_JOBS} CTEST_OUTPUT_ON_FAILURE=1 $make test fi diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index 6af8134ba..fbe3204f1 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -2,7 +2,7 @@ install( DIRECTORY async mpark Leksys TYPE INCLUDE MESSAGE_NEVER FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" ) -if( ${WITH_PYTHON} ) +if( ${BUILD_PYTHON} ) install( DIRECTORY cctbx TYPE INCLUDE MESSAGE_NEVER FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfb91adaa..4dcf601c0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,25 +11,25 @@ add_subdirectory( TNL/Experimental ) # Note that it is important to start building examples as soon as possible, # because they take the longest time and other stuff can be pipelined before # they are finished (at least with Ninja). -if( ${WITH_EXAMPLES} ) +if( ${BUILD_EXAMPLES} ) add_subdirectory( Examples ) endif() -if( ${WITH_BENCHMARKS} ) +if( ${BUILD_BENCHMARKS} ) add_subdirectory( Benchmarks ) endif() -if( ${WITH_TOOLS} ) +if( ${BUILD_TOOLS} ) add_subdirectory( Tools ) endif() -if( ${WITH_TESTS} ) +if( ${BUILD_TESTS} ) add_subdirectory( UnitTests ) endif() -if( ${WITH_MATRIX_TESTS} ) +if( ${BUILD_MATRIX_TESTS} ) add_subdirectory( UnitTests/Matrices ) endif() -if( ${WITH_PYTHON} ) +if( ${BUILD_PYTHON} ) add_subdirectory( Python ) endif() diff --git a/src/TNL/Experimental/CMakeLists.txt b/src/TNL/Experimental/CMakeLists.txt index b543baec6..fc636e695 100644 --- a/src/TNL/Experimental/CMakeLists.txt +++ b/src/TNL/Experimental/CMakeLists.txt @@ -1,4 +1,4 @@ add_subdirectory( Arithmetics ) -if( ${WITH_EXAMPLES} ) +if( ${BUILD_EXAMPLES} ) add_subdirectory( Hamilton-Jacobi ) endif() -- GitLab From 446b988dad2af7ec07477642ad4bb1984b19ac9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 18 Feb 2021 09:56:03 +0100 Subject: [PATCH 2/3] install script refactoring: tnl-bindir does not exist anymore, check $PATH directly --- install | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/install b/install index 989620b15..8eae2bad4 100755 --- a/install +++ b/install @@ -56,38 +56,23 @@ fi PREFIX=${HOME}/.local -for option in "$@" -do +for option in "$@"; do case $option in - --prefix=* ) PREFIX="${option#*=}" ;; + --prefix=*) PREFIX="${option#*=}" ;; esac done -TNL_TEST=`which tnl-bindir` +if [[ ! "$PATH" =~ "$PREFIX/bin" ]]; then + cat << EOF + +WARNING !!! + +Your system does not see TNL which was installed right now. +You need to add it to your system variables PATH and LD_LIBRARY_PATH. +Add the following to your .bashrc file: -if test x${TNL_TEST} = x; -then - echo "" - echo "WARNING !!!" - echo "" - echo "Your system does not see TNL which was installed right now." - echo "You need to add it to your system variables PATH and LD_LIBRARY_PATH." - echo "Add the following to your .bashrc file:" - echo "" - - echo "if test x\${PATH} = x;" - echo "then" - echo " PATH=${PREFIX}/bin" - echo "else" - echo " PATH=\${PATH}:${PREFIX}/bin" - echo "fi" - echo "if test x\${LD_LIBRARY_PATH} = x;" - echo "then" - echo " LD_LIBRARY_PATH=${PREFIX}/lib" - echo "else" - echo " LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${PREFIX}/lib" - echo "fi" - echo "export PATH" - echo "export LD_LIBRARY_PATH" +export PATH="\${PATH}:${PREFIX}/bin" +export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${PREFIX}/lib" +EOF fi -- GitLab From 596a2e70786b0f5bdc22cb49b8e796d44feadc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 18 Feb 2021 14:07:25 +0100 Subject: [PATCH 3/3] build script: removed --with-profiling, --build=RelWithDebInfo can be used instead --- CMakeLists.txt | 11 ++++------- build | 13 ++++++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09bf1b2a6..1d4c8677f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ set(WITH_CUDA_ARCH "auto" CACHE STRING "Build for these CUDA architectures") option(WITH_OPENMP "Build with OpenMP support" ON) option(WITH_MPI "Build with MPI support" ON) option(WITH_GMP "Build with GMP support" OFF) -option(WITH_PROFILING "Enable code profiling compiler flags" OFF ) option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF) option(BUILD_BENCHMARKS "Compile the 'src/Benchmarks' directory" OFF) option(BUILD_EXAMPLES "Compile the 'src/Examples' directory" OFF) @@ -76,6 +75,7 @@ set( CMAKE_CXX_EXTENSIONS OFF ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -Wall" ) set( CMAKE_CXX_FLAGS_DEBUG "-g" ) set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" ) +set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG}" ) # pass -rdynamic only in Debug mode set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" ) set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS_DEBUG "-rdynamic" ) @@ -211,6 +211,9 @@ if( ${WITH_CUDA} ) endif() endif() set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -DHAVE_CUDA --expt-relaxed-constexpr --expt-extended-lambda --default-stream per-thread) + if( CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" ) + set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; --generate-line-info) + endif() # disable false compiler warnings # reference for the -Xcudafe --diag_suppress and --display_error_number flags: https://stackoverflow.com/a/54142937 # incomplete list of tokens: http://www.ssl.berkeley.edu/~jimm/grizzly_docs/SSL/opt/intel/cc/9.0/lib/locale/en_US/mcpcom.msg @@ -241,11 +244,6 @@ if( ${WITH_CUDA} ) endif() -if( ${WITH_PROFILING} ) - set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g" ) - set( CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --generate-line-info") -endif() - find_package( DCMTK ) if( DCMTK_FOUND ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_DCMTK_H" ) @@ -373,7 +371,6 @@ message( " WITH_CUDA_ARCH = ${WITH_CUDA_ARCH}" ) message( " WITH_OPENMP = ${WITH_OPENMP}" ) message( " WITH_MPI = ${WITH_MPI}" ) message( " WITH_GMP = ${WITH_GMP}" ) -message( " WITH_PROFILING = ${WITH_PROFILING}" ) message( " WITH_COVERAGE = ${WITH_COVERAGE}" ) message( " BUILD_BENCHMARKS = ${BUILD_BENCHMARKS}" ) message( " BUILD_EXAMPLES = ${BUILD_EXAMPLES}" ) diff --git a/build b/build index 3a15ac510..3e7f11c58 100755 --- a/build +++ b/build @@ -6,7 +6,7 @@ set -e # get the root directory (i.e. the directory where this script is located) ROOT_DIR="$( builtin cd -P "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -BUILD="" +BUILD="Release" BUILD_JOBS="" VERBOSE="" OFFLINE_BUILD="no" @@ -27,7 +27,6 @@ WITH_CI_FLAGS="no" # flags affecting only tests RUN_TESTS="yes" # whether to run tests if they were compiled (coverage script sets it to no) TESTS_JOBS="4" -WITH_PROFILING="no" WITH_COVERAGE="no" # targets @@ -79,7 +78,6 @@ Options affecting all targets: --with-cuda-arch=all/auto/3.0/3.5/... Chooses CUDA architecture. '$WITH_CUDA_ARCH' by default. --with-openmp=yes/no Enables OpenMP. '$WITH_OPENMP' by default. --with-gmp=yes/no Enables the wrapper for GNU Multiple Precision Arithmetic Library. '$WITH_GMP' by default. - --with-profiling=yes/no Enables code profiling compiler flags. '$WITH_PROFILING' by default. Options for the 'tests' and 'matrix-tests' targets: --run-tests=yes/no Runs unit tests if they were compiled. '$RUN_TESTS' by default. @@ -104,6 +102,7 @@ for option in "$@"; do --verbose ) VERBOSE="VERBOSE=1" ;; --offline-build ) OFFLINE_BUILD="yes" ;; --install=* ) INSTALL="${option#*=}" ;; + --install ) INSTALL="yes" ;; --prefix=* ) PREFIX="${option#*=}" ;; --cmake=* ) CMAKE="${option#*=}" ;; --cmake-only=* ) CMAKE_ONLY="${option#*=}" ;; @@ -116,7 +115,6 @@ for option in "$@"; do --with-gmp=* ) WITH_GMP="${option#*=}" ;; --run-tests=* ) RUN_TESTS="${option#*=}" ;; --tests-jobs=* ) TESTS_JOBS="${option#*=}" ;; - --with-profiling=* ) WITH_PROFILING="${option#*=}" ;; --with-coverage=* ) WITH_COVERAGE="${option#*=}" ;; --with-ci-flags=* ) WITH_CI_FLAGS="${option#*=}" ;; -* ) @@ -128,6 +126,12 @@ for option in "$@"; do shift done +# check the build type +if [[ ! "Release Debug RelWithDebInfo" =~ "$BUILD" ]]; then + echo "Unknown build type: $BUILD. The available build types are: Release, Debug, RelWithDebInfo." >&2 + exit 1 +fi + # handle targets for target in "$@"; do case "$target" in @@ -199,7 +203,6 @@ cmake_command=( -DWITH_OPENMP=${WITH_OPENMP} -DWITH_MPI=${WITH_MPI} -DWITH_GMP=${WITH_GMP} - -DWITH_PROFILING=${WITH_PROFILING} -DWITH_COVERAGE=${WITH_COVERAGE} -DWITH_CI_FLAGS=${WITH_CI_FLAGS} -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} -- GitLab