diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..2d44c0a5f --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 99 +per-file-ignores = + py_engine.py:E201,E202,E203,E501 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index cfd7fe344..bb9d8955f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,194 +1,197 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 # @date last modification: Fri Jan 22 2016 # # @brief main configuration file # # @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 . # # @section DESCRIPTION #------------------------------------------------------------------------------- # _ _ # | | | | # __ _| | ____ _ _ __ | |_ _ _ # / _` | |/ / _` | '_ \| __| | | | # | (_| | < (_| | | | | |_| |_| | # \__,_|_|\_\__,_|_| |_|\__|\__,_| # #=============================================================================== #=============================================================================== # CMake Project #=============================================================================== cmake_minimum_required(VERSION 3.1.3) # add this options before PROJECT keyword set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) project(Akantu) 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() #=============================================================================== # Version Number #=============================================================================== # AKANTU version number. An even minor number corresponds to releases. set(AKANTU_MAJOR_VERSION 3) set(AKANTU_MINOR_VERSION 1) set(AKANTU_PATCH_VERSION 0) define_project_version() #=============================================================================== # Options #=============================================================================== # Debug set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DAKANTU_NDEBUG" CACHE STRING "Flags used by the compiler during release builds" FORCE) #add_flags(cxx "-Wall -Wextra -pedantic -Werror") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_flags(cxx "-Wall -Wextra -pedantic") # -Weffc++ 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) else() add_flags(cxx "-Wall") endif() option(AKANTU_EXAMPLES "Activate examples" OFF) option(AKANTU_TESTS "Activate tests" OFF) set(AKANTU_PREFERRED_PYTHON_VERSION 3 CACHE STRING "Preferred version for python related things") mark_as_advanced(AKANTU_PREFERRED_PYTHON_VERSION) 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) #=============================================================================== # Documentation #=============================================================================== if(AKANTU_DOCUMENTATION_DOXYGEN 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) 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) 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() -# tests -add_test_tree(test) - #=============================================================================== # Install and Packaging #=============================================================================== 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) endif() diff --git a/Jenkinsfile b/Jenkinsfile index 8921bb666..408ee0ef9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,185 +1,184 @@ pipeline { parameters {string(defaultValue: '', description: 'api-token', name: 'API_TOKEN') string(defaultValue: '', description: 'buildable phid', name: 'BUILD_TARGET_PHID') string(defaultValue: '', description: 'Commit id', name: 'COMMIT_ID') string(defaultValue: '', description: 'Diff id', name: 'DIFF_ID') + string(defaultValue: 'PHID-PROJ-5eqyu6ooyjktagbhf473', description: 'ID of the project', name: 'PROJECT_ID') } options { disableConcurrentBuilds() + //skipDefaultCheckout(true) } environment { PHABRICATOR_HOST = 'https://c4science.ch/api/' PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/test/ci/script/' BLA_VENDOR = 'OpenBLAS' OMPI_MCA_plm = 'isolated' OMPI_MCA_btl = 'tcp,self' } agent { dockerfile { filename 'Dockerfile' dir 'test/ci' additionalBuildArgs '--tag akantu-environment' } } stages { + stage('Checkout proper commit') { + steps { + checkout scm: [$class: 'GitSCM', + branches: [[name: "${COMMIT_ID}" ]] + ], changelog: true + } + } + stage('Lint') { steps { sh """ - arc lint --output json --rev ${GIT_PREVIOUS_COMMIT}^1 | jq . -srM | tee lint.json + arc lint --output json --rev HEAD^ | jq . -srM | tee lint.json ./test/ci/scripts/hbm send-arc-lint -f lint.json """ } } + stage('Configure') { steps { sh """#!/bin/bash set -o pipefail mkdir -p 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_PYTHON_INTERFACE:BOOL=TRUE \ + -DAKANTU_EXAMPLES:BOOL=TRUE \ + -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE \ + -DAKANTU_TEST_EXAMPLES:BOOL=FALSE \ -DAKANTU_TESTS:BOOL=TRUE .. | tee configure.txt """ } post { failure { uploadArtifact('configure.txt', 'Configure') deleteDir() } } } + stage('Compile') { steps { sh '''#!/bin/bash set -o pipefail make -C build/src | tee compilation.txt ''' } post { failure { uploadArtifact('compilation.txt', 'Compilation') } } } stage ('Warnings gcc') { steps { warnings(consoleParsers: [[parserName: 'GNU Make + GNU C Compiler (gcc)']]) } } stage('Compile python') { steps { sh '''#!/bin/bash set -o pipefail + make -C build/python | tee compilation_python.txt ''' } post { failure { uploadArtifact('compilation_python.txt', 'Compilation_Python') } } } stage('Compile tests') { steps { sh '''#!/bin/bash set -o pipefail + make -C build/test | tee compilation_test.txt ''' } post { failure { uploadArtifact('compilation_test.txt', 'Compilation_Tests') } } } stage('Tests') { steps { sh ''' #rm -rf build/gtest_reports cd build/ #source ./akantu_environement.sh ctest -T test --no-compress-output || true + tag=$(head -n 1 < Testing/TAG) + if [ -e Testing/${tag}/Test.xml ]; then + cp Testing/${tag}/Test.xml ../CTestResults.xml + fi ''' } - post { - always { - script { - def TAG = sh returnStdout: true, script: 'head -n 1 < build/Testing/TAG' - def TAG_ = TAG.trim() - - if (fileExists("build/Testing/${TAG}/Test.xml")) { - sh "cp build/Testing/${TAG}/Test.xml CTestResults.xml" - } - } - } - } + //post { + //failure { + //zip zipFile: 'build.zip', dir: 'build/', archive: true + //} + //} } } - post { always { createArtifact("./CTestResults.xml") - + step([$class: 'XUnitBuilder', thresholds: [ [$class: 'SkippedThreshold', failureThreshold: '0'], [$class: 'FailedThreshold', failureThreshold: '0']], tools: [ [$class: 'CTestType', pattern: 'CTestResults.xml', skipNoTestFiles: true] ]]) - - // step([$class: 'XUnitBuilder', - // thresholds: [ - // [$class: 'SkippedThreshold', failureThreshold: '100'], - // [$class: 'FailedThreshold', failureThreshold: '0']], - // tools: [ - // [$class: 'GoogleTestType', pattern: 'build/gtest_reports/**', skipNoTestFiles: true] - // ]]) } success { passed() } failure { - // emailext( - // body: '''${SCRIPT, template="groovy-html.template"}''', - // mimeType: 'text/html', - // subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed", - // recipientProviders: [[$class: 'CulpritsRecipientProvider']], - // to: 'akantu-admins@akantu.ch', - // replyTo: 'akantu-admins@akantu.ch', - // attachLog: true, - // compressLog: false) failed() } } } def failed() { sh "./test/ci/scripts/hbm failed" } def passed() { sh "./test/ci/scripts/hbm passed" } -def createArtifact(artifact) { +def createArtifact(filename) { sh "./test/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'" - sh "./test/ci/scripts/hbm send-ctest-results -f ${artifact}" + sh "./test/ci/scripts/hbm send-ctest-results -f ${filename}" } def uploadArtifact(artifact, name) { - sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v PHID-PROJ-5eqyu6ooyjktagbhf473" + sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v ${PROJECT_ID}" } diff --git a/cmake/AkantuExampleMacros.cmake b/cmake/AkantuExampleMacros.cmake index 1cb3c59c4..ec950532a 100644 --- a/cmake/AkantuExampleMacros.cmake +++ b/cmake/AkantuExampleMacros.cmake @@ -1,103 +1,136 @@ #=============================================================================== # @file AkantuExampleMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jan 18 2016 # @date last modification: Fri Jan 22 2016 # # @brief macros for examples # # @section LICENSE # # Copyright (©) 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 . # # @section DESCRIPTION # #=============================================================================== include(AkantuSimulationMacros) # ============================================================================== function(register_example example_name) _add_akantu_simulation(${example_name} ${ARGN} LIST_FILES _example_files) if(DEFINED _add_examples_pkg) package_add_to_variable(EXAMPLES_FILES ${_add_examples_pkg} ${_example_files}) endif() + + if(AKANTU_TEST_EXAMPLES) + cmake_parse_arguments(_example + "PYTHON;PARALLEL" + "" + "SCRIPT" + ${ARGN} + ) + + if(_example_PARALLEL) + set(_exe ${MPIEXEC}) + if(NOT _exe) + set(_exe ${MPIEXEC_EXECUTABLE}) + endif() + set(_parallel_runner ${_exe} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 2) + endif() + + if(NOT _example_SCRIPT) + add_test(NAME ${example_name}-test + COMMAND ${_parallel_runner} $ + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + elseif(_example_SCRIPT) + if(_example_PYTHON) + add_test(NAME ${example_name}-test + COMMAND ${_parallel_runner} ${PYTHON_EXECUTABLE} ${_example_SCRIPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + else() + add_test(NAME ${example_name}-test + COMMAND ${_parallel_runner} ${_example_SCRIPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + endif() + endif() endfunction() # ============================================================================== function(add_example et_name desc) string(TOUPPER ${et_name} upper_name) if(NOT _build_all_ex) option(AKANTU_BUILD_ALL_EXAMPLES "Activate all examples" OFF) set( _build_all_ex TRUE) endif() option(AKANTU_BUILD_EXAMPLES_${upper_name} ${desc} OFF) if(AKANTU_BUILD_ALL_EXAMPLES) mark_as_advanced(FORCE AKANTU_BUILD_EXAMPLES_${upper_name}) else() mark_as_advanced(CLEAR AKANTU_BUILD_EXAMPLES_${upper_name}) endif() if(AKANTU_BUILD_EXAMPLES_${upper_name} OR AKANTU_BUILD_ALL_EXAMPLES) if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${et_name}) message(FATAL_ERROR "The folder ${CMAKE_CURRENT_SOURCE_DIR}/${et_name} " "that you try to register as an example sub-folder, does not exists.") endif() cmake_parse_arguments(_manage_example "" "" "PACKAGE" ${ARGN} ) if(_manage_example_PACKAGE) set(_act TRUE) foreach(_pkg ${_manage_example_PACKAGE}) package_is_activated(${_pkg} _activated) if(NOT _activated) set(_act FALSE) endif() endforeach() else() message(SEND_ERROR "Examples should be associated to a package") endif() if(_act) if(DEFINED _add_examples_pkg) set(_save_add_examples_pkg ${_add_examples_pkg}) endif() list(GET _manage_example_PACKAGE 0 _pkg) set(_add_examples_pkg ${_pkg}) add_subdirectory(${et_name}) unset(_add_examples_pkg) if(DEFINED _save_add_examples_pkg) set(_add_examples_pkg ${_save_add_examples_pkg}) unset(_save_add_examples_pkg) endif() endif() endif() endfunction() diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake index bb41eca95..78a7f124a 100644 --- a/cmake/AkantuMacros.cmake +++ b/cmake/AkantuMacros.cmake @@ -1,245 +1,267 @@ #=============================================================================== # @file AkantuMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Fri Oct 22 2010 # @date last modification: Tue Jan 19 2016 # # @brief Set of macros used by akantu cmake files # # @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 . # #=============================================================================== #=============================================================================== function(set_third_party_shared_libirary_name _var _lib) set(${_var} ${PROJECT_BINARY_DIR}/third-party/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_lib}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE FILEPATH "" FORCE) endfunction() +# ============================================================================== +function(_add_file_to_copy target file) + get_filename_component(_file_name_we ${file} NAME_WE) + get_filename_component(_file_name ${file} NAME) + get_filename_component(_file_path ${file} + ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + + set(copy_target copy_${_file_name_we}_${target}) + add_custom_target(${copy_target} + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file_name}) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_name} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${file} + ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + DEPENDS ${_file_path} + COMMENT "Copying file ${_file_name} for the target ${target}" + ) + add_dependencies(${target} ${copy_target}) +endfunction() + # ============================================================================== function(get_target_list_of_associated_files tgt files) if(TARGET ${tgt}) get_target_property(_type ${tgt} TYPE) else() set(_type ${tgt}-NOTFOUND) endif() if(_type STREQUAL "SHARED_LIBRARY" OR _type STREQUAL "STATIC_LIBRARY" OR _type STREQUAL "MODULE_LIBRARY" OR _type STREQUAL "EXECUTABLE") get_target_property(_srcs ${tgt} SOURCES) set(_dep_ressources) foreach(_file ${_srcs}) list(APPEND _dep_ressources ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) endforeach() elseif(_type) get_target_property(_dep_ressources ${tgt} RESSOURCES) endif() set(${files} ${_dep_ressources} PARENT_SCOPE) endfunction() #=============================================================================== # Generate the list of currently loaded materials function(generate_material_list) message(STATUS "Determining the list of recognized materials...") package_get_all_include_directories( AKANTU_LIBRARY_INCLUDE_DIRS ) package_get_all_external_informations( PRIVATE_INCLUDE AKANTU_PRIVATE_EXTERNAL_INCLUDE_DIR INTERFACE_INCLUDE AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR LIBRARIES AKANTU_EXTERNAL_LIBRARIES ) set(_include_dirs ${AKANTU_INCLUDE_DIRS} ${AKANTU_PRIVATE_EXTERNAL_INCLUDE_DIR} ${AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR} ) try_run(_material_list_run _material_list_compile ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/material_lister.cc CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}" "-DCMAKE_CXX_STANDARD=14" COMPILE_DEFINITIONS "-DAKANTU_CMAKE_LIST_MATERIALS" COMPILE_OUTPUT_VARIABLE _compile_results RUN_OUTPUT_VARIABLE _result_material_list) if(_material_list_compile AND "${_material_list_run}" EQUAL 0) message(STATUS "Materials included in Akantu:") string(REPLACE "\n" ";" _material_list "${_result_material_list}") foreach(_mat ${_material_list}) string(REPLACE ":" ";" _mat_key "${_mat}") list(GET _mat_key 0 _key) list(GET _mat_key 1 _class) list(LENGTH _mat_key _l) if("${_l}" GREATER 2) list(REMOVE_AT _mat_key 0 1) set(_opt " -- options: [") foreach(_o ${_mat_key}) set(_opt "${_opt} ${_o}") endforeach() set(_opt "${_opt} ]") else() set(_opt "") endif() message(STATUS " ${_class} -- key: ${_key}${_opt}") endforeach() else() message(STATUS "Could not determine the list of materials.") message("${_compile_results}") endif() endfunction() #=============================================================================== # Declare the options for the types and defines the approriate typedefs function(declare_akantu_types) set(AKANTU_TYPE_FLOAT "double (64bit)" CACHE STRING "Precision force floating point types") mark_as_advanced(AKANTU_TYPE_FLOAT) set_property(CACHE AKANTU_TYPE_FLOAT PROPERTY STRINGS "quadruple (128bit)" "double (64bit)" "float (32bit)" ) set(AKANTU_TYPE_INTEGER "int (32bit)" CACHE STRING "Size of the integer types") mark_as_advanced(AKANTU_TYPE_INTEGER) set_property(CACHE AKANTU_TYPE_INTEGER PROPERTY STRINGS "int (32bit)" "long int (64bit)" ) include(CheckTypeSize) # ---------------------------------------------------------------------------- # Floating point types # ---------------------------------------------------------------------------- if(AKANTU_TYPE_FLOAT STREQUAL "float (32bit)") set(AKANTU_FLOAT_TYPE "float" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 4 CACHE INTERNAL "") elseif(AKANTU_TYPE_FLOAT STREQUAL "double (64bit)") set(AKANTU_FLOAT_TYPE "double" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 8 CACHE INTERNAL "") elseif(AKANTU_TYPE_FLOAT STREQUAL "quadruple (128bit)") check_type_size("long double" LONG_DOUBLE) if(HAVE_LONG_DOUBLE) set(AKANTU_FLOAT_TYPE "long double" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 16 CACHE INTERNAL "") message("This feature is not tested and will most probably not compile") else() message(FATAL_ERROR "The type long double is not defined on your system") endif() else() message(FATAL_ERROR "The float type is not defined") endif() include(CheckIncludeFileCXX) include(CheckCXXSourceCompiles) # ---------------------------------------------------------------------------- # Integer types # ---------------------------------------------------------------------------- check_include_file_cxx(cstdint HAVE_CSTDINT) if(NOT HAVE_CSTDINT) check_include_file_cxx(stdint.h HAVE_STDINT_H) if(HAVE_STDINT_H) list(APPEND _int_include stdint.h) endif() else() list(APPEND _int_include cstdint) endif() check_include_file_cxx(cstddef HAVE_CSTDDEF) if(NOT HAVE_CSTDINT) check_include_file_cxx(stddef.h HAVE_STDDEF_H) if(HAVE_STDINT_H) list(APPEND _int_include stddef.h) endif() else() list(APPEND _int_include cstddef) endif() if(AKANTU_TYPE_INTEGER STREQUAL "int (32bit)") set(AKANTU_INTEGER_SIZE 4 CACHE INTERNAL "") check_type_size("int" INT) if(INT EQUAL 4) set(AKANTU_SIGNED_INTEGER_TYPE "int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned int" CACHE INTERNAL "") else() check_type_size("int32_t" INT32_T LANGUAGE CXX) if(HAVE_INT32_T) set(AKANTU_SIGNED_INTEGER_TYPE "int32_t" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "uint32_t" CACHE INTERNAL "") list(APPEND _extra_includes ${_int_include}) endif() endif() elseif(AKANTU_TYPE_INTEGER STREQUAL "long int (64bit)") set(AKANTU_INTEGER_SIZE 8 CACHE INTERNAL "") check_type_size("long int" LONG_INT) if(LONG_INT EQUAL 8) set(AKANTU_SIGNED_INTEGER_TYPE "long int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long int" CACHE INTERNAL "") else() check_type_size("long long int" LONG_LONG_INT) if(HAVE_LONG_LONG_INT AND LONG_LONG_INT EQUAL 8) set(AKANTU_SIGNED_INTEGER_TYPE "long long int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long long int" CACHE INTERNAL "") else() check_type_size("int64_t" INT64_T) if(HAVE_INT64_T) set(AKANTU_SIGNED_INTEGER_TYPE "int64_t" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "uint64_t" CACHE INTERNAL "") list(APPEND _extra_includes ${_int_include}) endif() endif() endif() else() message(FATAL_ERROR "The integer type is not defined") endif() # ---------------------------------------------------------------------------- # includes # ---------------------------------------------------------------------------- foreach(_inc ${_extra_includes}) set(_incs "#include <${_inc}>\n${_incs}") endforeach() set(AKANTU_TYPES_EXTRA_INCLUDES ${_incs} CACHE INTERNAL "") endfunction() function(mask_package_options prefix) get_property(_list DIRECTORY PROPERTY VARIABLES) foreach(_var ${_list}) if("${_var}" MATCHES "^${prefix}.*") mark_as_advanced(${_var}) endif() endforeach() endfunction() diff --git a/cmake/AkantuSimulationMacros.cmake b/cmake/AkantuSimulationMacros.cmake index f4711a0fd..0d779525c 100644 --- a/cmake/AkantuSimulationMacros.cmake +++ b/cmake/AkantuSimulationMacros.cmake @@ -1,176 +1,177 @@ #=============================================================================== # @file AkantuSimulationMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jan 18 2016 # @date last modification: Wed Jan 20 2016 # # @brief macros for examples # # @section LICENSE # # Copyright (©) 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 . # # @section DESCRIPTION # #=============================================================================== if(__AKANTU_SIMULATION_MACROS) return() endif() set(__AKANTU_SIMULATION_MACROS TRUE) #=============================================================================== function(add_akantu_simulation simulation_name) _add_akantu_simulation(${simulation_name} ${ARGN}) endfunction() #=============================================================================== function(_add_akantu_simulation simulation_name) set(multi_variables SCRIPT SOURCES FILES_TO_COPY DEPENDS DIRECTORIES_TO_CREATE COMPILE_OPTIONS USE_PACKAGES ) cmake_parse_arguments(_simulation - "" + "PYTHON;PARALLEL" "LIST_FILES" "${multi_variables}" ${ARGN} ) set(_deps_OK TRUE) + if(_simulation_PYTHON) + list(APPEND _simulation_USE_PACKAGES python_interface) + endif() + if(_simulation_USE_PACKAGES) foreach(_pkg ${_simulation_USE_PACKAGES}) package_is_activated(${_pkg} _activated) if(_activated) package_get_include_dir(${_pkg} _inc_dir) list(APPEND _simulation_INCLUDE_DIRS ${_inc_dir}) package_get_libraries(${_pkg} _libraries) list(APPEND _simulation_LIBRARIES ${_libraries}) package_get_compile_flags(${_pkg} CXX _flags) list(APPEND _simulation_COMPILE_FLAGS "${_flags}") else() message("${simulation_name} use ${_pkg} but Akantu " " has been compiled without this package") set(_deps_OK FALSE) endif() endforeach() endif() - package_is_activated(CORE_CXX11 _activated) - if(_activated) - package_get_compile_flags(CORE_CXX11 CXX _flags) - list(APPEND _simulation_COMPILE_FLAGS "${_flags}") - endif() - package_get_compile_flags(BOOST CXX _flags) list(APPEND _simulation_COMPILE_FLAGS "${_flags}") package_get_include_dir(BOOST _boost_include_dir) string(REPLACE ";" " " _tmp_flags "${_simulation_COMPILE_FLAGS}") string(REGEX REPLACE " +" " " _simulation_COMPILE_FLAGS "${_tmp_flags}") if(_deps_OK) if(_simulation_UNPARSED_ARGUMENTS OR _simulation_SOURCES) add_executable(${simulation_name} ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_SOURCES}) target_link_libraries(${simulation_name} PRIVATE akantu ${_simulation_LIBRARIES}) target_include_directories(${simulation_name} PRIVATE ${AKANTU_INCLUDE_DIRS} ${_boost_include_dir} ${_simulation_INCLUDE_DIRS}) if(_simulation_DEPENDS) foreach(_deps ${_simulation_DEPENDS}) get_target_property(_type ${_deps} TYPE) if(_type STREQUAL "SHARED_LIBRARY" OR _type STREQUAL "STATIC_LIBRARY") target_link_libraries(${simulation_name} PRIVATE ${_deps}) else() add_dependencies(${simulation_name} ${_deps}) endif() endforeach() endif() if(_simulation_COMPILE_OPTIONS) set_target_properties(${simulation_name} PROPERTIES COMPILE_DEFINITIONS "${_simulation_COMPILE_OPTIONS}") endif() if(_simulation_COMPILE_FLAGS) set_target_properties(${simulation_name} PROPERTIES COMPILE_FLAGS "${_simulation_COMPILE_FLAGS}") endif() endif() if(_simulation_SCRIPT) - file(COPY ${_simulation_SCRIPT} DESTINATION .) + if (NOT TARGET ${simulation_name}) + add_custom_target(${simulation_name}) + endif() + _add_file_to_copy(${simulation_name} "${_simulation_SCRIPT}") endif() # copy the needed files to the build folder if(_simulation_FILES_TO_COPY) file(COPY ${_simulation_FILES_TO_COPY} DESTINATION .) endif() # create the needed folders in the build folder if(_simulation_DIRECTORIES_TO_CREATE) foreach(_dir ${_simulation_DIRECTORIES_TO_CREATE}) if(IS_ABSOLUTE ${dir}) file(MAKE_DIRECTORY ${_dir}) else() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir}) endif() endforeach() endif() endif() if(_simulation_LIST_FILES) set(_simulation_files) foreach(_file ${_simulation_SCRIPT} ${_simulation_SOURCES} ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_FILES_TO_COPY}) list(APPEND _simulation_files ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) endforeach() foreach(_dep ${_simulation_DEPENDS}) get_target_list_of_associated_files(${_dep} _dep_ressources) if(_dep_ressources) list(APPEND _simulation_files "${_dep_ressources}") endif() endforeach() set(${_simulation_LIST_FILES} ${_simulation_files} PARENT_SCOPE) endif() endfunction() diff --git a/cmake/AkantuTestsMacros.cmake b/cmake/AkantuTestsMacros.cmake index 250c6f430..80cb5071e 100644 --- a/cmake/AkantuTestsMacros.cmake +++ b/cmake/AkantuTestsMacros.cmake @@ -1,667 +1,647 @@ #=============================================================================== # @file AkantuTestsMacros.cmake # # @author Nicolas Richart # # @date creation: Fri Sep 03 2010 # @date last modification: Fri Jan 22 2016 # # @brief macros for tests # # @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 . # #=============================================================================== #[=======================================================================[.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