diff --git a/.editorconfig b/.editorconfig index ea74e14a8..8a9c9f15b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,23 +1,18 @@ # EditorConfig is awesome: https://EditorConfig.org # top-most EditorConfig file root = true [*] end_of_line = lf insert_final_newline = true max_line_length = 80 - - -[*.{py,cc,hh,cmake,tcc}] -charset = utf-8 -indent_style = space -indent_size = 4 - -[CMakeLists.txt] charset = utf-8 indent_style = space indent_size = 2 +[*.py] +indent_size = 4 + [*.tcc] file_type_emacs = c++ diff --git a/.gitignore b/.gitignore index 7dd72dc48..d3ad89d2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,27 @@ build* .dir-locals.el TAGS third-party/*/ !third-party/cmake/* !third-party/akantu-iterators !third-party/iohelper *~ release .*.swp *.tar.gz *.tgz *.tbz *.tar.bz2 .idea __pycache__ .mailmap paraview/* *.vtu *.pvd *.pvtu *.vtk compile_commands.json .clangd .iwyu.imp .cache +setup.cfg diff --git a/.gitlab-ci.d/code-quality.yaml b/.gitlab-ci.d/code-quality.yaml new file mode 100644 index 000000000..5b5836d84 --- /dev/null +++ b/.gitlab-ci.d/code-quality.yaml @@ -0,0 +1,63 @@ +.code_quality_common: + stage: code_quality + allow_failure: true + rules: + - if: '$CODE_QUALITY_DISABLED' + when: never + - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + +.code_quality_gitlab_template: + extends: + - .code_quality_common + image: docker:19.03.12 + allow_failure: true + services: + - docker:19.03.12-dind + variables: + DOCKER_DRIVER: overlay2 + DOCKER_TLS_CERTDIR: "" + CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24" + needs: [] + script: + - export SOURCE_CODE=$PWD + - | + if ! docker info &>/dev/null; then + if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then + export DOCKER_HOST='tcp://localhost:2375' + fi + fi + - | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage + function propagate_env_vars() { + CURRENT_ENV=$(printenv) + + for VAR_NAME; do + echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME " + done + } + - docker pull --quiet "$CODE_QUALITY_IMAGE" + - | + docker run --rm \ + $(propagate_env_vars \ + SOURCE_CODE \ + TIMEOUT_SECONDS \ + CODECLIMATE_DEBUG \ + CODECLIMATE_DEV \ + REPORT_STDOUT \ + REPORT_FORMAT \ + ENGINE_MEMORY_LIMIT_BYTES \ + CODECLIMATE_PREFIX \ + ) \ + --volume "$PWD":/code \ + --volume /var/run/docker.sock:/var/run/docker.sock \ + "$CODE_QUALITY_IMAGE" /code + +.clang_tools: + extends: + - .code_quality_common + - .debian_testing_clang + before_script: + - if [ 'x${CI_MERGE_REQUEST_ID}' != 'x' ]; then + - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME + - git diff --name-only $CI_COMMIT_SHA $CI_MERGE_REQUEST_TARGET_BRANCH_NAME > file_list + - FILE_LIST_ARG='-f file_list' + - fi diff --git a/.gitlab-ci.d/images.yaml b/.gitlab-ci.d/images.yaml new file mode 100644 index 000000000..6d5d70dbf --- /dev/null +++ b/.gitlab-ci.d/images.yaml @@ -0,0 +1,109 @@ +.docker_build: + image: "docker:19.03.11" + stage: .pre + services: + - docker:19.03.11-dind + variables: + # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - cd test/ci/${IMAGE_NAME}/ + - docker build -t registry.gitlab.com/akantu/akantu/${IMAGE_NAME} . + - docker push registry.gitlab.com/akantu/akantu/${IMAGE_NAME} + rules: + - changes: + - test/ci/${IMAGE_NAME}/* + +# ------------------------------------------------------------------------------ +.cache_build: + variables: + CCACHE_BASEDIR: ${CI_PROJECT_DIR}/ + CCACHE_DIR: ${CI_PROJECT_DIR}/.ccache + CCACHE_MAXSIZE: 1Gi + cache: + key: ${output}_${BUILD_TYPE} + policy: pull-push + paths: + - .ccache/ + - third-party/google-test + - third-party/pybind11 + before_script: + - ccache --zero-stats || true + after_script: + - ccache --show-stats || true + +# ------------------------------------------------------------------------------ +.image_debian_testing: + image: registry.gitlab.com/akantu/akantu/debian:testing + +.image_ubuntu_lts: + image: registry.gitlab.com/akantu/akantu/ubuntu:lts + +.image_manylinux: + image: registry.gitlab.com/akantu/akantu/manylinux:2010_x86_64 + +# ------------------------------------------------------------------------------ +.compiler_gcc: + variables: + CC: /usr/lib/ccache/gcc + CXX: /usr/lib/ccache/g++ + FC: gfortran + GCOV_EXECUTABLE: gcov + +.compiler_clang: + variables: + CC: /usr/lib/ccache/clang + CXX: /usr/lib/ccache/clang++ + FC: gfortran + GCOV_EXECUTABLE: llvm-cov gcov + +.build_coverage: + variables: + TEST_EXAMPLES: "FALSE" + BUILD_TYPE: "Coverage" + +.build_release: + variables: + TEST_EXAMPLES: "TRUE" + BUILD_TYPE: "Release" + +.build_valgrind: + variables: + TEST_EXAMPLES: "FALSE" + BUILD_TYPE: "Valgrind" + +# ------------------------------------------------------------------------------ +.debian_testing_gcc: + variables: + output: debian_testing_gcc + extends: + - .compiler_gcc + - .image_debian_testing + - .cache_build + +.debian_testing_clang: + variables: + output: debian_testing_clang + extends: + - .compiler_clang + - .image_debian_testing + - .cache_build + +.ubuntu_lts_gcc: + variables: + output: ubuntu_lts_gcc + extends: + - .compiler_gcc + - .image_ubuntu_lts + - .cache_build + +.manylinux_2010_x64_gcc: + variables: + output: manylinux_2010_x64_gcc + extends: + - .compiler_gcc + - .image_manylinux + - .cache_build diff --git a/.gitlab-ci.d/templates.yaml b/.gitlab-ci.d/templates.yaml new file mode 100644 index 000000000..e507a182c --- /dev/null +++ b/.gitlab-ci.d/templates.yaml @@ -0,0 +1,133 @@ +# Configuration template +.configure: + stage: configure + except: + - tags + variables: + BLA_VENDOR: "Generic" + CMAKE_GENERATOR: "Unix Makefiles" + # CMAKE_GENERATOR: 'Ninja' + script: + # Create the build folder + - cmake -E make_directory build + - cd build + + # Configure the project + - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE + -DAKANTU_IMPLICIT:BOOL=TRUE + -DAKANTU_PARALLEL:BOOL=TRUE + -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE + -DAKANTU_HEAT_TRANSFER:BOOL=TRUE + -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE + -DAKANTU_PHASE_FIELD:BOOL=TRUE + -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE + -DAKANTU_CONTACT_MECHANICS:BOOL=TRUE + -DAKANTU_EXAMPLES:BOOL=TRUE + -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE + -DAKANTU_TESTS:BOOL=TRUE + -DAKANTU_RUN_IN_DOCKER:BOOL=TRUE + -DAKANTU_TEST_EXAMPLES:BOOL=${TEST_EXAMPLES} + -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} + -G "${CMAKE_GENERATOR}" .. + + # Copie the compile commands for the code quality + - if [ -e compile_commands.json ]; then + - cp compile_commands.json .. + - fi + artifacts: + when: on_success + paths: + - build + - compile_commands.json + expire_in: 10h + +# Build the libraries +.build_libs: + stage: build_libs + script: + - cmake --build build --target akantu -j1 + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + - cmake --build build --target py11_akantu -j1 + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + artifacts: + when: on_success + paths: + - build/ + - build-${output}-err.log + - compile_commands.json + expire_in: 10h + +# build the tests +.build_tests: + stage: build_tests + script: + - cmake --build build -j1 + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + artifacts: + when: on_success + paths: + - build/ + - build-${output}-err.log + - compile_commands.json + exclude: + - build/**/*.o + expire_in: 10h + +# Build all +.build_all: + stage: build_libs + script: + - cmake --build build/src + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + - cmake --build build/python + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + - cmake --build build/test/ + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + - cmake --build build/examples + > >(tee -a build-${output}-out.log) + 2> >(tee -a build-${output}-err.log >&2) + artifacts: + when: on_success + paths: + - build/ + - build-${output}-err.log + - compile_commands.json + exclude: + - build/**/*.o + expire_in: 10h + +# Run the tests +.tests: + stage: test + script: + - cd build + - ctest -T test --output-on-failure --no-compress-output --timeout 1800 + after_script: + - cd build + - tag=$(head -n 1 < Testing/TAG) + - if [ -e Testing/${tag}/Test.xml ]; then + - xsltproc -o ./juint.xml ${CI_PROJECT_DIR}/test/ci/ctest2junit.xsl Testing/${tag}/Test.xml; + - fi + - if [ ${CMAKE_BUILD_TYPE} = "Coverage" ]; then + - gcovr --xml + --gcov-executable "${GCOV_EXECUTABLE}" + --output coverage.xml + --object-directory ${CI_PROJECT_DIR}/build + --root ${CI_PROJECT_DIR} -s || true + - fi + artifacts: + when: always + paths: + - build/juint.xml + - build/coverage.xml + reports: + junit: + - build/juint.xml + cobertura: + - build/coverage.xml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4dfb06087..cb7d307e1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,450 +1,375 @@ stages: - configure - - build + - build_libs + - build_tests - test + - code_quality - deploy -.docker_build: - image: 'docker:19.03.11' - stage: .pre - services: - - docker:19.03.11-dind - variables: - # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_CERTDIR: "/certs" - before_script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - script: - - cd test/ci/${IMAGE_NAME}/ - - docker build -t registry.gitlab.com/akantu/akantu/${IMAGE_NAME} . - - docker push registry.gitlab.com/akantu/akantu/${IMAGE_NAME} +include: + local: '.gitlab-ci.d/*.yaml' +#------------------------------------------------------------------------------- +# Rebuilding the docker images if needed +#------------------------------------------------------------------------------- docker build:debian-testing: variables: IMAGE_NAME: debian:testing extends: .docker_build - rules: - - changes: - - test/ci/debian:testing/Dockerfile docker build:ubuntu-lts: variables: IMAGE_NAME: ubuntu:lts extends: .docker_build - rules: - - changes: - - test/ci/ubuntu:lts/Dockerfile - -.configure: - stage: configure - except: - - tags - variables: - BLA_VENDOR: 'Generic' - script: - - cmake -E make_directory build - - cd build - - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE - -DAKANTU_IMPLICIT:BOOL=TRUE - -DAKANTU_PARALLEL:BOOL=TRUE - -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE - -DAKANTU_HEAT_TRANSFER:BOOL=TRUE - -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE - -DAKANTU_PHASE_FIELD:BOOL=TRUE - -DAKANTU_PYTHON_INTERFACE:BOOL=TRUE - -DAKANTU_CONTACT_MECHANICS:BOOL=TRUE - -DAKANTU_EXAMPLES:BOOL=TRUE - -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE - -DAKANTU_TESTS:BOOL=TRUE - -DAKANTU_RUN_IN_DOCKER:BOOL=TRUE - -DAKANTU_TEST_EXAMPLES:BOOL=${TEST_EXAMPLES} - -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} .. - - - if [ -e compile_commands.json ]; then - - cp compile_commands.json .. - - fi - artifacts: - when: on_success - paths: - - build - - compile_commands.json - expire_in: 10h - -.build: - stage: build - script: - - cmake --build build/src > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - - cmake --build build/python > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - - cmake --build build/test/ > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - - cmake --build build/examples > >(tee -a build-${output}-out.log) 2> >(tee -a build-${output}-err.log >&2) - artifacts: - when: on_success - paths: - - build/ - - build-${output}-err.log - - compile_commands.json - exclude: - - build/**/*.o - expire_in: 10h - -.tests: - stage: test - script: - - cd build - - ctest -T test --output-on-failure --no-compress-output --timeout 1800 - after_script: - - cd build - - tag=$(head -n 1 < Testing/TAG) - - if [ -e Testing/${tag}/Test.xml ]; then - - xsltproc -o ./juint.xml ${CI_PROJECT_DIR}/test/ci/ctest2junit.xsl Testing/${tag}/Test.xml; - - fi - - if [ "${BUILD_TYPE}" = "Coverage" ]; then - - gcovr --xml - --gcov-executable "${GCOV_EXECUTABLE}" - --output coverage.xml - --object-directory ${CI_PROJECT_DIR}/build - --root ${CI_PROJECT_DIR} -s || true - - fi - artifacts: - when: always - paths: - - build/juint.xml - - build/coverage.xml - reports: - junit: - - build/juint.xml - cobertura: - - build/coverage.xml -# ------------------------------------------------------------------------------ -.cache_build: - variables: - CCACHE_BASEDIR: ${CI_PROJECT_DIR}/ - CCACHE_DIR: ${CI_PROJECT_DIR}/.ccache - #CCACHE_NOHASHDIR: 1 - #CCACHE_COMPILERCHECK: content - cache: - key: ${output}_${BUILD_TYPE} - policy: pull-push - paths: - - .ccache/ - - third-party/google-test - - third-party/pybind11 - before_script: - - ccache --zero-stats || true - after_script: - - ccache --show-stats || true - -# ------------------------------------------------------------------------------ -.image_debian_testing: - image: registry.gitlab.com/akantu/akantu/debian:testing - -.image_ubuntu_lts: - image: registry.gitlab.com/akantu/akantu/ubuntu:lts - -# ------------------------------------------------------------------------------ -.compiler_gcc: +docker build:manylinux: variables: - CC: /usr/lib/ccache/gcc - CXX: /usr/lib/ccache/g++ - FC: gfortran - GCOV_EXECUTABLE: gcov - -.compiler_clang: - variables: - CC: /usr/lib/ccache/clang - CXX: /usr/lib/ccache/clang++ - FC: gfortran - GCOV_EXECUTABLE: llvm-cov gcov - -.build_coverage: - variables: - TEST_EXAMPLES: 'FALSE' - BUILD_TYPE: 'Coverage' - -.build_release: - variables: - TEST_EXAMPLES: 'TRUE' - BUILD_TYPE: 'Release' - -.build_valgrind: - variables: - TEST_EXAMPLES: 'FALSE' - BUILD_TYPE: 'Valgrind' - -# ------------------------------------------------------------------------------ -.debian_testing_gcc: - variables: - output: debian_testing_gcc - extends: - - .compiler_gcc - - .image_debian_testing - - .cache_build - -.debian_testing_clang: - variables: - output: debian_testing_clang - extends: - - .compiler_clang - - .image_debian_testing - - .cache_build - -.ubuntu_lts_gcc: - variables: - output: ubuntu_lts_gcc - extends: - - .compiler_gcc - - .image_ubuntu_lts - - .cache_build + IMAGE_NAME: manylinux:2010_x86_64 + extends: .docker_build # ------------------------------------------------------------------------------ +# Debian testing compiled with GCC # ------------------------------------------------------------------------------ configure:debian_testing_gcc: extends: - .debian_testing_gcc - .build_coverage - .configure build:debian_testing_gcc: extends: - .debian_testing_gcc - .build_coverage - - .build + - .build_all needs: - job: configure:debian_testing_gcc +#build_libs:debian_testing_gcc: +# extends: +# - .debian_testing_gcc +# - .build_coverage +# - .build_libs +# needs: +# - job: configure:debian_testing_gcc + +#build_tests:debian_testing_gcc: +# extends: +# - .debian_testing_gcc +# - .build_coverage +# - .build_tests +# needs: +# - job: build_libs:debian_testing_gcc + test:debian_testing_gcc: extends: - .debian_testing_gcc - .build_coverage - .tests - coverage: '/^lines: (\d+\.\d+\%)/' needs: - job: build:debian_testing_gcc # ------------------------------------------------------------------------------ -configure:debian_testing_gcc_valgrind: - extends: - - .debian_testing_gcc - - .build_valgrind - - .configure - -build:debian_testing_gcc_valgrind: - extends: - - .debian_testing_gcc - - .build_valgrind - - .build - needs: - - job: configure:debian_testing_gcc_valgrind - -test:debian_testing_gcc_valgrind: - extends: - - .debian_testing_gcc - - .build_valgrind - - .tests - needs: - - job: build:debian_testing_gcc_valgrind - +# Debian testing compiled with Clang # ------------------------------------------------------------------------------ configure:debian_testing_clang: extends: - .debian_testing_clang - .build_coverage - .configure build:debian_testing_clang: extends: - .debian_testing_clang - .build_coverage - - .build + - .build_all needs: - job: configure:debian_testing_clang +#build_libs:debian_testing_clang: +# extends: +# - .debian_testing_clang +# - .build_coverage +# - .build_libs +# needs: +# - job: configure:debian_testing_clang + +#build_tests:debian_testing_clang: +# extends: +# - .debian_testing_clang +# - .build_coverage +# - .build_tests +# needs: +# - job: build_libs:debian_testing_clang + test:debian_testing_clang: extends: - .debian_testing_clang - .build_coverage - .tests coverage: '/^lines: (\d+\.\d+\%)/' needs: - job: build:debian_testing_clang +# ------------------------------------------------------------------------------ +# Ubuntu LTS compiled with GCC # ------------------------------------------------------------------------------ configure:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - .configure build:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - - .build + - .build_all needs: - job: configure:ubuntu_lts_gcc test:ubuntu_lts_gcc: extends: - .ubuntu_lts_gcc - .build_release - .tests needs: - job: build:ubuntu_lts_gcc # ------------------------------------------------------------------------------ -cq:code_quality: - stage: test - image: docker:19.03.12 - allow_failure: true - services: - - docker:19.03.12-dind - variables: - DOCKER_DRIVER: overlay2 - DOCKER_TLS_CERTDIR: "" - CODE_QUALITY_IMAGE: "registry.gitlab.com/gitlab-org/ci-cd/codequality:0.85.24" - needs: [] +# Debian testing compiled with GCC tested with valgrind +# ------------------------------------------------------------------------------ +configure:ubuntu_lts_gcc_valgrind: + extends: + - .ubuntu_lts_gcc + - .build_valgrind + - .configure + +build:ubuntu_lts_gcc_valgrind: + extends: + - .ubuntu_lts_gcc + - .build_valgrind + - .build_all + needs: + - job: configure:ubuntu_lts_gcc_valgrind + +test:ubuntu_lts_gcc_valgrind: + extends: + - .ubuntu_lts_gcc + - .build_valgrind + - .tests + needs: + - job: build:ubuntu_lts_gcc_valgrind + +# ------------------------------------------------------------------------------ +# Manylinux to build python packages +# ------------------------------------------------------------------------------ +configure:python_package: + stage: configure + extends: + - .manylinux_2010_x64_gcc + - .build_release script: - - export SOURCE_CODE=$PWD - - | - if ! docker info &>/dev/null; then - if [ -z "$DOCKER_HOST" -a "$KUBERNETES_PORT" ]; then - export DOCKER_HOST='tcp://localhost:2375' - fi - fi - - | # this is required to avoid undesirable reset of Docker image ENV variables being set on build stage - function propagate_env_vars() { - CURRENT_ENV=$(printenv) - - for VAR_NAME; do - echo $CURRENT_ENV | grep "${VAR_NAME}=" > /dev/null && echo "--env $VAR_NAME " - done - } - - docker pull --quiet "$CODE_QUALITY_IMAGE" - - | - docker run --rm \ - $(propagate_env_vars \ - SOURCE_CODE \ - TIMEOUT_SECONDS \ - CODECLIMATE_DEBUG \ - CODECLIMATE_DEV \ - REPORT_STDOUT \ - REPORT_FORMAT \ - ENGINE_MEMORY_LIMIT_BYTES \ - CODECLIMATE_PREFIX \ - ) \ - --volume "$PWD":/code \ - --volume /var/run/docker.sock:/var/run/docker.sock \ - "$CODE_QUALITY_IMAGE" /code + # create the build folder + - cmake -E make_directory build + - cd build + + # Variables for cmake + - export CMAKE_PREFIX_PATH=/softs/view + - export BOOST_ROOT=/softs/view + + # Configure in sequential and without tests or examples + - cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE + -DAKANTU_IMPLICIT:BOOL=TRUE + -DAKANTU_PARALLEL:BOOL=FALSE + -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE + -DAKANTU_HEAT_TRANSFER:BOOL=TRUE + -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE + -DAKANTU_PHASE_FIELD:BOOL=TRUE + -DAKANTU_PYTHON_INTERFACE:BOOL=FALSE + -DAKANTU_CONTACT_MECHANICS:BOOL=TRUE + -DAKANTU_EXAMPLES:BOOL=FALSE + -DAKANTU_TESTS:BOOL=FALSE + -DMUMPS_DETECT_DEBUG:BOOL=TRUE + -DCMAKE_INSTALL_PREFIX:PATH=${CI_PROJECT_DIR}/install + -DCMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} .. artifacts: + when: on_success paths: - - gl-code-quality-report.json - expire_in: 1 week + - build/ + expire_in: 10h + +build_akantu:python_package: + extends: + - .build_libs + - .build_release + - .manylinux_2010_x64_gcc + script: + stage: build_libs + script: + - cmake --build build --target akantu -j1 + - cmake --install build + artifacts: + when: on_success + paths: + - install/ + expire_in: 10h needs: - - job: build:debian_testing_clang - rules: - - if: '$CODE_QUALITY_DISABLED' - when: never - - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + - job: configure:python_package + +build_pip:python_package: + stage: build_tests + extends: + - .build_release + - .manylinux_2010_x64_gcc + script: + - export CI_AKANTU_INSTALL_PREFIX=${CI_PROJECT_DIR}/install + - export CMAKE_PREFIX_PATH=/softs/view:${CI_AKANTU_INSTALL_PREFIX} + - test/ci/make-wheels.sh + needs: + - job: build_akantu:python_package + artifacts: + when: on_success + paths: + - wheelhouse + expire_in: 10h -.clang_tools: +test:python_package: stage: test + image: python:3.8 + needs: + - job: build_pip:python_package + script: + - pip install akantu -f wheelhouse + - python -c "import akantu" + - cd examples/python/dynamics/ + - apt update && apt install -y gmsh + - gmsh -2 bar.geo + - python ./dynamics.py + +package:python_gitlab: + stage: deploy + image: python:latest + script: + - pip install twine + - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token + python3 -m twine upload + --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi + wheelhouse/* + needs: + - job: build_pip:python_package + only: + - master + +package:python_pypi: + stage: deploy + image: python:latest + script: + - pip install twine + - TWINE_PASSWORD=${PYPI_TOKEN} TWINE_USERNAME=__token__ + python3 -m twine upload --verbose wheelhouse/* + needs: + - job: build_pip:python_package + only: + - tags + +# ------------------------------------------------------------------------------ +# Code Quality +# ------------------------------------------------------------------------------ +cq:code_quality: extends: - - .debian_testing_clang - before_script: - - if [ 'x${CI_MERGE_REQUEST_ID}' != 'x' ]; then - - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME - - git diff --name-only $CI_COMMIT_SHA $CI_MERGE_REQUEST_TARGET_BRANCH_NAME > file_list - - FILE_LIST_ARG='-f file_list' - - fi + - .code_quality_gitlab_template needs: - job: build:debian_testing_clang - allow_failure: true - rules: - - if: '$CODE_QUALITY_DISABLED' - when: never - - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH' + artifacts: + paths: + - gl-code-quality-report.json cq:clang_tidy: extends: - .clang_tools script: - test/ci/scripts/cq -x third-party -x extra-packages -x pybind11 -x test ${FILE_LIST_ARG} clang-tidy -p ${CI_PROJECT_DIR}/build > gl-clang-tidy-report.json + needs: + - job: build:debian_testing_clang artifacts: paths: - gl-clang-tidy-report.json cq:clang_format: extends: - .clang_tools script: - test/ci/scripts/cq -x third-party -x extra-packages clang-format -p ${CI_PROJECT_DIR}/build > gl-clang-format-report.json + needs: + - job: build:debian_testing_clang artifacts: paths: - gl-clang-format-report.json cq:compilation_warnings: - stage: test + stage: code_quality image: python:latest script: - pip install warning-parser termcolor Click - ls build-*-err.log - test/ci/scripts/cq -x third-party -x extra-packages warnings build-*-err.log > gl-warnings-report.json needs: - job: build:debian_testing_clang - job: build:debian_testing_gcc - job: build:ubuntu_lts_gcc artifacts: paths: - gl-warnings-report.json cq:merge_code_quality: stage: deploy extends: - .debian_testing_clang script: - jq -Ms '[.[][]]' gl-*-report.json | tee gl-codequality.json | jq -C needs: - job: cq:code_quality - job: cq:clang_tidy - job: cq:clang_format - job: cq:compilation_warnings artifacts: paths: - gl-codequality.json artifacts: reports: codequality: [gl-codequality.json] + +# ------------------------------------------------------------------------------ +# Deploy pages # ------------------------------------------------------------------------------ pages: stage: deploy extends: - .debian_testing_gcc script: - cd build - cmake -DAKANTU_DOCUMENTATION=ON .. - cmake --build . -t sphinx-doc - mv doc/dev-doc/html ../public needs: - job: build:debian_testing_gcc artifacts: paths: - public only: - master diff --git a/.pypirc b/.pypirc new file mode 100644 index 000000000..c4a4eb29a --- /dev/null +++ b/.pypirc @@ -0,0 +1,13 @@ +[distutils] +index-servers = + gitlab + pypi + +[gitlab] +repository = https://gitlab.com/api/v4/projects/${env.CI_PROJECT_ID}/packages/pypi +username = gitlab-ci-token +password = ${env.CI_JOB_TOKEN} + +[pypi] +username = __token__ +password = ${env.pypi_token} diff --git a/CMakeLists.txt b/CMakeLists.txt index 41770fc4f..7ca64da1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,202 +1,219 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 # @date last modification: Sat Mar 13 2021 # # @brief main configuration file # # # @section LICENSE # # Copyright (©) 2010-2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with Akantu. If not, see . # # @section DESCRIPTION #------------------------------------------------------------------------------- # _ _ # | | | | # __ _| | ____ _ _ __ | |_ _ _ # / _` | |/ / _` | '_ \| __| | | | # | (_| | < (_| | | | | |_| |_| | # \__,_|_|\_\__,_|_| |_|\__|\__,_| # #=============================================================================== #=============================================================================== # CMake Project #=============================================================================== cmake_minimum_required(VERSION 3.5.1) # add this options before PROJECT keyword set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) if(CMAKE_VERSION VERSION_GREATER 3.12) cmake_policy(SET CMP0074 NEW) endif() set(AKANTU_COPYRIGHT "2010-2021, EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)") set(AKANTU_MAINTAINER "Nicolas Richart") set(AKANTU_HOMEPAGE_URL "https://akantu.ch") if(CMAKE_VERSION VERSION_GREATER 3.12) project(Akantu HOMEPAGE_URL "https://akantu.ch") else() project(Akantu) endif() enable_language(CXX) #=============================================================================== # Misc. config for cmake #=============================================================================== set(AKANTU_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules") -set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation" FORCE) mark_as_advanced(BUILD_SHARED_LIBS) if(NOT AKANTU_TARGETS_EXPORT) set(AKANTU_TARGETS_EXPORT AkantuTargets) endif() include(CMakeVersionGenerator) include(CMakePackagesSystem) include(CMakeFlagsHandling) include(AkantuPackagesSystem) include(AkantuMacros) include(AkantuCleaning) #cmake_activate_debug_message() include(GNUInstallDirs) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) #=============================================================================== # Version Number #=============================================================================== # AKANTU version number. define_project_version() +if(NOT AKANTU_BYPASS_AKANTU_TARGET) + configure_file("cmake/akantu_version.py.in" + "${PROJECT_BINARY_DIR}/akantu_version.py" + @ONLY) +endif() #=============================================================================== # Options #=============================================================================== option(AKANTU_EXAMPLES "Activate examples" OFF) option(AKANTU_TESTS "Activate tests" OFF) +option(AKANTU_SHARED "Build Akantu as a shared library" ON) +option(AKANTU_POSITION_INDEPENDENT "Build with -fPIC when static" ON) option(AKANTU_RUN_IN_DOCKER "Set the approriate flage tu run in docker" OFF) set(AKANTU_PREFERRED_PYTHON_VERSION 3 CACHE STRING "Preferred version for python related things") -mark_as_advanced(AKANTU_PREFERRED_PYTHON_VERSION AKANTU_RUN_IN_DOCKER) +mark_as_advanced( + AKANTU_PREFERRED_PYTHON_VERSION + AKANTU_RUN_IN_DOCKER + AKANTU_POSITION_INDEPENDENT + AKANTU_SHARED + ) + +if (AKANTU_SHARED) + set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") +else() + set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries.") + set(CMAKE_POSITION_INDEPENDENT_CODE ON) +endif() + include(AkantuExtraCompilationProfiles) #=============================================================================== # Dependencies #=============================================================================== declare_akantu_types() package_list_packages(${PROJECT_SOURCE_DIR}/packages EXTRA_PACKAGES_FOLDER ${PROJECT_SOURCE_DIR}/extra_packages NO_AUTO_COMPILE_FLAGS) -## meta option \todo better way to do it when multiple package give enable the -## same feature -if(AKANTU_SCOTCH) - set(AKANTU_PARTITIONER ON) -else() - set(AKANTU_PARTITIONER OFF) -endif() - -if(AKANTU_MUMPS) - set(AKANTU_SOLVER ON) -else() - set(AKANTU_SOLVER OFF) -endif() - #=============================================================================== # Akantu library #=============================================================================== -add_subdirectory(src) +if (NOT AKANTU_BYPASS_AKANTU_TARGET) + add_subdirectory(src) +else() + find_package(Akantu REQUIRED) + if (Akantu_FOUND) + get_target_property(_lib akantu INTERFACE_LINK_LIBRARIES) + message(STATUS "Found Akantu: ${_lib} (found version ${AKANTU_VERSION})") + endif() +endif() #=============================================================================== # Documentation #=============================================================================== if(AKANTU_DOCUMENTATION OR AKANTU_DOCUMENTATION_MANUAL) add_subdirectory(doc) else() set(AKANTU_DOC_EXCLUDE_FILES "${PROJECT_SOURCE_DIR}/doc/manual" CACHE INTERNAL "") endif() #=============================================================================== # Python interface #=============================================================================== package_is_activated(python_interface _python_act) if(_python_act) + include(AkantuNeedPybind11) if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") set(AKANTU_PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) else() set(AKANTU_PYTHON_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") endif() add_subdirectory(python) endif() #=============================================================================== # Examples and tests #=============================================================================== include(AkantuTestsMacros) include(AkantuExampleMacros) if(AKANTU_TESTS) + include(AkantuNeedPybind11) option(AKANTU_BUILD_ALL_TESTS "Build all tests" ON) find_package(GMSH REQUIRED) endif() # tests add_test_tree(test) if(AKANTU_EXAMPLES) if(AKANTU_TESTS) option(AKANTU_TEST_EXAMPLES "Run the examples" ON) endif() find_package(GMSH REQUIRED) add_subdirectory(examples) endif() #=============================================================================== # Install and Packaging #=============================================================================== -include(AkantuInstall) +if (NOT AKANTU_BYPASS_AKANTU_TARGET) + include(AkantuInstall) -option(AKANTU_DISABLE_CPACK - "This option commands the generation of extra info for the \"make package\" target" ON) -mark_as_advanced(AKANTU_DISABLE_CPACK) -if(NOT AKANTU_DISABLE_CPACK) - include(AkantuCPack) + option(AKANTU_DISABLE_CPACK + "This option commands the generation of extra info for the \"make package\" target" ON) + mark_as_advanced(AKANTU_DISABLE_CPACK) + if(NOT AKANTU_DISABLE_CPACK) + include(AkantuCPack) + endif() endif() diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..62a73ee6e --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,11 @@ +graft src +graft examples +graft test +graft cmake +graft doc +graft third-party/akantu_iterators +graft third-party/iohelper +graft third-party/cmake +recursive-include python *.txt *.cc *.hh + +include CMakeLists.txt COPYING COPYING.lesser versioneer.py README.md diff --git a/README b/README deleted file mode 100644 index 11931061e..000000000 --- a/README +++ /dev/null @@ -1,26 +0,0 @@ -================================================== - _ _ - | | | | - __ _| | ____ _ _ __ | |_ _ _ - / _` | |/ / _` | '_ \| __| | | | - | (_| | < (_| | | | | |_| |_| | - \__,_|_|\_\__,_|_| |_|\__|\__,_| - -================================================== -__________ -COMPILATION - -There are two ways to compile Akantu. - -1. You can compile it directly using cmake - - > mkdir build - > cd build - > ccmake .. - > make - -________ -CONTACTS - - If you need some help to use Akantu you can contact use akantu@akantu.ch - diff --git a/README.md b/README.md new file mode 100644 index 000000000..8c78c41fc --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +# `Akantu`: Swiss-Made Open-Source Finite-Element Library + +`Akantu` means a little element in Kinyarwanda, a Bantu language. From now on it +is also an open- source object-oriented library which has the ambi- tion to be +generic and efficient. + +# Building `Akantu` + +## Dependencies + +In order to compile `Akantu` any compiler supporting fully C++14 should work. +In addition some libraries are required: + + - CMake (>= 3.5.1) + - Boost (preprocessor and Spirit) + - zlib + - blas/lapack + +For the python interface: + + - Python (>=3 is recommended) + - pybind11 (if not present the build system will try to download it) + +To run parallel simulations: + + - MPI + - Scotch + +To use the static or implicit dynamic solvers at least one of the following libraries is needed: + + - MUMPS (since this is usually compiled in static you also need MUMPS dependencies) + - PETSc + +To compile the tests and examples: + + - Gmsh + - google-test (if not present the build system will try to download it) + +### On `.deb` based systems + +``` sh +> sudo apt install cmake libboost-dev libzlib-dev liblapack3 gmsh +# For parallel +> sudo apt install mpi-default-dev libmumps-dev +# For sequential +> sudo apt install libmumps-seq-dev +``` + +## Configuring and compilation + + +`Akantu` is a [CMake](https://cmake.org/) project, so to configure it, you can follow the usual way: + +``` sh + > cd akantu + > mkdir build + > cd build + > ccmake .. + [ Set the options that you need ] + > make + > make install +``` + +## Using the python interface + + +You can install ``Akantu`` using pip: + +``` sh + > pip install akantu +``` + +You can then import the package in a python script as: + +``` python + import akantu +``` + +The python API is similar to the C++ one. If you +encounter any problem with the python interface, you are welcome to do a merge +request or post an issue on [GitLab](https://gitlab.com/akantu/akantu/-/issues). + +# Tutorials with the python interface + +To help getting started, multiple tutorials using the python interface are +available as notebooks with pre-installed version of `Akantu` on Binder. The +following tutorials are currently available: + +[Plate whith a hole loaded](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.com%2Fakantu%2Ftutorials.git/HEAD?filepath=plate-hole/plate-hole.ipynb) + +[Loaded cohesive crack](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.com%2Fakantu%2Ftutorials.git/HEAD?filepath=cohesive-fracture/cohesive-fracture.ipynb) + +[Making your constitutive law in python](https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.com%2Fakantu%2Ftutorials.git/HEAD?filepath=constitutive-laws/python_constitutive_law.ipynb) diff --git a/VERSION b/VERSION index fd2a01863..fcdb2e109 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.1.0 +4.0.0 diff --git a/cmake/AkantuConfig.cmake.in b/cmake/AkantuConfig.cmake.in index 866b1567f..99d9212f5 100644 --- a/cmake/AkantuConfig.cmake.in +++ b/cmake/AkantuConfig.cmake.in @@ -1,68 +1,69 @@ #=============================================================================== # @file AkantuConfig.cmake.in # # @author Nicolas Richart # # @date creation: Thu Dec 01 2011 # @date last modification: Mon Jan 18 2016 # # @brief CMake file for the library # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== +set(AKANTU_VERSION @AKANTU_SEMVER@) + @PACKAGE_INIT@ # Compute paths get_filename_component(AKANTU_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(AKANTU_USE_FILE "${AKANTU_CMAKE_DIR}/AkantuUse.cmake") include(${AKANTU_USE_FILE}) if(EXISTS "${AKANTU_CMAKE_DIR}/CMakeCache.txt") # In build tree include("${AKANTU_CMAKE_DIR}/AkantuBuildTreeSettings.cmake") include(AkantuSimulationMacros) else() # In install tree set(AKANTU_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/akantu") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${AKANTU_CMAKE_DIR}") include(AkantuSimulationMacros) endif() +# Akantu exported targets include("${AKANTU_CMAKE_DIR}/AkantuTargets.cmake") # Dependencies include("${AKANTU_CMAKE_DIR}/AkantuConfigInclude.cmake") set(AKANTU_BUILD_TYPE @CMAKE_BUILD_TYPE@) # find_akantu_dependencies() set(AKANTU_LIBRARY akantu) set(_akantu_libraries ${AKANTU_LIBRARIES}) list(APPEND _akantu_libraries ${AKANTU_LIBRARY} ${AKANTU_EXTRA_LIBRARIES}) list(APPEND AKANTU_INCLUDE_DIRS ${AKANTU_EXTRA_INCLUDE_DIR}) set(AKANTU_LIBRARIES ${_akantu_libraries} CACHE INTERNAL "List of akantu necessary libraries" FORCE) -# set(AKANTU_VERSION @AKANTU_VERSION@) -# set_and_check(AKANTU_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") check_required_components(Akantu) diff --git a/cmake/AkantuExtraCompilationProfiles.cmake b/cmake/AkantuExtraCompilationProfiles.cmake index 80d648a6b..d25cb5976 100644 --- a/cmake/AkantuExtraCompilationProfiles.cmake +++ b/cmake/AkantuExtraCompilationProfiles.cmake @@ -1,119 +1,119 @@ #=============================================================================== # @file AkantuExtraCompilationProfiles.cmake # # @author Nicolas Richart # # @date creation: Fri Dec 02 2016 # @date last modification: Wed Feb 03 2021 # # @brief Compilation profiles # # # @section LICENSE # # Copyright (©) 2016-2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with Akantu. If not, see . # #=============================================================================== option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE) mark_as_advanced(FORCE_COLORED_OUTPUT) if(FORCE_COLORED_OUTPUT) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_flags(cxx "-fcolor-diagnostics") else() add_flags(cxx "-fdiagnostics-color=always") endif() endif() set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DAKANTU_NDEBUG" CACHE STRING "Flags used by the compiler during release builds" FORCE) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} -ggdb3" CACHE STRING "Flags used by the compiler during debug builds" FORCE) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT} -ggdb3" CACHE STRING "Flags used by the compiler during debug builds" FORCE) endif() function(declare_compilation_profile name) include(CMakeParseArguments) cmake_parse_arguments(_args "" "COMPILER;LINKER;DOC" "" ${ARGN}) string(TOUPPER "${name}" _u_name) if(NOT _args_DOC) string(TOLOWER "${name}" _args_DOC) endif() if(NOT _args_COMPILER) message(FATAL_ERROR "declare_compilation_profile: you should at least give COMPILER flags") endif() if(NOT _args_LINKER) set(_args_LINKER ${_args_COMPILER}) endif() foreach(_flag CXX C Fortran SHARED_LINKER EXE_LINKER) set(_stage "compiler") set(_flags ${_args_COMPILER}) if(_stage MATCHES ".*LINKER") set(_stage "linker") set(_flags ${_args_LINKER}) endif() set(CMAKE_${_flag}_FLAGS_${_u_name} ${_flags} CACHE STRING "Flags used by the ${_stage} during coverage builds" FORCE) mark_as_advanced(CMAKE_${_flag}_FLAGS_${_u_name}) endforeach() endfunction() # Profiling declare_compilation_profile(PROFILING COMPILER "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O3") # Valgrind declare_compilation_profile(VALGRIND - COMPILER "-g -ggdb3 -DNDEBUG -DAKANTU_NDEBUG -O3") + COMPILER "-g -ggdb3 -O3") # Coverage declare_compilation_profile(COVERAGE COMPILER "-g -ggdb3 -DNDEBUG -DAKANTU_NDEBUG -O2 --coverage") # Sanitize the code if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.2") OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(_blacklist " -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/cmake/sanitize-blacklist.txt") endif() declare_compilation_profile(SANITIZE COMPILER "-g -ggdb3 -O2 -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer${_blacklist}") endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") declare_compilation_profile(SANITIZEMEMORY COMPILER "-g -ggdb3 -O2 -fPIE -fsanitize=memory -fsanitize-memory-track-origins -fsanitize-recover=all -fno-omit-frame-pointer -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/cmake/sanitize-blacklist.txt" DOC "\"sanitize memory\"") endif() if (CMAKE_BUILD_TYPE MATCHES "[Vv][Aa][Ll][Gg][Rr][Ii][Nn][Dd]") find_program(VALGRIND_EXECUTABLE valgrind) endif() diff --git a/cmake/AkantuInstall.cmake b/cmake/AkantuInstall.cmake index afd8e5159..796331f6f 100644 --- a/cmake/AkantuInstall.cmake +++ b/cmake/AkantuInstall.cmake @@ -1,164 +1,164 @@ #=============================================================================== # @file AkantuInstall.cmake # # @author Nicolas Richart # # @date creation: Wed Oct 17 2012 # @date last modification: Fri Jan 15 2021 # # @brief Create the files that allows users to link with Akantu in an other # cmake project # # # @section LICENSE # # Copyright (©) 2010-2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with Akantu. If not, see . # #=============================================================================== #=============================================================================== # Config gen for external packages #=============================================================================== configure_file(cmake/AkantuBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/AkantuBuildTreeSettings.cmake" @ONLY) file(WRITE "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " #=============================================================================== # @file AkantuConfigInclude.cmake # @author Nicolas Richart # @date Fri Jun 11 09:46:59 2010 # # @section LICENSE # # Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # # @section DESCRIPTION # #=============================================================================== ") package_get_all_packages(_package_list) foreach(_pkg_name ${_package_list}) # package_pkg_name(${_option} _pkg_name) _package_is_activated(${_pkg_name} _acctivated) _package_get_real_name(${_pkg_name} _real_name) string(TOUPPER ${_real_name} _real_pkg_name) file(APPEND "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " set(AKANTU_HAS_${_real_pkg_name} ${_acctivated})") _package_get_libraries(${_pkg_name} _libs) if(_libs) file(APPEND "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " set(AKANTU_${_real_pkg_name}_LIBRARIES ${_libs})") endif() _package_get_include_dir(${_pkg_name} _incs) if(_incs) file(APPEND "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " set(AKANTU_${_real_pkg_name}_INCLUDE_DIR ${_incs}) ") endif() _package_get_compile_flags(${_pkg_name} CXX _compile_flags) if(_compile_flags) file(APPEND "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " set(AKANTU_${_real_pkg_name}_COMPILE_CXX_FLAGS ${_compile_flags}) ") endif() endforeach() file(APPEND "${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake" " set(AKANTU_EXTRA_CXX_FLAGS \"${AKANTU_EXTRA_CXX_FLAGS}\") ") # Create the AkantuConfig.cmake and AkantuConfigVersion files get_filename_component(CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) configure_file(cmake/AkantuConfig.cmake.in "${PROJECT_BINARY_DIR}/AkantuConfig.cmake" @ONLY) -configure_file(cmake/AkantuConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/AkantuConfigVersion.cmake" @ONLY) +#configure_file(cmake/AkantuConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/AkantuConfigVersion.cmake" @ONLY) configure_file(cmake/AkantuUse.cmake "${PROJECT_BINARY_DIR}/AkantuUse.cmake" COPYONLY) package_is_activated(pybind11 _is_pybind11_activated) package_is_activated(swig _is_swig_activated) configure_file(cmake/akantu_environement.sh.in ${PROJECT_BINARY_DIR}/akantu_environement.sh @ONLY) configure_file(cmake/akantu_environement.csh.in ${PROJECT_BINARY_DIR}/akantu_environement.csh @ONLY) include(GNUInstallDirs) -package_is_activated(python_interface _is_acticated) -if(_is_acticated) +package_is_activated(python_interface _is_activated) +if(_is_activated) find_package(PythonInterp ${AKANTU_PREFERRED_PYTHON_VERSION}) configure_file(cmake/akantu_install_environement.sh.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/akantu_environement.sh @ONLY) configure_file(cmake/akantu_install_environement.csh.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/akantu_environement.csh @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/akantu_environement.sh ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/akantu_environement.csh DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/akantu${AKANTU_VERSION}) endif() include(CMakePackageConfigHelpers) configure_package_config_file(cmake/AkantuConfig.cmake.in "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" - INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME} + INSTALL_DESTINATION lib/cmake/${PROJECT_NAME} ) write_basic_package_version_file(${PROJECT_BINARY_DIR}/AkantuConfigVersion.cmake VERSION ${AKANTU_VERSION} COMPATIBILITY SameMajorVersion) # Install the export set for use with the install-tree install(FILES ${PROJECT_SOURCE_DIR}/cmake/Modules/FindScaLAPACK.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindMETIS.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindParMETIS.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindPETSc.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindMumps.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindScotch.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindGMSH.cmake ${PROJECT_BINARY_DIR}/AkantuConfig.cmake ${PROJECT_BINARY_DIR}/AkantuConfigInclude.cmake ${PROJECT_BINARY_DIR}/AkantuConfigVersion.cmake ${PROJECT_SOURCE_DIR}/cmake/AkantuUse.cmake ${PROJECT_SOURCE_DIR}/cmake/AkantuSimulationMacros.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindGMSH.cmake - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME} + DESTINATION lib/cmake/${PROJECT_NAME} COMPONENT dev) diff --git a/cmake/AkantuNeedPybind11.cmake b/cmake/AkantuNeedPybind11.cmake new file mode 100644 index 000000000..e23bb6d94 --- /dev/null +++ b/cmake/AkantuNeedPybind11.cmake @@ -0,0 +1,16 @@ +if(DEFINED AKANTU_NEED_PYBIND11_LOADED) + return() +endif() +set(AKANTU_NEED_PYBIND11_LOADED TRUE) + + +set(PYBIND11_PYTHON_VERSION ${AKANTU_PREFERRED_PYTHON_VERSION} CACHE INTERNAL "") + +find_package(pybind11 QUIET) + +if (NOT pybind11_FOUND) + set(PYBIND11_VERSION "v2.4.2") + set(PYBIND11_GIT "https://github.com/pybind/pybind11.git") + + include(${PROJECT_SOURCE_DIR}/third-party/cmake/pybind11.cmake) +endif() diff --git a/cmake/AkantuTestsMacros.cmake b/cmake/AkantuTestsMacros.cmake index 319e10f97..19e4134c9 100644 --- a/cmake/AkantuTestsMacros.cmake +++ b/cmake/AkantuTestsMacros.cmake @@ -1,657 +1,656 @@ #=============================================================================== # @file AkantuTestsMacros.cmake # # @author Nicolas Richart # # @date creation: Fri Sep 03 2010 # @date last modification: Tue Jun 30 2020 # # @brief macros for tests # # # @section LICENSE # # Copyright (©) 2010-2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) # Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License along # with Akantu. If not, see . # #=============================================================================== #[=======================================================================[.rst: AkantuTestsMacros ----------------- This modules provides the functions to helper to declare tests and folders containing tests in akantu .. command:: add_test_tree add_test_tree() ```` is the entry direcroty of the full structure of subfolders containing tests .. command:: add_akantu_test add_akantu_test( ) This function add a subdirectory ```` of tests that will be conditionnaly activable and will be visible only if the parent folder as been activated An option ``AKANTU_BUILD_TEST_`` will appear in ccmake with the description ````. The compilation of all tests can be forced with the option ``AKANTU_BUILD_ALL_TESTS`` .. command:: register_test register_test( SOURCES ... PACKAGE ... SCRIPT [FILES_TO_COPY ...] [DEPENDS ...] [DIRECTORIES_TO_CREATE ...] [COMPILE_OPTIONS ...] [EXTRA_FILES ...] [LINK_LIBRARIES ...] [INCLUDE_DIRECTORIES ...] [UNSABLE] [PARALLEL] [PARALLEL_LEVEL ...] ) This function defines a test ``_run`` this test could be of different nature depending on the context. If Just sources are provided the test consist of running the executable generated. If a file ``.sh`` is present the test will execute the script. And if a ``.verified`` exists the output of the test will be compared to this reference file The options are: ``SOURCES ...`` The list of source files to compile to generate the executable of the test ``PACKAGE ...`` The list of package to which this test belongs. The test will be activable only of all the packages listed are activated ``SCRIPT