diff --git a/.gitignore b/.gitignore index 20d1883ddd50d7456a5a335e4128a770406bc840..935ed9c3483a235a260a05822ea82f628e16f958 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ CMakeLists.txt.user* Tests/**/*.md5 Tests/Data/Parabolic/HT/InvalidProjectFiles/*.prj web/.netlify + +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index dc932887c31dc31421d45ac6975708125bcb708d..e8f4271a2e929b20db54b923e86dd03e09d5d4bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,6 +38,14 @@ endif() if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.16) option(OGS_USE_UNITY_BUILDS "Enables Unity builds for faster compilation." ON) endif() +option(OGS_USE_PYTHON "Interface with Python" ON) +option(OGS_USE_POETRY "Enables automatic Python virtual environment handling with poetry." ON) +if(WIN32) + option(OGS_BUILD_SWMM "Should the SWMM interface be built?" ON) +endif() +if(NOT WIN32 AND OGS_BUILD_SWMM) + message(FATAL_ERROR "OGS_BUILD_SWMM requires Windows!") +endif() # Third-party libraries, names come from Conan package names set(OGS_LIBS @@ -63,6 +71,7 @@ if(OGS_USE_PETSC) set(OGS_USE_MPI ON CACHE BOOL "Use MPI" FORCE) endif() option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) +option(OGS_BUILD_UTILS "Should the utilities programms be built?" ON) # ---- CMake includes ---- include(GitSetup) @@ -93,15 +102,6 @@ if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) AND GPROF_PATH) endif() # GCC AND GPROF_PATH option(OGS_BUILD_GUI "Should the Data Explorer be built?" OFF) -option(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF) - -if(WIN32) - option(OGS_BUILD_SWMM "Should the SWMM interface be built?" OFF) -endif() -if(NOT WIN32 AND OGS_BUILD_SWMM) - message(FATAL_ERROR "OGS_BUILD_SWMM requires Windows!") -endif() - option(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF) option(OGS_INSITU "Builds OGS with insitu visualization capabilities." OFF) option(OGS_USE_LIS "Use Lis" OFF) @@ -182,11 +182,6 @@ endif() option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." OFF) -option(OGS_USE_PYTHON "Interface with Python" OFF) -if(OGS_USE_PYTHON AND NOT Python3_FOUND) - message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!") -endif() - option(OGS_USE_MFRONT "Enable solid material models by MFront (https://tfel.sourceforge.net)" OFF) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000000000000000000000000000000000..3ab4166ef4cf08921ca1b3ba37561ab257bc336d --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,166 @@ +{ + "version": 1, + "cmakeMinimumRequired": { + "major": 3, + "minor": 19, + "patch": 0 + }, + "configurePresets": [ + { + "name": "_binary_dir", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}" + }, + { + "name": "_release", + "hidden": true, + "inherits": "_binary_dir", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "_debug", + "hidden": true, + "inherits": "_binary_dir", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "_ninja", + "hidden": true, + "generator": "Ninja" + }, + { + "name": "_msvc", + "hidden": true, + "generator": "Visual Studio 16 2019" + }, + { + "name": "_gui", + "hidden": true, + "cacheVariables": { + "OGS_BUILD_CLI": "OFF", + "OGS_BUILD_GUI": "ON", + "OGS_USE_NETCDF": "ON" + } + }, + { + "name": "_petsc", + "hidden": true, + "cacheVariables": { + "OGS_USE_PYTHON": "OFF", + "BUILD_SHARED_LIBS": "ON", + "OGS_USE_CONAN": "OFF", + "OGS_USE_PETSC": "ON" + }, + "environment": { + "CC": "mpicc", + "CXX": "mpic++" + } + }, + { + "name": "release", + "inherits": [ + "_ninja", + "_release" + ] + }, + { + "name": "debug", + "inherits": [ + "_ninja", + "_debug" + ] + }, + { + "name": "release-gui", + "inherits": [ + "release", + "_gui" + ] + }, + { + "name": "debug-gui", + "inherits": [ + "debug", + "_gui" + ] + }, + { + "name": "release-petsc", + "inherits": [ + "release", + "_petsc" + ] + }, + { + "name": "debug-petsc", + "inherits": [ + "debug", + "_petsc" + ] + }, + { + "name": "msvc-release", + "inherits": [ + "_msvc", + "_release" + ] + }, + { + "name": "msvc-debug", + "inherits": [ + "_msvc", + "_debug" + ] + }, + { + "name": "msvc-release-gui", + "inherits": [ + "msvc-release", + "_gui" + ] + }, + { + "name": "msvc-debug-gui", + "inherits": [ + "msvc-debug", + "_gui" + ] + }, + { + "name": "_all", + "hidden": true, + "cacheVariables": { + "OGS_USE_MFRONT": "ON", + "OGS_USE_XDMF": "ON" + } + }, + { + "name": "release-all", + "inherits": [ + "release", + "_all" + ] + }, + { + "name": "debug-all", + "inherits": [ + "debug", + "_all" + ] + }, + { + "name": "ci-simplest", + "inherits": "release", + "cacheVariables": { + "OGS_BUILD_UTILS": "OFF", + "OGS_USE_PYTHON": "OFF", + "OGS_USE_CONAN": "OFF", + "OGS_USE_POETRY": "OFF" + } + } + ] +} diff --git a/ThirdParty/container-maker b/ThirdParty/container-maker index 6fc82f9e2954fc1a676e69425af8d78cb1cc1239..35d81f1b2fa2470035eb578364e4b867dc41aa8e 160000 --- a/ThirdParty/container-maker +++ b/ThirdParty/container-maker @@ -1 +1 @@ -Subproject commit 6fc82f9e2954fc1a676e69425af8d78cb1cc1239 +Subproject commit 35d81f1b2fa2470035eb578364e4b867dc41aa8e diff --git a/scripts/ci/extends/template-build-linux.yml b/scripts/ci/extends/template-build-linux.yml index 92bf2a643dfc702821db8070b4075b69305872d3..346ff35eb4522926f63f8bb17f817feb60cfe5fb 100644 --- a/scripts/ci/extends/template-build-linux.yml +++ b/scripts/ci/extends/template-build-linux.yml @@ -9,17 +9,12 @@ before_script: - "echo \"For debugging run: docker run --rm -it -v $CI_BUILDS_DIR:/builds -w=$CI_PROJECT_DIR $CI_JOB_IMAGE\"" - - mkdir -p $BUILD_DIR - - cd $BUILD_DIR - ([ "${CONAN_USER_HOME}" == "${CI_PROJECT_DIR}/.conan" ]) && conan remove --system-reqs '*' - ([[ $BUILD_CTEST_LARGE_ON_MASTER && "${CI_COMMIT_BRANCH}" == "master" && "${CMAKE_ARGS}" == *"USE_PYTHON=ON"* ]]) && export BUILD_CTEST_LARGE=true script: - - "echo \"Running: cmake .. -G Ninja $CMAKE_ARGS -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DOGS_BUILD_PROCESSES=$BUILD_PROCESSES\"" - - > - cmake .. -G Ninja - $CMAKE_ARGS - -DCMAKE_BUILD_TYPE=$BUILD_TYPE - -DOGS_BUILD_PROCESSES=$BUILD_PROCESSES + - cmake -S . --preset=$CMAKE_PRESET $CMAKE_ARGS -DOGS_BUILD_PROCESSES=$BUILD_PROCESSES + - build_dir=${BUILD_DIR:-build/$CMAKE_PRESET} + - cd $build_dir - $BUILD_CMD_PREFIX cmake --build . --target package > >(tee make.output) - if [ "$BUILD_TESTS" = true ] ; then $BUILD_CMD_PREFIX cmake --build . --target tests ; fi - if [ "$BUILD_CTEST" = true ] ; then $BUILD_CMD_PREFIX cmake --build . --target ctest ; fi diff --git a/scripts/ci/extends/template-build-win.yml b/scripts/ci/extends/template-build-win.yml index 8b5d9e761446e4e706899e16be21d7092c403838..ac696034ed366e7b8f56998e39ca1cc06b4383f8 100644 --- a/scripts/ci/extends/template-build-win.yml +++ b/scripts/ci/extends/template-build-win.yml @@ -8,14 +8,13 @@ dependencies: [meta, meta_container] variables: script: - - mkdir -p $env:BUILD_DIR - - cd $env:BUILD_DIR - - $cmake_cmd = "cmake .. -G Ninja + - $build_directory = if ($env:BUILD_DIR) { $env:BUILD_DIR } else { "build/" + $env:CMAKE_PRESET } + - $cmake_cmd = "cmake -S . --preset=$env:CMAKE_PRESET $env:CMAKE_ARGS - -DCMAKE_BUILD_TYPE=$env:BUILD_TYPE -DOGS_BUILD_PROCESSES=$env:BUILD_PROCESSES" - $cmake_cmd - Invoke-Expression $cmake_cmd + - cd $build_directory - cmake --build . --target package | Tee-Object -FilePath make.output - if($env:BUILD_TESTS -eq "true") { cmake --build . --target tests } - if($env:BUILD_CTEST -eq "true") { cmake --build . --target ctest } diff --git a/scripts/ci/extends/test-artifacts.yml b/scripts/ci/extends/test-artifacts.yml index 99fea5077af6c66c0d0ef9a63202373527bb99ff..424ff0e992ecb5ee02ef1d6cb79d6d75ea1f7e84 100644 --- a/scripts/ci/extends/test-artifacts.yml +++ b/scripts/ci/extends/test-artifacts.yml @@ -1,12 +1,12 @@ .test-artifacts: artifacts: paths: - - $BUILD_DIR/Tests/ctest.xml - - $BUILD_DIR/Tests/testrunner.xml - - $BUILD_DIR/make.output - - $BUILD_DIR/*.zip - - $BUILD_DIR/*.tar.gz + - build/*/Tests/ctest.xml + - build/*/Tests/testrunner.xml + - build/*/make.output + - build/*/*.zip + - build/*/*.tar.gz expire_in: 1 week reports: junit: - - $BUILD_DIR/Tests/testrunner.xml + - build/*/Tests/testrunner.xml diff --git a/scripts/ci/jobs/build-gui-linux.yml b/scripts/ci/jobs/build-gui-linux.yml index ee0ba1e833f98939fa399ba6ca601785e35077c3..b2b8b824cd3bc685ec08612e675732fa9c9f4ffb 100644 --- a/scripts/ci/jobs/build-gui-linux.yml +++ b/scripts/ci/jobs/build-gui-linux.yml @@ -10,11 +10,7 @@ build gui linux: - when: manual allow_failure: true variables: - BUILD_DIR: "build-gui-linux" + CMAKE_PRESET: release-gui CMAKE_ARGS: >- -DOGS_USE_CONAN=OFF - -DOGS_BUILD_CLI=OFF - -DOGS_BUILD_GUI=ON - -DOGS_BUILD_UTILS=ON - -DOGS_USE_NETCDF=ON -DOGS_INSTALL_DEPENDENCIES=ON diff --git a/scripts/ci/jobs/build-gui-mac.yml b/scripts/ci/jobs/build-gui-mac.yml index b9a3f5da14bdb03b039bdc77f946ed2b1148319c..ca76dd06216502b1b8f971672ef33c8917d3282f 100644 --- a/scripts/ci/jobs/build-gui-mac.yml +++ b/scripts/ci/jobs/build-gui-mac.yml @@ -9,11 +9,7 @@ build gui mac: - when: manual allow_failure: true variables: - BUILD_DIR: "build-gui-mac" + CMAKE_PRESET: release-gui CMAKE_ARGS: >- -DOGS_USE_CONAN=auto - -DOGS_BUILD_CLI=OFF - -DOGS_BUILD_GUI=ON - -DOGS_BUILD_UTILS=ON - -DOGS_USE_NETCDF=OFF -DOGS_INSTALL_DEPENDENCIES=ON diff --git a/scripts/ci/jobs/build-gui-win.yml b/scripts/ci/jobs/build-gui-win.yml index b807ab28d35b9bacb3e5053fc627d26a2d9d86db..5835286efd3a62308b607b52a28872a16621ec8f 100644 --- a/scripts/ci/jobs/build-gui-win.yml +++ b/scripts/ci/jobs/build-gui-win.yml @@ -8,14 +8,9 @@ build gui win: - when: manual allow_failure: true variables: - BUILD_DIR: build-gui-win + CMAKE_PRESET: release-gui CMAKE_ARGS: >- -DOGS_$USE_PYTHON - -DOGS_BUILD_CLI=OFF - -DOGS_BUILD_GUI=ON - -DOGS_BUILD_UTILS=ON - -DOGS_BUILD_SWMM=ON - -DOGS_USE_NETCDF=ON -DOGS_CI_TESTRUNNER_REPEAT=1 parallel: matrix: diff --git a/scripts/ci/jobs/build-linux-conan.yml b/scripts/ci/jobs/build-linux-conan.yml index 34f3a983c076bc7d574ee4eb2449647694cbf222..baabe461e6e824d3cb94eac88ae3c0237f65e82a 100644 --- a/scripts/ci/jobs/build-linux-conan.yml +++ b/scripts/ci/jobs/build-linux-conan.yml @@ -4,10 +4,9 @@ build linux conan: - .rules-master-manual tags: [shell, envinf1-shell] variables: - BUILD_DIR: build + CMAKE_PRESET: release CMAKE_ARGS: >- -DBUILD_SHARED_LIBS=ON - -DOGS_BUILD_UTILS=ON -DOGS_USE_CONAN=AUTO -DOGS_USE_MFRONT=ON -DOGS_USE_XDMF=ON diff --git a/scripts/ci/jobs/build-linux-frontend.yml b/scripts/ci/jobs/build-linux-frontend.yml index 7d3e086a15daf178f617dbc1045c283e6063c6aa..a1106ef33da67886b22ba58170072c14a87e9a8e 100644 --- a/scripts/ci/jobs/build-linux-frontend.yml +++ b/scripts/ci/jobs/build-linux-frontend.yml @@ -6,10 +6,8 @@ build linux frontend: - frontend2 allow_failure: true variables: - BUILD_DIR: "build" CCACHE_DIR: "/data/ogs/.ccache" - CMAKE_ARGS: "-DOGS_USE_CONAN=OFF -DOGS_DISABLE_CCACHE=OFF -DOGS_CPU_ARCHITECTURE=generic" + CMAKE_PRESET: release + CMAKE_ARGS: "-DOGS_USE_CONAN=OFF -DOGS_USE_PYTHON=OFF -DOGS_CPU_ARCHITECTURE=generic" before_script: - source scripts/env/eve/cli.sh - - mkdir -p $BUILD_DIR - - cd $BUILD_DIR diff --git a/scripts/ci/jobs/build-linux-petsc.yml b/scripts/ci/jobs/build-linux-petsc.yml index 183edff1f863086840c76836f395955b01a1b5da..04fe1f3f8684e85b283874bfcc5d6804a7479f19 100644 --- a/scripts/ci/jobs/build-linux-petsc.yml +++ b/scripts/ci/jobs/build-linux-petsc.yml @@ -4,10 +4,5 @@ build linux petsc: - envinf1-shell timeout: 2h variables: - BUILD_DIR: "build-petsc" BUILD_CTEST_LARGE_ON_MASTER: "true" - CMAKE_ARGS: >- - -DBUILD_SHARED_LIBS=ON - -DOGS_BUILD_UTILS=ON - -DOGS_USE_CONAN=OFF - -DOGS_USE_PETSC=ON + CMAKE_PRESET: release-petsc diff --git a/scripts/ci/jobs/build-linux.yml b/scripts/ci/jobs/build-linux.yml index 3873b170e81aeababcfba51c119db38e1ced7cb4..c9002c05009a70d6cf29d4fa71b9c513d94d8df7 100644 --- a/scripts/ci/jobs/build-linux.yml +++ b/scripts/ci/jobs/build-linux.yml @@ -4,10 +4,9 @@ build linux: tags: [ docker ] timeout: 2h variables: - BUILD_DIR: "build" BUILD_CTEST_LARGE_ON_MASTER: "true" + CMAKE_PRESET: release CMAKE_ARGS: >- - -DOGS_BUILD_UTILS=ON -DOGS_USE_CONAN=OFF -DOGS_USE_MFRONT=ON -DOGS_$USE_PYTHON @@ -24,16 +23,17 @@ build linux (no unity): tags: [ docker ] timeout: 1h variables: - BUILD_DIR: "build-no-unity" + BUILD_DIR: "build/no-unity" BUILD_TESTS: "false" BUILD_CTEST: "false" + CMAKE_PRESET: release CMAKE_ARGS: >- - -DOGS_BUILD_UTILS=ON + -DOGS_USE_PYTHON=OFF -DOGS_USE_CONAN=OFF - -DOGS_USE_UNITY_BUILDS=OFF -DOGS_USE_MFRONT=ON + -DOGS_USE_UNITY_BUILDS=OFF -DOGS_USE_XDMF=ON - -DOGS_USE_PYTHON=ON + -B $BUILD_DIR build linux (no deps, no procs): image: $CONTAINER_GCC_IMAGE @@ -41,9 +41,7 @@ build linux (no deps, no procs): tags: [ docker ] timeout: 1h variables: - BUILD_DIR: "build-no-unity" BUILD_TESTS: "false" BUILD_CTEST: "false" BUILD_PROCESSES: "SteadyStateDiffusion" - CMAKE_ARGS: >- - -DOGS_USE_CONAN=OFF + CMAKE_PRESET: ci-simplest diff --git a/scripts/ci/jobs/build-mac.yml b/scripts/ci/jobs/build-mac.yml index 1ae0f906a52f023ea3df3f10654a806e48d59f9c..5c35c328fc9b7984f7299bf63ed1058a5b9cfc1d 100644 --- a/scripts/ci/jobs/build-mac.yml +++ b/scripts/ci/jobs/build-mac.yml @@ -3,9 +3,9 @@ build mac: tags: - mac variables: - BUILD_DIR: "build-mac" + BUILD_DIR: "build/mac-release" + CMAKE_PRESET: release CMAKE_ARGS: >- - -DOGS_BUILD_UTILS=ON - -DOGS_USE_PYTHON=ON -DOGS_INSTALL_DEPENDENCIES=ON -DOGS_USE_XDMF=ON + -B $BUILD_DIR diff --git a/scripts/ci/jobs/build-win.yml b/scripts/ci/jobs/build-win.yml index bd4459720dec7268ef43a4f545ba0f5608f299c8..5fc3a970ff0f9b8247f5760902ee31e98780fd47 100644 --- a/scripts/ci/jobs/build-win.yml +++ b/scripts/ci/jobs/build-win.yml @@ -7,13 +7,14 @@ build win: - when: manual allow_failure: true variables: - BUILD_DIR: build-win + BUILD_DIR: build/win-release + CMAKE_PRESET: release CMAKE_ARGS: >- - -DOGS_BUILD_UTILS=ON -DOGS_CI_TESTRUNNER_REPEAT=1 -DOGS_$USE_PYTHON -DOGS_USE_CONAN=AUTO -DOGS_USE_XDMF=ON + -B $BUILD_DIR parallel: matrix: - USE_PYTHON: ["USE_PYTHON=ON", "USE_PYTHON=OFF"] diff --git a/scripts/ci/jobs/check-header.yml b/scripts/ci/jobs/check-header.yml index 6bf461d5c830c9452b352bf61e0e60d056e25a41..daf3914f27b60027a1cdd0fa8ae60978bb6726c8 100644 --- a/scripts/ci/jobs/check-header.yml +++ b/scripts/ci/jobs/check-header.yml @@ -6,7 +6,7 @@ check header: dependencies: [meta, meta_container] variables: BUILD_DIR: "build-check-header" - CMAKE_ARGS: "-DOGS_CHECK_HEADER_COMPILATION=ON -DOGS_BUILD_UTILS=ON -DOGS_BUILD_GUI=ON -DOGS_USE_PYTHON=ON -DBUILD_SHARED_LIBS=ON" + CMAKE_ARGS: "-DOGS_CHECK_HEADER_COMPILATION=ON -DOGS_BUILD_GUI=ON -DBUILD_SHARED_LIBS=ON" image: $CONTAINER_GCC_GUI_IMAGE script: - mkdir -p $BUILD_DIR diff --git a/scripts/ci/jobs/checks.yml b/scripts/ci/jobs/checks.yml index 26381758617dc6783d87a436c040309d3e0f5884..e02ffef696c6595b222dae11e283f7847b1b9c0b 100644 --- a/scripts/ci/jobs/checks.yml +++ b/scripts/ci/jobs/checks.yml @@ -10,10 +10,10 @@ compiler warnings: - job: build mac script: - exit_code=0 - - cd build-no-unity + - cd build/no-unity - "if [[ $(cat make.output | grep warning -i) ]]; then printf 'There were GCC compiler warnings:\n\n'; cat make.output | grep warning -i; exit_code=1; fi" - - cd ../build-win + - cd ../win-release - "if [[ $(cat make.output | grep ': warning' -i) ]]; then printf 'There were MSVC compiler warnings:\n\n'; cat make.output | grep ': warning' -i; exit_code=1; fi" - - cd ../build-mac + - cd ../mac-release - "if [[ $(cat make.output | grep warning -i) ]]; then printf 'There were Clang (macOS) compiler warnings:\n\n'; cat make.output | grep warning -i; exit_code=1; fi" - exit $exit_code diff --git a/scripts/ci/jobs/clang-sanitizer.yml b/scripts/ci/jobs/clang-sanitizer.yml index 2420e539cef9fd16f49a7ba6c1fd875ab75546b4..281d20e93b48f400e89a26fa2db8ea7c4bdc1795 100644 --- a/scripts/ci/jobs/clang-sanitizer.yml +++ b/scripts/ci/jobs/clang-sanitizer.yml @@ -5,7 +5,7 @@ clang sanitizer: needs: ["pre commit"] variables: BUILD_DIR: "build-sanitizer" - CMAKE_ARGS: "-DOGS_ADDRESS_SANITIZER=ON -DOGS_UNDEFINED_BEHAVIOR_SANITIZER=ON -DOGS_BUILD_UTILS=ON" + CMAKE_ARGS: "-DOGS_ADDRESS_SANITIZER=ON -DOGS_UNDEFINED_BEHAVIOR_SANITIZER=ON" UBSAN_OPTIONS: "print_stacktrace=1" LSAN_OPTIONS: "suppressions=$CI_PROJECT_DIR/scripts/test/leak_sanitizer.suppressions" image: diff --git a/scripts/ci/jobs/code-quality.yml b/scripts/ci/jobs/code-quality.yml index 59916cf3f8bb2567e15a94dd0ffc04ee0cae0653..a44664c53693f6294edac71417a3f0ce9422da5a 100644 --- a/scripts/ci/jobs/code-quality.yml +++ b/scripts/ci/jobs/code-quality.yml @@ -8,6 +8,7 @@ cppcheck: script: - > cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DOGS_USE_CONAN=OFF + -DOGS_USE_PYTHON=OFF -DOGS_BUILD_UTILS=OFF -DOGS_USE_UNITY_BUILDS=OFF -DOGS_USE_XDMF=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - bash cppcheck.sh artifacts: diff --git a/scripts/ci/jobs/container.yml b/scripts/ci/jobs/container.yml index 3d2465d5bcdfe271c16c1fce53003774bfb4746e..0ee94ee64f7127957cda058e691914f2512ba184 100644 --- a/scripts/ci/jobs/container.yml +++ b/scripts/ci/jobs/container.yml @@ -20,7 +20,7 @@ container: poetry run ogscm compiler.py ogs.py -B -C -R --ogs ../.. --build_args ' --progress=plain' --pm system --cvode --ccache - --cmake_args ' -DOGS_CPU_ARCHITECTURE=sandybridge -DBUILD_TESTING=OFF -DOGS_BUILD_UTILS=ON -DOGS_USE_PYTHON=ON' + --cmake_args ' -DOGS_CPU_ARCHITECTURE=sandybridge -DBUILD_TESTING=OFF' $DOCKER_TAG - > poetry run ogscm compiler.py mpi.py ogs.py -B -C -R --ogs ../.. diff --git a/scripts/cmake/ConanSetup.cmake b/scripts/cmake/ConanSetup.cmake index 838b21c1ad06b5e82e8b23b9628fb8966b4a616f..92182e4a01fe9cb9bf813bc85d1465cdf4738aad 100644 --- a/scripts/cmake/ConanSetup.cmake +++ b/scripts/cmake/ConanSetup.cmake @@ -3,7 +3,8 @@ if(NOT OGS_USE_CONAN) endif() string(TOLOWER ${OGS_USE_CONAN} OGS_USE_CONAN_lower) if(OGS_USE_CONAN_lower STREQUAL "auto" AND POETRY) - execute_process(COMMAND ${CMD_COMMAND} poetry add conan==${ogs.minimum_version.conan}) + execute_process(COMMAND ${CMD_COMMAND} poetry add conan==${ogs.minimum_version.conan} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) find_program(CONAN_CMD conan HINTS ${LOCAL_VIRTUALENV_BIN_DIRS} REQUIRED NO_DEFAULT_PATH ) diff --git a/scripts/cmake/PythonSetup.cmake b/scripts/cmake/PythonSetup.cmake index 60466a930b6ef5d89732fff6553c4ee402869392..7e2dbe63a86c635ccd6546866256439655e64449 100644 --- a/scripts/cmake/PythonSetup.cmake +++ b/scripts/cmake/PythonSetup.cmake @@ -1,18 +1,21 @@ -find_program(POETRY poetry) -if(POETRY) - configure_file(${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml - ${PROJECT_BINARY_DIR}/poetry.toml COPYONLY) - if(NOT EXISTS ${PROJECT_BINARY_DIR}/pyproject.toml) - configure_file(${PROJECT_SOURCE_DIR}/scripts/python/pyproject.in.toml - ${PROJECT_BINARY_DIR}/pyproject.toml) - endif() - if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) - execute_process(COMMAND ${CMD_COMMAND} poetry install) - endif() - set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) - if(MSVC) - set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) +if(OGS_USE_POETRY) + find_program(POETRY poetry) + if(POETRY) + configure_file(${PROJECT_SOURCE_DIR}/scripts/python/poetry.in.toml + ${PROJECT_BINARY_DIR}/poetry.toml COPYONLY) + if(NOT EXISTS ${PROJECT_BINARY_DIR}/pyproject.toml) + configure_file(${PROJECT_SOURCE_DIR}/scripts/python/pyproject.in.toml + ${PROJECT_BINARY_DIR}/pyproject.toml) + endif() + if(NOT EXISTS ${PROJECT_BINARY_DIR}/.venv) + execute_process(COMMAND ${CMD_COMMAND} poetry install + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + endif() + set(Python3_ROOT_DIR ${PROJECT_BINARY_DIR}/.venv) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/bin/python) + if(MSVC) + set(Python3_EXECUTABLE ${Python3_ROOT_DIR}/Scripts/python.exe) + endif() endif() endif() @@ -50,5 +53,6 @@ if(POETRY) ) endif() endif() - execute_process(COMMAND ${CMD_COMMAND} poetry add ${PYTHON_PACKAGES}) + execute_process(COMMAND ${CMD_COMMAND} poetry add ${PYTHON_PACKAGES} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) endif() diff --git a/scripts/env/eve/cli.sh b/scripts/env/eve/cli.sh index dfeee0cfa8ef602b9a23912cbe4f660412528736..19e453d8553073127fc4b5a14bb1f1f7a311d63e 100644 --- a/scripts/env/eve/cli.sh +++ b/scripts/env/eve/cli.sh @@ -8,10 +8,9 @@ fi module use /global/apps/modulefiles module load foss/2019b -module load CMake/3.15.3 +module load cmake/3.19.4-1 module load ninja module load git/2.23.0 -module load git-lfs/2.7.1 # Libraries module load boost/1.67.0-1 diff --git a/web/content/docs/devguide/advanced/build-with-ninja.md b/web/content/docs/devguide/advanced/build-with-ninja.md deleted file mode 100644 index 009433fbad9e9a0ef71c19f44492f4754655deea..0000000000000000000000000000000000000000 --- a/web/content/docs/devguide/advanced/build-with-ninja.md +++ /dev/null @@ -1,55 +0,0 @@ -+++ -date = "2018-02-26T11:00:13+01:00" -title = "Build with ninja" -author = "Lars Bilke" -weight = 1031 - -[menu] - [menu.devguide] - parent = "advanced" -+++ - -## Install ninja - -<div class='win'> - -Download *ninja.zip* from the [latest GitHub release](https://github.com/ninja-build/ninja/releases/latest). Unzip it and make sure that the directory containing the `ninja.exe` is the `PATH`-environment variable! - -</div> - -<div class='linux'> - -Install with your package manager: - -```bash -sudo apt-get install ninja-build -``` - -</div> - -<div class='mac'> - -Install via Homebrew: - -```bash -brew install ninja -``` - -</div> - -## Configure for ninja and build - -Run CMake with the ninja-generator: - -```bash -cmake ../source/dir -G Ninja -ninja -``` - -<div class='note'> - -### <i class="far fa-exclamation-triangle"></i> Visual Studio remarks - -When you configure with the Ninja generator you have to run CMake from the appropriate Visual Studio Command Prompt! From there you can both use `cmake` as well as `cmake-gui` which starts the GUI. In the GUI select the `Ninja` generator and leave the toggle `Use default native compilers` on. - -</div> diff --git a/web/content/docs/devguide/advanced/working-on-eve.md b/web/content/docs/devguide/advanced/working-on-eve.md index 3684a5d687e8fc0fdf884486e6b2af92f988ff84..66ba1d5f7427b19c880ae7c37225d431e4b93c0b 100644 --- a/web/content/docs/devguide/advanced/working-on-eve.md +++ b/web/content/docs/devguide/advanced/working-on-eve.md @@ -57,7 +57,7 @@ Generating Doxygen documentation: module load Doxygen/1.8.14 ``` -You can [build with Ninja]({{< ref "build-with-ninja" >}}): +You can build with Ninja: ```bash module load ninja/1.9.0 diff --git a/web/content/docs/devguide/getting-started/build-configuration.md b/web/content/docs/devguide/getting-started/build-configuration.md index 6a0bf1b1ee4b6189f07ff03c9011e2326b3e2f79..30e55e897c8e7236066a14e00389e595498e84fe 100644 --- a/web/content/docs/devguide/getting-started/build-configuration.md +++ b/web/content/docs/devguide/getting-started/build-configuration.md @@ -11,36 +11,53 @@ weight = 1004 ## Overview -To separate source code from generated files such as compiled libraries, executables, test outputs and IDE projects we create build-directories. They can be placed arbitrarily but should **not** be placed inside the source code. You can have as many build-directories as you like for e.g. different configurations but they will all use one source code directory. A typically directory structure: +Before compiling the developer has to choose a configuration of the software. OGS comes in lots of different flavours (e.g. serial / parallelized), can be build with optional features (e.g. with Python scripting support) or modules (e.g. MFront material models). -- `ogs-source-code` (or simply `ogs`) -- `build-release` -- `build-debug` -- `build-release-mpi` +To separate source code from generated files such as compiled libraries, executables, test outputs and IDE projects we create build-directories. They can be placed arbitrarily. You can have as many build-directories as you like for e.g. different configurations but they will all use one source code directory. A typically directory structure: -So just go ahead and create a build-directory along your source code directory. +- `ogs-source-code` (or simply `ogs`) + - `build/release` + - `build/debug` + - `build/release-petsc` +- `build` (can also be placed outside the source tree) ## Configure with CMake -For configuring a build the open source [CMake](http://www.cmake.org) tool is used. CMakeLists.txt files replace traditional Makefiles or IDE project files. The CMake tool is run inside the build-directory with a reference to the source code-directory of the project and user-chosen options. CMake then generates based on the chosen *Generator* either Makefiles or project files for IDE such as Visual Studio or Eclipse inside the build directory. Also all the compiled files will be generated in this directory. This keeps the actual source code clean from intermediate files which are generated from the source code. Nothing inside the build directory will ever be version controlled because its contents can be regenerated anytime from the source code. +For configuring a build the open source tool [CMake](http://www.cmake.org) is used. `CMakeLists.txt` files replace traditional Makefiles or IDE project files. -Because of the separation of the source code and all stuff that is generated as a part of the build process it is no problem to have several build configurations (e.g. a serial configuration and a parallelized MPI-enabled configuration) all referring to the same source code. +We provide CMake configuration presets defined in [CMakePresets.json](https://gitlab.opengeosys.org/ogs/ogs/-/blob/master/CMakePresets.json) for simple build configuration (**Note:** Requires CMake $\geq$ 3.19! Otherwise see [Configure manually](#option-configure-manually)). See the following table for commonly used presets: -When you want to start over with a new configuration simply delete the build-directory, create a new one and reconfigure. +### Available CMake presets -[See this]({{< ref "configuration-options" >}}) for a list of available options. +| | Ninja[^1] | Visual Studio | +| ------------- | ------------- | ---------------- | +| CLI Release | release | msvc-release | +| CLI Debug | debug | msvc-debug | +| GUI Release | release-gui | msvc-release-gui | +| GUI Debug | debug-gui | msvc-debug-gui | +| PETSc Release | release-petsc | - | +| PETSc Debug | debug-petsc | - | -<div class='win'> +[^1]: Requires the `ninja`-tool. See [install instructions]({{< ref "prerequisites.md#optional-install-ninja" >}}). -<div class='note'> +### Configure with a preset -### <i class="far fa-exclamation-triangle"></i> Supported Visual Studio Generators +In the source directory run `cmake`: -- `Visual Studio {{< dataFile "versions.minimum_version.msvc.number" >}} {{< dataFile "versions.minimum_version.msvc.year" >}}` +```bash +# Usage: cmake -S [path-to-source] --preset=[preset-name] +cmake -S . --preset=release +``` -</div> +This will create a build-directory in the source tree (`build/release`) with the default CMake options and the Release configuration. -</div> +Additionally you can pass any CMake variable or option with `-DVARIABLE_NAME=VALUE` (note the `-D` in front!) to the CMake command. You can also overwrite the generator with the `-G` parameter or the build-directory with the `-B` parameter (to see all available options just run `cmake --help`) + +Also all the compiled files will be generated in this directory. This keeps the actual source code clean from intermediate files which are generated from the source code. Nothing inside the build directory will ever be version controlled because its contents can be regenerated anytime from the source code. + +When you want to start over with a new configuration simply delete the build-directory, create a new one and reconfigure. + +[See this]({{< ref "configuration-options" >}}) for a list of commonly used available options. ### Note: Installation of required libraries @@ -48,63 +65,73 @@ It is preferred to use the Conan package manager to install required third-party Instead of using Conan you can optionally [install the required libraries manually]({{< ref "third-party-libraries.md" >}}) **before** running CMake. -<div class='win'> - <div class='note'> -#### <i class="far fa-exclamation-triangle"></i> Multi-configuration with Conan and Visual Studio +### User-defined presets -With Conan one build directory corresponds to one configuration. If you want to have e.g. a release and a debug build you need to create two build directories. This is nothing new new to Linux / GCC user but differs to Visual Studios default behavior having just one build-folder / project with different configurations. A typical Visual Studio setup with both Release and Debug configs would be initialized as follows: +You can create a `CMakeUserPresets.json` file in the root source directory with your own presets (this file is ignored by git): + +```json +{ + "version": 1, + "configurePresets": [ + { + "name": "my-release", + "inherits": "release", + "cacheVariables": { + "OGS_USE_POETRY": "OFF" + } + } + ] +} -```bash -[assuming you are at the same directory where the source code directory is located] -mkdir ogs-build && cd ogs-build -mkdir debug && cd debug -cmake ../../ogs -G "Visual Studio {{< dataFile "versions.minimum_version.msvc.number" >}} {{< dataFile "versions.minimum_version.msvc.year" >}}" -DCMAKE_BUILD_TYPE=Debug -cd .. && mkdir release && cd release -cmake ../../ogs -G "Visual Studio {{< dataFile "versions.minimum_version.msvc.number" >}} {{< dataFile "versions.minimum_version.msvc.year" >}}" -DCMAKE_BUILD_TYPE=Release ``` -`..\..\ogs` represents the relative path to the source code (please adapt if you have a different directory layout). +</div> -Please also note that in Visual Studio you have to choose the correct configuration (i.e. when opening the solution-file in the release-folder you have to switch the Visual Studio configuration to **Release**)! +<div class='win'> -</div> +<div class='note'> -</div> +### Windows notes: -## Option: Configure from the command line +#### <i class="far fa-check"></i> Ninja requirement: Use the Visual Studio command line -CMake can be run from the shell by invoking the cmake command inside a build directory. You can pass any CMake variable or option with `-DVARIABLE_NAME=VALUE` (note the `-D` in front!). You can also pass the generator you want to use (e.g. `Unix Makefiles` or `Visual Studio {{< dataFile "versions.minimum_version.msvc.number" >}} {{< dataFile "versions.minimum_version.msvc.year" >}}`-project files) with the `-G` parameter (to see all available generators just run `cmake --help`), although in most cases the appropriate generator will be chosen automatically. The last parameter to the CMake command is the path to the source code directory. A typical call would look like this: +To use the Ninja build tool you need to configure in the Visual Studio command line. In the Start menu under *Visual Studio {{< dataFile "versions.minimum_version.msvc.year" >}}* you find a application link to *x64 Native Tools Command Prompt for VS {{< dataFile "versions.minimum_version.msvc.year" >}}*. This starts a command line setup for Visual Studio 64-bit. Now you can use a Ninja preset: ```bash -cmake -G "Visual Studio {{< dataFile "versions.minimum_version.msvc.number" >}} {{< dataFile "versions.minimum_version.msvc.year" >}}" -DCMAKE_BUILD_TYPE=Release ../ogs +cmake -S . --preset=release ``` -CMake tries to autodetect your compiler so in most cases this should be enough: +#### <i class="far fa-exclamation-triangle"></i> Multi-configuration with Conan and Visual Studio + +With Conan one build directory corresponds to one configuration. If you want to have e.g. a release and a debug build you need to create two build directories. This is nothing new to Linux / GCC user but differs to Visual Studios default behavior having just one build-folder / project with different configurations. A typical Visual Studio setup with both Release and Debug configs would be initialized as follows: ```bash -cmake ../ogs +cmake -S . --preset=msvc-release +cmake -S . --preset=msvc-debug ``` -{{< asciinema url="https://asciinema.org/a/249004" >}} +Please also note that in Visual Studio you have to choose the correct configuration (i.e. when opening the solution-file in the release-folder you have to switch the Visual Studio configuration to **Release**)! -<div class='note'> +#### <i class="far fa-check"></i> Pro Tip: Use a better terminal application -### <i class="far fa-check"></i> Pro Tip: Use the Visual Studio command line +Use the [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701) for a better terminal experience. It offers modern terminal features such as multiple tabs and panes. -In the Start menu under *Visual Studio {{< dataFile "versions.minimum_version.msvc.year" >}}* you find a application link to *x64 Native Tools Command Prompt for VS {{< dataFile "versions.minimum_version.msvc.year" >}}*. This starts a command line setup for Visual Studio 64-bit. When you run CMake commands in this command line the correct generator will be picked up automatically: +</div> -```bash -cmake ../ogs -``` +</div> -This even allows for using [Ninja]({{< ref "build-with-ninja.md" >}}) as the build tool which can effectively utilize all CPU cores +## Option: Configure manually -### <i class="far fa-check"></i> Pro Tip 2: Use a better terminal application +If you cannot use CMake presets (e.g. when your CMake installation does not support it) manually create a build directory and run CMake from within with all required parameters, e.g: -Use the [Windows Terminal](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701) for a better terminal experience. It offers modern terminal features such as multiple tabs and panes. -</div> +```bash +# in ogs source-directory +mkdir -p build/release +cd build/release +cmake ../.. -G Ninja -DCMAKE_BUILD_TYPE=Release +``` ## Option: Configure with a visual tool @@ -116,10 +143,10 @@ CMake comes with a graphical tool called **cmake-gui**. You can find it in the * <div class='linux'> -A more convenient way of running cmake on the command line is to use the `ccmake` tool. This is a shell tool but with some graphical user interface. To use it just run `ccmake` inside your build directory with the path to the source code (and optionally the generator you want to use) as parameter: +A more convenient way of running cmake on the command line is to use the `ccmake` tool. This is a shell tool but with some graphical user interface. To use it just run `ccmake` instead of `cmake`: ```bash -ccmake ../ogs +ccmake -S . --preset=release ``` First press <kbd>C</kbd> to **Configure**. You are now presented the available configuration options. You can navigate in the list with the cursor keys and toggle / alter options with <kbd>Enter</kbd>. You may also press <kbd>T</kbd> to toggle (previously hidden) advanced options. Press <kbd>C</kbd> again until the **Generate**-option becomes visible. Press <kbd>G</kbd> to generate the project files and exit `ccmake`. diff --git a/web/content/docs/devguide/getting-started/build.md b/web/content/docs/devguide/getting-started/build.md index 446e167c75899592a645fcde3dee707ead978f3f..b8866543b598b82919e593320effb1edc0db8c78 100644 --- a/web/content/docs/devguide/getting-started/build.md +++ b/web/content/docs/devguide/getting-started/build.md @@ -15,7 +15,7 @@ weight = 1005 ### Step: Build with Visual Studio -Open the OGS.sln either by double-clicking it in the file browser or opening in Visual Studio via **File / Open / Project**. +Open the OGS.sln (in the build directory) either by double-clicking it in the file browser or opening in Visual Studio via **File / Open / Project**. On the project explorer right-click on **ogs** or **ogs-gui** and choose **Set as startup project**. Then press <kbd>F5</kbd> or click the green arrow to build and start the project. @@ -30,78 +30,20 @@ You can work normally in Visual Studio but remember that you have to make projec <div class='linux'> -### Option: Make +### With ninja -To build with the `make` tool on the shell go to your previously created build directory and type `make`: +To build with the `ninja` tool on the shell go to your previously configured build directory and type `ninja`: ```bash -cd build -make +cd build/release +ninja ``` - -To speedup the compilation process append the number of cores of your cpu to the make command. E.g. for 8 cores: - -```bash -make -j 8 -``` - -{{< asciinema url="https://asciinema.org/a/249005" preload="1" >}} - -### Option: Eclipse - -To let CMake generate the Eclipse project files change the generator argument to the CMake run: - -```bash -cmake [your configuration options] -G"Eclipse CDT4 - Unix Makefiles" ../sources -``` - -Or with ccmake - -```bash -ccmake -G"Eclipse CDT4 - Unix Makefiles" ../sources -``` - -Start the Eclipse ide. From the menu choose **File / Import**. In the import dialog choose **General / Existing projects into workspace** and click **Next**. In **Select root directory** select your build directory and make sure that **Copy project into workspace** is unchecked. Click **Finish**. </div> <div class='mac'> -### Option: Make - -To build with the `make` tool on the shell go to your previously created build directory and type `make`: - -```bash -cd build -make -``` - -To speedup the compilation process append the number of cores of your cpu to the make command. E.g. for 8 cores: - -```bash -make -j 8 -``` - -### Option: Xcode - -To let CMake generate the Xcode project files change the generator argument on the CMake run: - -```bash -cmake [your configuration options] -G Xcode ../sources -``` - -Or with ccmake - -```bash -ccmake -G Xcode ../sources -``` - -Then load the generated project file by either clicking the **OGS.xcodeproj** or via - -```bash -open OGS.xcodeproj -``` +See Linux-tab! -In Xcode choose `ogs` or `ogs-gui` from the drop-down menu on the top right and then hit the Run-button. </div> ## Waiting diff --git a/web/content/docs/devguide/getting-started/prerequisites.md b/web/content/docs/devguide/getting-started/prerequisites.md index 2b08122f69bdddd85849527d82f77c37537c9090..2c4667ed5ccc68df4a8fbb1b36899b36e38166e9 100644 --- a/web/content/docs/devguide/getting-started/prerequisites.md +++ b/web/content/docs/devguide/getting-started/prerequisites.md @@ -18,6 +18,7 @@ The minimum prerequisites to build OGS are: - CMake (build configuration tool, at least version {{< dataFile "versions.minimum_version.cmake" >}}) - A compiler with [C++20](http://en.wikipedia.org/wiki/C%2B%2B20)-support - [Conan package manager](https://www.conan.io/) (at least version {{< dataFile "versions.minimum_version.conan" >}}) **OR** install [required libraries]({{< ref "third-party-libraries.md" >}}) manually (for advanced users only!) +- *Optional (but recommended)*: [Ninja](https://ninja-build.org) build tool <div class='note'> @@ -202,12 +203,11 @@ git config --global http.proxy http://yourproxy.example.com <div class='win'> -- [Download the Python 3 installer](https://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64-webinstall.exe) +- [Download the Python 3 installer](https://www.python.org/ftp/python/3.9.1/python-3.9.1-amd64.exe) - Install with the following options - Check *Add Python 3.X to PATH* - *Customize installation* - Make sure to have `pip` enabled (you may uncheck *Documentation*, *tcl/tk*, *Python test suite*) - - You may check *Install for all users* - Check *Add Python to environment variables*! </div> @@ -267,7 +267,7 @@ Install Conan (>= {{< dataFile "versions.minimum_version.conan" >}}) with Python pip3 install --user conan ``` -This installed `conan` to `.local/bin` (or `C:\Users\[username]\AppData\Roaming\Python\Python37\Scripts` on Windows) in your home directory. Make sure to have this directory in your `PATH`! +This installed `conan` to `.local/bin` (or `C:\Users\[username]\AppData\Roaming\Python\Python39\Scripts` on Windows) in your home directory. Make sure to have this directory in your `PATH`! Check on a newly opened command line if Conan was installed successfully: @@ -281,3 +281,15 @@ Conan version {{< dataFile "versions.minimum_version.conan" >}} **Advanced usage:** You can also have Conan auto-installed when using the CMake-option `OGS_USE_CONAN=auto`. See the page on [Python environment]({{< ref "python-env.md" >}}) for details. </div> + +## Optional: Install Ninja + +We recommend [`ninja`](https://ninja-build.org) as a cross-platform build tool (`make`-replacement). + +Install Ninja with Python's pip: + +```bash +pip3 install --user ninja +``` + +Make sure that `ninja` is in the path afterwards. See Conan install instructions above.