diff --git a/CMakeLists.txt b/CMakeLists.txt index 7706eb866..8a50a3726 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,194 +1,194 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 -# @date last modification: Mon Jan 18 2016 +# @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 2.8.12) # 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.") mark_as_advanced(BUILD_SHARED_LIBS) if(NOT AKANTU_TARGETS_EXPORT) set(AKANTU_TARGETS_EXPORT AkantuLibraryDepends) endif() include(CMakeVersionGenerator) include(CMakePackagesSystem) include(CMakeFlagsHandling) include(AkantuPackagesSystem) include(AkantuMacros) #cmake_activate_debug_message() #=============================================================================== # Version Number #=============================================================================== # AKANTU version number. An even minor number corresponds to releases. set(AKANTU_MAJOR_VERSION 2) set(AKANTU_MINOR_VERSION 3) 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") #Profiling set(CMAKE_CXX_FLAGS_PROFILING "-g -pg -DNDEBUG -DAKANTU_NDEBUG -O2" CACHE STRING "Flags used by the compiler during profiling builds") set(CMAKE_C_FLAGS_PROFILING "-g -pg -DNDEBUG -DAKANTU_NDEBUG -O2" CACHE STRING "Flags used by the compiler during profiling builds") set(CMAKE_Fortran_FLAGS_PROFILING "-g -pg -DNDEBUG -DAKANTU_NDEBUG -O2" CACHE STRING "Flags used by the compiler during profiling builds") set(CMAKE_EXE_LINKER_FLAGS_PROFILING "-pg" CACHE STRING "Flags used by the linker during profiling builds") set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-pg" CACHE STRING "Flags used by the linker during profiling builds") mark_as_advanced( CMAKE_CXX_FLAGS_PROFILING CMAKE_C_FLAGS_PROFILING CMAKE_Fortran_FLAGS_PROFILING CMAKE_EXE_LINKER_FLAGS_PROFILING CMAKE_SHARED_LINKER_FLAGS_PROFILING ) #=============================================================================== # 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() #=============================================================================== # Examples and tests #=============================================================================== option(AKANTU_EXAMPLES "Activate examples" OFF) option(AKANTU_TESTS "Activate tests" OFF) include(AkantuTestsMacros) include(AkantuExampleMacros) if(AKANTU_EXAMPLES OR AKANTU_TESTS) option(AKANTU_BUILD_ALL_TESTS "Build all tests" ON) find_package(GMSH REQUIRED) endif() if(AKANTU_EXAMPLES) add_subdirectory(examples) endif() # tests add_test_tree(test) #=============================================================================== # 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() #=============================================================================== # 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/cmake/AkantuCPack.cmake b/cmake/AkantuCPack.cmake index b38db5215..4df7d9593 100644 --- a/cmake/AkantuCPack.cmake +++ b/cmake/AkantuCPack.cmake @@ -1,129 +1,129 @@ #=============================================================================== # @file AkantuCPack.cmake # # @author Nicolas Richart # # @date creation: Wed Oct 17 2012 -# @date last modification: Mon Jan 18 2016 +# @date last modification: Fri Jan 22 2016 # # @brief Configure the packaging system # # @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(PACKAGE_FILE_NAME "akantu" CACHE STRING "Name of package to be generated") mark_as_advanced(PACKAGE_FILE_NAME) set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2") if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") set(CPACK_GENERATOR "TGZ;DEB") else() set(CPACK_GENERATOR "TGZ;NSIS") package_get_all_external_informations( _external_include_dirs _external_libraries ) set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${_external_libraries}) include(InstallRequiredSystemLibraries) endif() if(CMAKE_SYSTEM_PROCESSOR MATCHES "i.86" OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "[aA][mM][dD]64") if(CMAKE_SIZEOF_VOID_P EQUAL 8) set(_arch "amd64") else() set(_arch "i386") endif() elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc") set(_arch "powerpc") else() set(_arch "unknown") endif() if(WIN32 AND MINGW) set(_arch "mingw32") endif() # General configuration set(CPACK_PACKAGE_VENDOR "LSMS") set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${AKANTU_VERSION}-${_arch}") set(CPACK_PACKAGE_VERSION "${AKANTU_VERSION}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A multipurpose finite element library, Akantu") set(CPACK_PACKAGE_NAME "akantu") #set(CMAKE_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/akantu.ico") # Debian config package package_get_all_package_system_dependency(deb _deb_deps) package_get_all_package_system_dependency(deb-src _deb_src_deps) set(CPACK_DEBIAN_PACKAGE_MAINTAINER "nicolas.richart@epfl.ch, guillaume.anciaux@epfl.ch") set(CPACK_DEBIAN_PACKAGE_SECTION "Science") set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${_arch}" CACHE STRING "Architecture of akantu's package") set(CPACK_DEBIAN_PACKAGE_DEPENDS "${_deb_deps}") set(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDSS "${_deb_src_deps}") mark_as_advanced(CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # RPM package configuration #set(CPACK_RPM_PACKAGE_REQUIRES "${${_project}_PACKAGE_SYSTEM_DEBIAN_PACKAGE_DEPENDS}") # NSIS Windows installer #set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/akantu.ico") #set(CPACK_NSIS_CONTACT "akantu@akantu.ch") #set(CPACK_NSIS_MODIFY_PATH ON) # Components description set(CPACK_COMPONENTS_ALL lib dev bin python) set(CPACK_COMPONENT_LIB_DISPLAY_NAME "Libraries") set(CPACK_COMPONENT_BIN_DISPLAY_NAME "Examples") set(CPACK_COMPONENT_PYTHON_DISPLAY_NAME "Python interface") set(CPACK_COMPONENT_DEV_DISPLAY_NAME "C++ Headers") set(CPACK_COMPONENT_DEV_DEPENDS lib) set(CPACK_COMPONENT_BIN_DEPENDS lib) set(CPACK_COMPONENT_PYTHON_DEPENDS lib) set(CPACK_COMPONENT_LIB_DESCRIPTION "Akantu libraries") set(CPACK_COMPONENT_DEV_DESCRIPTION "Akantu C/C++ header files") set(CPACK_COMPONENT_LIB_GROUP "Akantu Libraries and Executables") set(CPACK_COMPONENT_BIN_GROUP "Akantu Libraries and Executables") set(CPACK_COMPONENT_PYTHON_GROUP "Akantu Libraries and Executables") set(CPACK_COMPONENT_DEV_GROUP "Development") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${AKANTU_VERSION}-src") set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") include(AkantuCPackMacros) generate_cpack_ignore_list(CPACK_SOURCE_IGNORE_FILES) # for debug foreach(_file ${CPACK_SOURCE_IGNORE_FILES}) message("IGNORE ${_file}") endforeach() list(APPEND CPACK_SOURCE_IGNORE_FILES "/.*build.*/" "/CVS/" "/\\\\.svn/" "/\\\\.bzr/" "/\\\\.hg/" "/\\\\.hgignore" "/\\\\.git/" "/\\\\.idea/" "\\\\.swp$" "\\\\.#" "/#" "~") include(CPack) diff --git a/cmake/AkantuExampleMacros.cmake b/cmake/AkantuExampleMacros.cmake index a1b80e0af..552a5e70f 100644 --- a/cmake/AkantuExampleMacros.cmake +++ b/cmake/AkantuExampleMacros.cmake @@ -1,86 +1,87 @@ #=============================================================================== # @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() endfunction() # ============================================================================== function(add_example et_name desc) string(TOUPPER ${et_name} upper_name) 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() endfunction() diff --git a/cmake/AkantuInstall.cmake b/cmake/AkantuInstall.cmake index 147d58fd1..f745f7cdf 100644 --- a/cmake/AkantuInstall.cmake +++ b/cmake/AkantuInstall.cmake @@ -1,154 +1,154 @@ #=============================================================================== # @file AkantuInstall.cmake # # @author Nicolas Richart # # @date creation: Wed Oct 17 2012 -# @date last modification: Mon Jan 18 2016 +# @date last modification: Fri Jan 22 2016 # # @brief Create the files that allows users to link with Akantu in an other # cmake project # # @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 . # #=============================================================================== #=============================================================================== # 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" " ") 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/AkantuUse.cmake "${PROJECT_BINARY_DIR}/AkantuUse.cmake" COPYONLY) 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) 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 share/akantu${AKANTU_VERSION}) # include(CMakePackageConfigHelpers) # configure_package_config_file(cmake/AkantuConfig.cmake.in ${PROJECT_BINARY_DIR}/AkantuConfig.cmake # INSTALL_DESTINATION "${CONF_REL_INCLUDE_DIR}lib/akantu/cmake" # PATH_VARS "${CONF_REL_INCLUDE_DIR}/include" ) # 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_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 DESTINATION lib/akantu COMPONENT dev) install(FILES ${PROJECT_SOURCE_DIR}/cmake/Modules/FindIOHelper.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindMumps.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindScotch.cmake ${PROJECT_SOURCE_DIR}/cmake/Modules/FindGMSH.cmake DESTINATION lib/akantu/cmake COMPONENT dev) diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake index 8ad1241ac..cdbca13c6 100644 --- a/cmake/AkantuMacros.cmake +++ b/cmake/AkantuMacros.cmake @@ -1,363 +1,363 @@ #=============================================================================== # @file AkantuMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Fri Oct 22 2010 -# @date last modification: Fri Dec 11 2015 +# @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(get_target_list_of_associated_files tgt files) get_target_property(_type ${tgt} TYPE) 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() else() 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( AKANTU_EXTERNAL_INCLUDE_DIR AKANTU_EXTERNAL_LIBRARIES ) set(_include_dirs ${AKANTU_INCLUDE_DIRS} ${AKANTU_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}" 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) include(CheckCXXCompilerFlag) check_cxx_compiler_flag (-std=c++11 HAVE_CPP_11) unset(_cpp_11_flag) if(HAVE_CPP_11) set(_cpp_11_flag "-std=c++11") else() check_cxx_compiler_flag (-std=c++0x HAVE_CPP_0X) if(HAVE_CPP_0X) set(_cpp_11_flag "-std=c++0x") endif() endif() set(AKANTU_CXX11_FLAGS "${_cpp_11_flag}" CACHE INTERNAL "") 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() # ---------------------------------------------------------------------------- # unordered map type # ---------------------------------------------------------------------------- check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP) set(AKANTU_UNORDERED_MAP_IS_CXX11 TRUE CACHE INTERNAL "") if(HAVE_UNORDERED_MAP) list(APPEND _extra_includes unordered_map) set(AKANTU_UNORDERED_MAP_TYPE "std::unordered_map" CACHE INTERNAL "") set(AKANTU_UNORDERED_MAP_NAMESPACE_BEGIN "namespace std {" CACHE INTERNAL "") set(AKANTU_UNORDERED_MAP_NAMESPACE_END "}" CACHE INTERNAL "") else() check_include_file_cxx(tr1/unordered_map HAVE_TR1_UNORDERED_MAP) if(HAVE_TR1_UNORDERED_MAP) list(APPEND _extra_includes tr1/unordered_map) set(AKANTU_UNORDERED_MAP_TYPE "std::tr1::unordered_map" CACHE INTERNAL "") set(AKANTU_UNORDERED_MAP_NAMESPACE_BEGIN "namespace std { namespace tr1 {" CACHE INTERNAL "") set(AKANTU_UNORDERED_MAP_NAMESPACE_END "}}" CACHE INTERNAL "") else() list(APPEND _extra_includes map) set(AKANTU_UNORDERED_MAP_TYPE "std::map" CACHE INTERNAL "") set(AKANTU_UNORDERED_MAP_IS_CXX11 FALSE CACHE INTERNAL "") endif() endif() # ---------------------------------------------------------------------------- # hash function # ---------------------------------------------------------------------------- unset(AKANTU_HASH_TYPE CACHE) check_include_file_cxx(functional HAVE_FUNCTIONAL) set(AKANTU_HASH_IS_CXX11 TRUE CACHE INTERNAL "") if(HAVE_FUNCTIONAL AND AKANTU_CXX11_FLAGS) list(APPEND _extra_includes functional) check_cxx_source_compiles(" #include template std::size_t hash(const T & t) { typedef typename std::hash hash_type; return hash_type()(t); }; int main() { return 0; } " HAVE_HASH) if(HAVE_HASH) set(AKANTU_HASH_TYPE "std::hash" CACHE INTERNAL "") endif() endif() if(NOT AKANTU_HASH_TYPE) check_include_file_cxx(tr1/functional HAVE_TR1_HASH) if(HAVE_TR1_HASH) list(APPEND _extra_includes tr1/functional) set(AKANTU_HASH_TYPE "std::tr1::hash" CACHE INTERNAL "") else() check_include_file_cxx(boost/functional/hash.hpp HAVE_BOOST_HASH) list(APPEND _extra_includes boost/functional/hash.hpp) set(AKANTU_HASH_TYPE "boost::hash" CACHE INTERNAL "") set(AKANTU_HASH_IS_CXX11 FALSE CACHE INTERNAL "") endif() endif() # ---------------------------------------------------------------------------- # includes # ---------------------------------------------------------------------------- foreach(_inc ${_extra_includes}) set(_incs "#include <${_inc}>\n${_incs}") endforeach() set(AKANTU_TYPES_EXTRA_INCLUDES ${_incs} CACHE INTERNAL "") endfunction() #=============================================================================== if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) return() endif() set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) # first set all result variables to empty/FALSE foreach(arg_name ${_singleArgNames} ${_multiArgNames}) set(${prefix}_${arg_name}) endforeach(arg_name) foreach(option ${_optionNames}) set(${prefix}_${option} FALSE) endforeach(option) set(${prefix}_UNPARSED_ARGUMENTS) set(insideValues FALSE) set(currentArgName) # now iterate over all arguments and fill the result variables foreach(currentArg ${ARGN}) list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) if(insideValues) if("${insideValues}" STREQUAL "SINGLE") set(${prefix}_${currentArgName} ${currentArg}) set(insideValues FALSE) elseif("${insideValues}" STREQUAL "MULTI") list(APPEND ${prefix}_${currentArgName} ${currentArg}) endif() else(insideValues) list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) endif(insideValues) else() if(NOT ${optionIndex} EQUAL -1) set(${prefix}_${currentArg} TRUE) set(insideValues FALSE) elseif(NOT ${singleArgIndex} EQUAL -1) set(currentArgName ${currentArg}) set(${prefix}_${currentArgName}) set(insideValues "SINGLE") elseif(NOT ${multiArgIndex} EQUAL -1) set(currentArgName ${currentArg}) set(${prefix}_${currentArgName}) set(insideValues "MULTI") endif() endif() endforeach(currentArg) # propagate the result variables to the caller: foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) endforeach(arg_name) set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/cmake/AkantuSimulationMacros.cmake b/cmake/AkantuSimulationMacros.cmake index afe7bcc0c..c072a53e3 100644 --- a/cmake/AkantuSimulationMacros.cmake +++ b/cmake/AkantuSimulationMacros.cmake @@ -1,160 +1,168 @@ #=============================================================================== # @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 "" "LIST_FILES" "${multi_variables}" ${ARGN} ) set(_deps_OK TRUE) 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}") string(REPLACE ";" " " _tmp_flags "${_simulation_COMPILE_FLAGS}") string(REGEX REPLACE " +" " " _simulation_COMPILE_FLAGS "${_tmp_flags}") if(_deps_OK) - add_executable(${simulation_name} - ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_SOURCES}) - - target_link_libraries(${simulation_name} akantu ${_simulation_LIBRARIES}) - target_include_directories(${simulation_name} PRIVATE ${AKANTU_INCLUDE_DIRS} ${_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} ${_deps}) - else() - add_dependencies(${simulation_name} ${_deps}) - endif() - endforeach() - endif() + if(_simulation_UNPARSED_ARGUMENTS OR _simulation_SOURCES) + add_executable(${simulation_name} + ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_SOURCES}) + + target_link_libraries(${simulation_name} akantu ${_simulation_LIBRARIES}) + target_include_directories(${simulation_name} PRIVATE ${AKANTU_INCLUDE_DIRS} ${_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} ${_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}") + 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_COMPILE_FLAGS) - set_target_properties(${simulation_name} - PROPERTIES COMPILE_FLAGS "${_simulation_COMPILE_FLAGS}") + if(_simulation_SCRIPT) + file(COPY ${_simulation_SCRIPT} DESTINATION .) 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_SOURCES} ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_FILES_TO_COPY}) + foreach(_file ${_simulation_SCRIPT} ${_simulation_SOURCES} + ${_simulation_UNPARSED_ARGUMENTS} ${_simulation_FILES_TO_COPY}) list(APPEND _simulation_files ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) - endforeach() + 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 f42dfe56e..d5d334790 100644 --- a/cmake/AkantuTestsMacros.cmake +++ b/cmake/AkantuTestsMacros.cmake @@ -1,399 +1,399 @@ #=============================================================================== # @file AkantuTestsMacros.cmake # # @author Nicolas Richart # # @date creation: Fri Sep 03 2010 -# @date last modification: Mon Jan 18 2016 +# @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 ...] # [UNSABLE] # [PARALLEL] # ) # # 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