Page MenuHomec4science

No OneTemporary

File Metadata

Created
Fri, Oct 22, 02:47
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/.flake8 b/.flake8
index 2d44c0a5f..76f42ce8a 100644
--- a/.flake8
+++ b/.flake8
@@ -1,4 +1,5 @@
[flake8]
+exclude = build*,__pycache__,third-party
max-line-length = 99
per-file-ignores =
- py_engine.py:E201,E202,E203,E501
\ No newline at end of file
+ py_engine.py:E201,E202,E203,E501
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e36180b8d..41770fc4f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,228 +1,202 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jun 14 2010
-# @date last modification: Fri Jan 22 2016
+# @date last modification: Sat Mar 13 2021
#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @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_MAJOR_VERSION 4)
-set(AKANTU_MINOR_VERSION 0)
-set(AKANTU_PATCH_VERSION 0)
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. An even minor number corresponds to releases.
+# AKANTU version number.
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)
-
- 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()
-else()
- add_flags(cxx "-Wall")
-endif()
-
option(AKANTU_EXAMPLES "Activate examples" OFF)
option(AKANTU_TESTS "Activate tests" OFF)
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")
+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)
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 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()
#===============================================================================
# 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/CTestConfig.cmake b/CTestConfig.cmake
index 23185704b..df24d6b21 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -1,45 +1,46 @@
#===============================================================================
# @file CTestConfig.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Thu Jan 06 2011
-# @date last modification: Sun Oct 19 2014
+# @date last modification: Fri Jan 15 2016
#
# @brief configuration for ctest
#
+#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
## This file should be placed in the root directory of your project.
## Then modify the CMakeLists.txt file in the root directory of your
## project to incorporate the testing dashboard.
## # The following are required to uses Dart and the Cdash dashboard
## ENABLE_TESTING()
## INCLUDE(CTest)
set(CTEST_PROJECT_NAME "Akantu")
set(CTEST_NIGHTLY_START_TIME "06:10:00 EST")
set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "lsmssrv1.epfl.ch")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=Akantu")
set(CTEST_DROP_SITE_CDASH TRUE)
diff --git a/cmake/AkantuCPack.cmake b/cmake/AkantuCPack.cmake
index 220f915ec..3a8727174 100644
--- a/cmake/AkantuCPack.cmake
+++ b/cmake/AkantuCPack.cmake
@@ -1,129 +1,130 @@
#===============================================================================
# @file AkantuCPack.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Wed Oct 17 2012
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
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/AkantuCPackMacros.cmake b/cmake/AkantuCPackMacros.cmake
index 3c7f3a7fc..2f3f1edaf 100644
--- a/cmake/AkantuCPackMacros.cmake
+++ b/cmake/AkantuCPackMacros.cmake
@@ -1,153 +1,155 @@
#===============================================================================
-# @file AkantuCPack.cmake
+# @file AkantuCPackMacros.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
-# @date creation: Wed Jan 18 2015
+# @date creation: Mon Jan 18 2016
+# @date last modification: Fri Jan 22 2016
#
# @brief macros to help for cpack
#
+#
# @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)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
# ==============================================================================
# let start the ugly things to list what should not be in the package
# ==============================================================================
function(generate_cpack_ignore_list ignore_list)
message(STATUS "Generating CPack ignore list...")
# get a full list of all the files include in the source folder
file(GLOB _first_level "${PROJECT_SOURCE_DIR}/*")
set(_all_files "${PROJECT_SOURCE_DIR}" ${_first_level})
foreach(_path ${_first_level})
if(IS_DIRECTORY "${_path}" AND
NOT _path MATCHES "build.*" AND
NOT _path MATCHES "\\.git.*")
file(GLOB_RECURSE _second_level "${_path}/*")
file(GLOB _second_extra_level "${_path}/*")
list(APPEND _all_files ${_second_level} ${_second_extra_level})
endif()
endforeach()
set(_dirs)
foreach(_file ${_all_files})
get_filename_component(_dir ${_file} DIRECTORY)
list(APPEND _dirs ${_dir})
endforeach()
list(REMOVE_DUPLICATES _dirs)
list(APPEND _all_files ${_dirs})
# getting list of all the files that should be in the source package
package_get_files_for_package(_all_package_files)
package_get_all_activated_packages(_activated_packages)
foreach(_pkg ${_activated_packages})
_package_get_filename(${_pkg} _file_name)
_package_get_source_files(${_pkg} _srcs _pub_hdrs _priv_hdrs)
_package_get_variable(TESTS_FILES ${_pkg} _tests_files)
# adding the source directory
set(_need_source_folder)
foreach(_src ${_srcs} ${_pub_hdrs} ${_priv_hdrs} ${_tests_files})
list(APPEND _need_source_folder ${PROJECT_SOURCE_DIR}/${_src})
endforeach()
_package_get_documentation_files(${_pkg} _doc_files)
# adding the manual directory
set(_all_docs)
_package_get_manual_folder(${_pkg} _doc_folder)
foreach(_file ${_doc_files})
list(APPEND _all_docs ${_doc_folder}/${_file})
endforeach()
_package_get_variable(EXAMPLES_FILES ${_pkg} _examples_files)
_package_get_variable(EXTRA_FILES ${_pkg} _extra_files)
# split the set in 2 for debug reasons
set(_package_files
${_file_name} ${_need_source_folder}
${_examples_files} ${_extra_files} ${_all_docs}
)
list(APPEND _all_package_files ${_package_files})
endforeach()
# generate ignore list
set(_ignore_list)
set(_keep_dirs)
set(_ignore_dirs)
foreach(_file ${_all_files})
set(_found FALSE)
foreach(_pkg_file ${_all_package_files})
if(IS_DIRECTORY "${_file}" AND
_pkg_file MATCHES "${_file}/.*")
set(_found TRUE)
list(APPEND _keep_dirs "${_file}")
break()
elseif(_pkg_file MATCHES "${_file}")
set(_found TRUE)
break()
endif()
endforeach()
if(NOT _found)
list(APPEND _ignore_list "${_file}")
if(IS_DIRECTORY "${_file}")
list(APPEND _ignore_dirs "${_file}")
endif()
endif()
endforeach()
# Save CMakeLists.txt in folder that are kept
foreach(_dir ${_keep_dirs})
if(EXISTS "${_dir}/CMakeLists.txt")
list(REMOVE_ITEM _ignore_list "${_dir}/CMakeLists.txt")
endif()
endforeach()
set(_tmp_ignore_list ${_ignore_list})
set(_ignore_list)
# cleaning the ignore
foreach(_file ${_tmp_ignore_list})
set(_found FALSE)
foreach(_dir ${_ignore_dirs})
if(_file MATCHES "${_dir}/.*")
set(_found TRUE)
break()
endif()
endforeach()
if(NOT _found)
if(IS_DIRECTORY ${_file})
list(APPEND _ignore_list "${_file}/")
else()
list(APPEND _ignore_list "${_file}")
endif()
endif()
endforeach()
list(SORT _ignore_list)
list(REMOVE_DUPLICATES _ignore_list)
set(${ignore_list} ${_ignore_list} PARENT_SCOPE)
endfunction()
# ==============================================================================
# Let's hope that after all this the list is complete and not to heavy for cpack
# ==============================================================================
diff --git a/cmake/AkantuCleaning.cmake b/cmake/AkantuCleaning.cmake
index d852abf84..5355f2efb 100644
--- a/cmake/AkantuCleaning.cmake
+++ b/cmake/AkantuCleaning.cmake
@@ -1,103 +1,106 @@
#===============================================================================
# @file AkantuCleaning.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
-# @date creation: Thu Jun 1, 2017
+# @date creation: Fri Oct 22 2010
+# @date last modification: Tue Feb 02 2021
#
# @brief set of tools to clean the code
#
+#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
#
-# You should have received a copy of the GNU Lesser General Public License
-# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#===============================================================================
+
# Adding clang-format target if executable is found
find_program(CLANG_FORMAT_EXECUTABLE "clang-format")
# Adding clang-tidy target if executable is found
find_program(CLANG_TIDY_EXECUTABLE "clang-tidy")
find_program(RUN_CLANG_TIDY_EXECUTABLE "run-clang-tidy")
mark_as_advanced(
CLANG_FORMAT_EXECUTABLE
CLANG_TIDY_EXECUTABLE
RUN_CLANG_TIDY_EXECUTABLE
)
function(register_code_to_format)
if(NOT CLANG_FORMAT_EXECUTABLE)
endif()
add_custom_target(
clang-format-all
COMMAND ${CLANG_FORMAT_EXECUTABLE}
-style=file
--output-replacements-xml
${ARGN} || /bin/true
)
endfunction()
function(register_tidy_all directory)
if(NOT RUN_CLANG_TIDY_EXECUTABLE)
return()
endif()
add_custom_target(
clang-tidy-all
COMMAND ${RUN_CLANG_TIDY_EXECUTABLE}
${ARGN}
)
endfunction()
function(register_target_to_tidy target)
if(NOT CLANG_TIDY_EXECUTABLE)
return()
endif()
option(AKANTU_CLANG_TIDY_AUTOFIX OFF)
mark_as_advanced(AKANTU_CLANG_TIDY_AUTOFIX)
set(_autofix_option)
if(AKANTU_CLANG_TIDY_AUTOFIX)
set(_autofix_option -fix)
endif()
get_target_property(_sources ${target} SOURCES)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/clang-tidy)
set(_depends)
foreach(_src ${_sources})
get_filename_component(_src_dir ${_src} DIRECTORY)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/clang-tidy/${_src_dir})
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml
COMMAND ${CLANG_TIDY_EXECUTABLE}
-p=${PROJECT_BINARY_DIR}
-export-fixes=${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml
${_autofix_option}
${_src}
COMMENT "Tidying ${_src}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
list(APPEND _depends ${PROJECT_BINARY_DIR}/clang-tidy/${_src}.yaml)
endforeach()
add_custom_target(clang-tidy DEPENDS ${_depends})
endfunction()
diff --git a/cmake/AkantuExampleMacros.cmake b/cmake/AkantuExampleMacros.cmake
index 63d4c908a..3cf6951e3 100644
--- a/cmake/AkantuExampleMacros.cmake
+++ b/cmake/AkantuExampleMacros.cmake
@@ -1,155 +1,156 @@
#===============================================================================
# @file AkantuExampleMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
+# @author Fabian Barras <fabian.barras@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jan 18 2016
-# @date last modification: Fri Jan 22 2016
+# @date last modification: Wed Jan 15 2020
#
# @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)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
-#
-# @section DESCRIPTION
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
include(AkantuSimulationMacros)
set(AKANTU_DRIVER_SCRIPT ${AKANTU_CMAKE_DIR}/akantu_test_driver.sh)
# ==============================================================================
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"
"FILES_TO_COPY;DEPENDS"
"SCRIPT"
${ARGN}
)
if(_example_FILES_TO_COPY)
foreach(_file ${_example_FILES_TO_COPY})
_add_file_to_copy(${example_name} "${_file}")
endforeach()
endif()
if(_example_PARALLEL)
set(_exe ${MPIEXEC})
if(NOT _exe)
- set(_exe ${MPIEXEC_EXECUTABLE})
+ set(_exe ${MPIEXEC_EXECUTABLE})
endif()
set(_parallel_runner -p "${_exe} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG}" -N "2")
endif()
if(NOT _example_SCRIPT)
- add_test(NAME ${example_name}-test
- COMMAND ${AKANTU_DRIVER_SCRIPT}
+ add_test(NAME ${example_name}-test
+ COMMAND ${AKANTU_DRIVER_SCRIPT}
${_parallel_runner}
-n "${example_name}-test"
-w "${CMAKE_CURRENT_BINARY_DIR}"
-e $<TARGET_FILE:${example_name}>)
elseif(_example_SCRIPT)
_add_file_to_copy(${example_name} "${_example_SCRIPT}")
if(_example_PYTHON)
- add_test(NAME ${example_name}-test
- COMMAND ${AKANTU_DRIVER_SCRIPT}
+ add_test(NAME ${example_name}-test
+ COMMAND ${AKANTU_DRIVER_SCRIPT}
${_parallel_runner}
-n "${example_name}-test"
-E "${PROJECT_BINARY_DIR}/akantu_environement.sh"
-w "${CMAKE_CURRENT_BINARY_DIR}"
-e "${PYTHON_EXECUTABLE}" "${_example_SCRIPT}")
else()
- add_test(NAME ${example_name}-test
- COMMAND ${AKANTU_DRIVER_SCRIPT}
+ add_test(NAME ${example_name}-test
+ COMMAND ${AKANTU_DRIVER_SCRIPT}
${_parallel_runner}
-n "${example_name}-test"
-w "${CMAKE_CURRENT_BINARY_DIR}"
-e "${_example_SCRIPT}")
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.")
+ "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)
+ package_is_activated(${_pkg} _activated)
+ if(NOT _activated)
set(_act FALSE)
- endif()
+ 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})
+ 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)
+ set(_add_examples_pkg ${_save_add_examples_pkg})
+ unset(_save_add_examples_pkg)
endif()
endif()
endif()
endfunction()
diff --git a/cmake/AkantuExtraCompilationProfiles.cmake b/cmake/AkantuExtraCompilationProfiles.cmake
index 1076b809e..c39ff7480 100644
--- a/cmake/AkantuExtraCompilationProfiles.cmake
+++ b/cmake/AkantuExtraCompilationProfiles.cmake
@@ -1,92 +1,143 @@
+#===============================================================================
+# @file AkantuExtraCompilationProfiles.cmake
+#
+# @author Nicolas Richart <nicolas.richart@epfl.ch>
+#
+# @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 <http://www.gnu.org/licenses/>.
+#
+#===============================================================================
+
+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()
+
#Profiling
set(_profiling "-g -ggdb3 -pg -DNDEBUG -DAKANTU_NDEBUG -O2")
set(CMAKE_CXX_FLAGS_PROFILING ${_profiling}
CACHE STRING "Flags used by the compiler during profiling builds")
set(CMAKE_C_FLAGS_PROFILING ${_profiling}
CACHE STRING "Flags used by the compiler during profiling builds")
set(CMAKE_Fortran_FLAGS_PROFILING ${_profiling}
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
)
set(_coverage "-g -ggdb3 -DNDEBUG -DAKANTU_NDEBUG -O2 --coverage")
set(CMAKE_CXX_FLAGS_COVERAGE ${_coverage}
CACHE STRING "Flags used by the compiler during profiling builds" FORCE)
set(CMAKE_C_FLAGS_COVERAGE ${_coverage}
CACHE STRING "Flags used by the compiler during profiling builds" FORCE)
set(CMAKE_Fortran_FLAGS_COVERAGE ${_coverage}
CACHE STRING "Flags used by the compiler during profiling builds" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE ${_coverage}
CACHE STRING "Flags used by the compiler during profiling builds" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_COVERAGE ${_coverage}
CACHE STRING "Flags used by the linker during sanitizing builds" FORCE)
mark_as_advanced(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_Fortran_FLAGS_COVERAGE
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
CMAKE_EXE_LINKER_FLAGS_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()
set(_sanitize "-g -ggdb3 -O2 -fsanitize=address -fsanitize=leak -fsanitize=undefined -fno-omit-frame-pointer${_blacklist}")
set(CMAKE_CXX_FLAGS_SANITIZE ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_C_FLAGS_SANITIZE ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_Fortran_FLAGS_SANITIZE ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_EXE_LINKER_FLAGS_SANITIZE ${_sanitize}
CACHE STRING "Flags used by the linker during sanitizing builds")
set(CMAKE_SHARED_LINKER_FLAGS_SANITIZE ${_sanitize}
CACHE STRING "Flags used by the linker during sanitizing builds")
mark_as_advanced(
CMAKE_CXX_FLAGS_SANITIZE
CMAKE_C_FLAGS_SANITIZE
CMAKE_Fortran_FLAGS_SANITIZE
CMAKE_SHARED_LINKER_FLAGS_SANITIZE
CMAKE_EXE_LINKER_FLAGS_SANITIZE
)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(_sanitize "-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")
set(CMAKE_CXX_FLAGS_SANITIZEMEMORY ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_C_FLAGS_SANITIZEMEMORY ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_Fortran_FLAGS_SANITIZEMEMORY ${_sanitize}
CACHE STRING "Flags used by the compiler during sanitizing builds")
set(CMAKE_EXE_LINKER_FLAGS_SANITIZEMEMORY ${_sanitize}
CACHE STRING "Flags used by the linker during sanitizing builds")
set(CMAKE_SHARED_LINKER_FLAGS_SANITIZEMEMORY ${_sanitize}
CACHE STRING "Flags used by the linker during sanitizing builds")
mark_as_advanced(
CMAKE_CXX_FLAGS_SANITIZEMEMORY
CMAKE_C_FLAGS_SANITIZEMEMORY
CMAKE_Fortran_FLAGS_SANITIZEMEMORY
CMAKE_SHARED_LINKER_FLAGS_SANITIZEMEMORY
CMAKE_EXE_LINKER_FLAGS_SANITIZEMEMORY
)
endif()
diff --git a/cmake/AkantuInstall.cmake b/cmake/AkantuInstall.cmake
index 93b932af6..afd8e5159 100644
--- a/cmake/AkantuInstall.cmake
+++ b/cmake/AkantuInstall.cmake
@@ -1,163 +1,164 @@
#===============================================================================
# @file AkantuInstall.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Wed Oct 17 2012
-# @date last modification: Fri Jan 22 2016
+# @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-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
-# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
-# Solides)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#===============================================================================
# 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 <nicolas.richart@epfl.ch>
# @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 <http://www.gnu.org/licenses/>.
#
# @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/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)
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}
)
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}
COMPONENT dev)
diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake
index 3e784c762..0615d7b41 100644
--- a/cmake/AkantuMacros.cmake
+++ b/cmake/AkantuMacros.cmake
@@ -1,273 +1,274 @@
#===============================================================================
# @file AkantuMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Fri Oct 22 2010
-# @date last modification: Tue Jan 19 2016
+# @date last modification: Tue Mar 24 2020
#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#===============================================================================
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_ext ${file} EXT)
get_filename_component(_file_name ${file} NAME)
get_filename_component(_file_path ${file}
ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
configure_file(
${_file_path}
${CMAKE_CURRENT_BINARY_DIR}/${_file_name}
COPYONLY)
# set(copy_target copy_${_file_name_we}_${_file_name_ext}_${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/AkantuPackagesSystem.cmake b/cmake/AkantuPackagesSystem.cmake
index f7d13d99f..146937dfc 100644
--- a/cmake/AkantuPackagesSystem.cmake
+++ b/cmake/AkantuPackagesSystem.cmake
@@ -1,353 +1,355 @@
#===============================================================================
# @file AkantuPackagesSystem.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sat Jul 18 2015
-# @date last modification: Mon Jan 18 2016
+# @date last modification: Fri Mar 16 2018
#
# @brief Addition to the PackageSystem specific for Akantu
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#===============================================================================
# Element Types
#===============================================================================
#-------------------------------------------------------------------------------
function(package_declare_elements pkg)
set(_options
KIND
ELEMENT_TYPES
GEOMETRICAL_TYPES
INTERPOLATION_TYPES
GEOMETRICAL_SHAPES
GAUSS_INTEGRATION_TYPES
INTERPOLATION_KIND
FE_ENGINE_LISTS
)
cmake_parse_arguments(_opt_pkg
""
""
"${_options}"
${ARGN})
foreach(_opt ${_options})
if(_opt_pkg_${_opt})
package_set_variable(ET_${_opt} ${pkg} ${_opt_pkg_${_opt}})
endif()
endforeach()
endfunction()
#-------------------------------------------------------------------------------
function(_transfer_list_to_enum types enum)
if(${enum})
set(_enum_tmp ${${enum}})
else()
unset(_enum_tmp)
endif()
foreach(_type ${${types}})
# defining the types for the enum
if(DEFINED _enum_tmp)
set(_enum_tmp "${_enum_tmp}
${_type},")
else()
set(_enum_tmp "${_type},")
endif()
endforeach()
set(${enum} ${_enum_tmp} PARENT_SCOPE)
endfunction()
#-------------------------------------------------------------------------------
function(_transfer_list_to_boost_seq types boost_seq)
if(${boost_seq})
set(_boost_seq_tmp ${${boost_seq}})
endif()
foreach(_type ${${types}})
if(DEFINED _boost_seq_tmp)
set(_boost_seq_tmp "${_boost_seq_tmp}${_tabs}\\
(${_type})")
else()
set(_boost_seq_tmp " (${_type})")
endif()
string(LENGTH "${_type}" _length)
if(_length LESS 13)
set(_tabs "\t\t\t\t")
elseif(_length LESS 28)
set(_tabs "\t\t\t")
else()
set(_tabs "\t\t")
endif()
endforeach()
set(${boost_seq} ${_boost_seq_tmp} PARENT_SCOPE)
endfunction()
#-------------------------------------------------------------------------------
function(package_get_element_lists)
package_get_all_activated_packages(_activated_list)
set(_lists
KIND
ELEMENT_TYPES
GEOMETRICAL_TYPES
INTERPOLATION_TYPES
GEOMETRICAL_SHAPES
GAUSS_INTEGRATION_TYPES
INTERPOLATION_TYPES
INTERPOLATION_KIND
FE_ENGINE_LISTS
)
set(_element_kind "#define AKANTU_ELEMENT_KIND")
set(_all_element_types "#define AKANTU_ALL_ELEMENT_TYPE\t")
set(_inter_types_boost_seq "#define AKANTU_INTERPOLATION_TYPES\t\t")
foreach(_pkg_name ${_activated_list})
foreach(_list ${_lists})
string(TOLOWER "${_list}" _l_list)
_package_get_variable(ET_${_list} ${_pkg_name} _${_l_list})
_transfer_list_to_enum(_${_l_list} _${_l_list}_enum)
endforeach()
if(_interpolation_types)
_transfer_list_to_boost_seq(_interpolation_types _inter_types_boost_seq)
endif()
if(_kind)
string(TOUPPER "${_kind}" _u_kind)
if(_element_types)
set(_boosted_element_types "${_boosted_element_types}
#define AKANTU_ek_${_kind}_ELEMENT_TYPE\t")
_transfer_list_to_boost_seq(_element_types _boosted_element_types)
set(_boosted_element_types "${_boosted_element_types}\n")
# defininf the kinds variables
set(_element_kinds "${_element_kinds}
#define AKANTU_${_u_kind}_KIND\t(_ek_${_kind})")
# defining the full list of element
set(_all_element_types "${_all_element_types}\t\\
AKANTU_ek_${_kind}_ELEMENT_TYPE")
endif()
# defining the full list of kinds
set(_element_kind "${_element_kind}${_kind_tabs}\t\t\\
AKANTU_${_u_kind}_KIND")
set(_kind_tabs "\t")
# defining the macros
set(_boost_macros "${_boost_macros}
#define AKANTU_BOOST_${_u_kind}_ELEMENT_SWITCH(macro) \\
AKANTU_BOOST_ELEMENT_SWITCH(macro, \\
AKANTU_ek_${_kind}_ELEMENT_TYPE)
#define AKANTU_BOOST_${_u_kind}_ELEMENT_LIST(macro) \\
AKANTU_BOOST_APPLY_ON_LIST(macro, \\
AKANTU_ek_${_kind}_ELEMENT_TYPE)
")
list(APPEND _aka_fe_lists ${_fe_engine_lists})
foreach(_fe_engine_list ${_fe_engine_lists})
if(NOT DEFINED _fe_engine_list_${_fe_engine_list})
string(TOUPPER "${_fe_engine_list}" _u_list)
string(LENGTH "#define AKANTU_FE_ENGINE_LIST_${_u_list}" _length)
math(EXPR _length "72 - ${_length}")
set(_space "")
while(_length GREATER 0)
if(CMAKE_VERSION VERSION_GREATER 3.0)
string(CONCAT _space "${_space}" " ")
else()
set(_space "${_space} ")
endif()
math(EXPR _length "${_length} - 1")
endwhile()
set(_fe_engine_list_${_fe_engine_list}
"#define AKANTU_FE_ENGINE_LIST_${_u_list}${_space}\\
AKANTU_GENERATE_KIND_LIST((_ek_${_kind})")
else()
set(_fe_engine_list_${_fe_engine_list}
"${_fe_engine_list_${_fe_engine_list}}\t\t\t\t\\
(_ek_${_kind})")
endif()
endforeach()
endif()
endforeach()
if(_aka_fe_lists)
list(REMOVE_DUPLICATES _aka_fe_lists)
foreach(_fe_list ${_aka_fe_lists})
set(_aka_fe_defines "${_fe_engine_list_${_fe_list}})\n${_aka_fe_defines}")
endforeach()
endif()
foreach(_list ${_lists})
string(TOLOWER "${_list}" _l_list)
set(AKANTU_${_list}_ENUM ${_${_l_list}_enum} PARENT_SCOPE)
endforeach()
set(AKANTU_INTERPOLATION_TYPES_BOOST_SEQ ${_inter_types_boost_seq} PARENT_SCOPE)
set(AKANTU_ELEMENT_TYPES_BOOST_SEQ ${_boosted_element_types} PARENT_SCOPE)
set(AKANTU_ELEMENT_KINDS_BOOST_SEQ ${_element_kinds} PARENT_SCOPE)
set(AKANTU_ELEMENT_KIND_BOOST_SEQ ${_element_kind} PARENT_SCOPE)
set(AKANTU_ALL_ELEMENT_BOOST_SEQ ${_all_element_types} PARENT_SCOPE)
set(AKANTU_ELEMENT_KINDS_BOOST_MACROS ${_boost_macros} PARENT_SCOPE)
set(AKANTU_FE_ENGINE_LISTS ${_aka_fe_defines} PARENT_SCOPE)
endfunction()
#-------------------------------------------------------------------------------
function(package_get_element_types pkg list)
package_get_name(${pkg} _pkg_name)
_package_get_variable(ET_ELEMENT_TYPES ${_pkg_name} _tmp_list)
set(${list} ${_tmp_list} PARENT_SCOPE)
endfunction()
#===============================================================================
# Material specific
#===============================================================================
#-------------------------------------------------------------------------------
function(package_declare_material_infos pkg)
cmake_parse_arguments(_opt_pkg
""
""
"LIST;INCLUDE"
${ARGN})
package_set_variable(MATERIAL_LIST ${pkg} ${_opt_pkg_LIST})
package_set_variable(MATERIAL_INCLUDE ${pkg} ${_opt_pkg_INCLUDE})
endfunction()
#-------------------------------------------------------------------------------
function(package_get_all_material_includes includes)
_package_get_variable_for_activated(MATERIAL_INCLUDE _includes)
foreach(_mat_inc ${_includes})
if(DEFINED _mat_includes)
set(_mat_includes "${_mat_includes}\n#include \"${_mat_inc}\"")
else()
set(_mat_includes "#include \"${_mat_inc}\"")
endif()
endforeach()
set(${includes} ${_mat_includes} PARENT_SCOPE)
endfunction()
#-------------------------------------------------------------------------------
function(package_get_all_material_lists lists)
_package_get_variable_for_activated(MATERIAL_LIST _lists)
foreach(_mat_list ${_lists})
if(DEFINED _mat_lists)
set(_mat_lists "${_mat_lists}\n ${_mat_list}\t\t\t\\")
else()
set(_mat_lists " ${_mat_list}\t\t\t\\")
endif()
endforeach()
set(${lists} ${_mat_lists} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Extra files to consider in source package generated by CPack
# ------------------------------------------------------------------------------
function(package_declare_extra_files_to_package pkg)
set(_types SOURCES MANUAL TESTS PROJECT)
cmake_parse_arguments(_extra_files
""
""
"${_types}"
${ARGN})
set(_files ${_extra_files_UNPARSED_ARGUMENTS})
package_get_sources_folder(${pkg} _folder_SOURCES)
package_get_manual_folder(${pkg} _folder_MANUAL)
package_get_tests_folder(${pkg} _folder_TESTS)
set(_folder_PROJECT ${PROJECT_SOURCE_DIR})
foreach(_type ${_types})
if(_extra_files_${_type})
foreach(_file ${_extra_files_${_type}})
list(APPEND _files ${_folder_${_type}}/${_file})
if(NOT EXISTS ${_folder_${_type}}/${_file})
message(SEND_ERROR "The package ${pkg} tries to register the file ${_file} (as a ${_type} file).
This file cannot be found.")
endif()
endforeach()
endif()
endforeach()
package_set_variable(EXTRA_FILES ${pkg} ${_files})
endfunction()
# ------------------------------------------------------------------------------
function(package_add_files_to_package)
set(_files)
foreach(_file ${ARGN})
list(APPEND _files ${PROJECT_SOURCE_DIR}/${_file})
endforeach()
package_add_to_project_variable(EXTRA_FILES ${_files})
endfunction()
function(package_get_files_for_package files)
package_get_project_variable(EXTRA_FILES _tmp)
set(${files} ${_tmp} PARENT_SCOPE)
endfunction()
package_add_files_to_package(
.clang-format
AUTHORS
README
VERSION
COPYING
COPYING.lesser
CTestConfig.cmake
cmake/akantu_environement.sh.in
cmake/akantu_environement.csh.in
cmake/akantu_install_environement.sh.in
cmake/akantu_install_environement.csh.in
cmake/Modules/CMakeFlagsHandling.cmake
cmake/Modules/CMakePackagesSystem.cmake
cmake/Modules/CMakePackagesSystemGlobalFunctions.cmake
cmake/Modules/CMakePackagesSystemPrivateFunctions.cmake
cmake/Modules/CMakeVersionGenerator.cmake
cmake/Modules/PCHgcc.cmake
cmake/AkantuBuildTreeSettings.cmake.in
cmake/AkantuConfig.cmake.in
cmake/AkantuConfigVersion.cmake.in
cmake/AkantuCPack.cmake
cmake/AkantuCPackMacros.cmake
cmake/AkantuInstall.cmake
cmake/AkantuMacros.cmake
cmake/AkantuPackagesSystem.cmake
cmake/AkantuUse.cmake
cmake/AkantuSimulationMacros.cmake
cmake/material_lister.cc
cmake/Modules/FindGMSH.cmake
)
diff --git a/cmake/AkantuSimulationMacros.cmake b/cmake/AkantuSimulationMacros.cmake
index 3881b1fdf..b827a99e9 100644
--- a/cmake/AkantuSimulationMacros.cmake
+++ b/cmake/AkantuSimulationMacros.cmake
@@ -1,186 +1,186 @@
#===============================================================================
# @file AkantuSimulationMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jan 18 2016
-# @date last modification: Wed Jan 20 2016
+# @date last modification: Wed Aug 14 2019
#
# @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)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
-#
-# @section DESCRIPTION
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
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_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})
+ PRIVATE akantu ${_simulation_LIBRARIES})
target_include_directories(${simulation_name}
- PRIVATE
- ${AKANTU_INCLUDE_DIRS}
- ${_boost_include_dir}
- ${_simulation_INCLUDE_DIRS})
+ 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)
add_custom_target(${simulation_name} ALL
- COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_simulation_SCRIPT} ${CMAKE_CURRENT_BINARY_DIR}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${_simulation_SCRIPT}
- DEPENDS ${_simulation_SCRIPT}
- )
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_simulation_SCRIPT} ${CMAKE_CURRENT_BINARY_DIR}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${_simulation_SCRIPT}
+ DEPENDS ${_simulation_SCRIPT}
+ )
if(_simulation_DEPENDS)
foreach(_deps ${_simulation_DEPENDS})
add_dependencies(${simulation_name} ${_deps})
endforeach()
endif()
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()
+ 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 ce970bb5f..5103e28cb 100644
--- a/cmake/AkantuTestsMacros.cmake
+++ b/cmake/AkantuTestsMacros.cmake
@@ -1,652 +1,653 @@
#===============================================================================
# @file AkantuTestsMacros.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Fri Sep 03 2010
-# @date last modification: Fri Jan 22 2016
+# @date last modification: Tue Jun 30 2020
#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#[=======================================================================[.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(<test_direcotry>)
``<test_directory>`` is the entry direcroty of the full structure of
subfolders containing tests
.. command:: add_akantu_test
add_akantu_test(<dir> <desc>)
This function add a subdirectory ``<dir>`` of tests that will be conditionnaly
activable and will be visible only if the parent folder as been activated An
option ``AKANTU_BUILD_TEST_<dir>`` will appear in ccmake with the description
``<desc>``. The compilation of all tests can be forced with the option
``AKANTU_BUILD_ALL_TESTS``
.. command:: register_test
register_test(<test_name>
SOURCES <sources>...
PACKAGE <akantu_packages>...
SCRIPT <scirpt>
[FILES_TO_COPY <filenames>...]
[DEPENDS <targets>...]
[DIRECTORIES_TO_CREATE <directories>...]
[COMPILE_OPTIONS <flags>...]
[EXTRA_FILES <filnames>...]
[LINK_LIBRARIES <libraries>...]
[INCLUDE_DIRECTORIES <include>...]
[UNSABLE]
[PARALLEL]
[PARALLEL_LEVEL <procs>...]
)
This function defines a test ``<test_name>_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 ``<test_name>.sh``
is present the test will execute the script. And if a ``<test_name>.verified``
exists the output of the test will be compared to this reference file
The options are:
``SOURCES <sources>...``
The list of source files to compile to generate the executable of the test
``PACKAGE <akantu_packages>...``
The list of package to which this test belongs. The test will be activable
only of all the packages listed are activated
``SCRIPT <script>``
The script to execute instead of the executable
``FILES_TO_COPY <filenames>...``
List of files to copy from the source directory to the build directory
``DEPENDS <targets>...``
List of targets the test depends on, for example if a mesh as to be generated
``DIRECTORIES_TO_CREATE <directories>...``
Obsolete. This specifies a list of directories that have to be created in
the build folder
``COMPILE_OPTIONS <flags>...``
List of extra compilations options to pass to the compiler
``EXTRA_FILES <filnames>...``
Files to consider when generating a package_source
``UNSABLE``
If this option is specified the test can be unacitivated by the glocal option
``AKANTU_BUILD_UNSTABLE_TESTS``, this is mainly intendeed to remove test
under developement from the continious integration
``PARALLEL``
This specifies that this test should be run in parallel. It will generate a
series of test for different number of processors. This automaticaly adds a
dependency to the package ``AKANTU_PARALLEL``
``PARALLEL_LEVEL``
This defines the different processor numbers to use, if not defined the
macro tries to determine it in a "clever" way
]=======================================================================]
set(AKANTU_DRIVER_SCRIPT ${AKANTU_CMAKE_DIR}/akantu_test_driver.sh)
# ==============================================================================
macro(add_test_tree dir)
if(AKANTU_TESTS)
enable_testing()
include(CTest)
mark_as_advanced(BUILD_TESTING)
set(_akantu_current_parent_test ${dir} CACHE INTERNAL "Current test folder" FORCE)
set(_akantu_${dir}_tests_count 0 CACHE INTERNAL "" FORCE)
string(TOUPPER ${dir} _u_dir)
set(AKANTU_BUILD_${_u_dir} ON CACHE INTERNAL "${desc}" FORCE)
package_get_all_test_folders(_test_dirs)
foreach(_dir ${_test_dirs})
add_subdirectory(${_dir})
endforeach()
endif()
endmacro()
set(_test_flags
UNSTABLE
PARALLEL
PYTHON
GTEST
HEADER_ONLY
)
set(_test_one_variables
POSTPROCESS
SCRIPT
)
set(_test_multi_variables
SOURCES
FILES_TO_COPY
DEPENDS
DIRECTORIES_TO_CREATE
COMPILE_OPTIONS
EXTRA_FILES
LINK_LIBRARIES
INCLUDE_DIRECTORIES
PACKAGE
PARALLEL_LEVEL
)
# ==============================================================================
function(add_akantu_test dir desc)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
return()
endif()
set(_my_parent_dir ${_akantu_current_parent_test})
# initialize variables
set(_akantu_current_parent_test ${dir} CACHE INTERNAL "Current test folder" FORCE)
set(_akantu_${dir}_tests_count 0 CACHE INTERNAL "" FORCE)
# set the option for this directory
string(TOUPPER ${dir} _u_dir)
option(AKANTU_BUILD_${_u_dir} "${desc}")
mark_as_advanced(AKANTU_BUILD_${_u_dir})
# add the sub-directory
add_subdirectory(${dir})
# if no test can be activated make the option disappear
set(_force_deactivate_count FALSE)
if(${_akantu_${dir}_tests_count} EQUAL 0)
set(_force_deactivate_count TRUE)
endif()
# if parent off make the option disappear
set(_force_deactivate_parent FALSE)
string(TOUPPER ${_my_parent_dir} _u_parent_dir)
if(NOT AKANTU_BUILD_${_u_parent_dir})
set(_force_deactivate_parent TRUE)
endif()
if(_force_deactivate_parent OR _force_deactivate_count OR AKANTU_BUILD_ALL_TESTS)
if(NOT DEFINED _AKANTU_BUILD_${_u_dir}_SAVE)
set(_AKANTU_BUILD_${_u_dir}_SAVE ${AKANTU_BUILD_${_u_dir}} CACHE INTERNAL "" FORCE)
endif()
unset(AKANTU_BUILD_${_u_dir} CACHE)
if(AKANTU_BUILD_ALL_TESTS AND NOT _force_deactivate_count)
set(AKANTU_BUILD_${_u_dir} ON CACHE INTERNAL "${desc}" FORCE)
else()
set(AKANTU_BUILD_${_u_dir} OFF CACHE INTERNAL "${desc}" FORCE)
endif()
else()
if(DEFINED _AKANTU_BUILD_${_u_dir}_SAVE)
unset(AKANTU_BUILD_${_u_dir} CACHE)
set(AKANTU_BUILD_${_u_dir} ${_AKANTU_BUILD_${_u_dir}_SAVE} CACHE BOOL "${desc}")
unset(_AKANTU_BUILD_${_u_dir}_SAVE CACHE)
endif()
endif()
# adding up to the parent count
math(EXPR _tmp_parent_count "${_akantu_${dir}_tests_count} + ${_akantu_${_my_parent_dir}_tests_count}")
set(_akantu_${_my_parent_dir}_tests_count ${_tmp_parent_count} CACHE INTERNAL "" FORCE)
# restoring the parent current dir
set(_akantu_current_parent_test ${_my_parent_dir} CACHE INTERNAL "Current test folder" FORCE)
endfunction()
function(is_test_active is_active)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
if(NOT _register_test_PACKAGE)
message(FATAL_ERROR "No reference package was defined for the test"
" ${test_name} in folder ${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(_register_test_PYTHON)
list(APPEND _register_test_PACKAGE python_interface)
endif()
set(_test_act TRUE)
# Activate the test anly if all packages associated to the test are activated
foreach(_package ${_register_test_PACKAGE})
package_is_activated(${_package} _act)
if(NOT _act)
set(_test_act FALSE)
endif()
endforeach()
# check if the test is marked unstable and if the unstable test should be run
if(_register_test_UNSTABLE AND NOT AKANTU_BUILD_UNSTABLE_TESTS)
set(_test_act FALSE)
endif()
if(_test_act)
# todo this should be checked for the build package_sources since the file will not be listed.
math(EXPR _tmp_parent_count "${_akantu_${_akantu_current_parent_test}_tests_count} + 1")
set(_akantu_${_akantu_current_parent_test}_tests_count ${_tmp_parent_count} CACHE INTERNAL "" FORCE)
endif()
string(TOUPPER ${_akantu_current_parent_test} _u_parent)
if(NOT (AKANTU_BUILD_${_u_parent} OR AKANTU_BUILD_ALL_TESTS))
set(_test_act FALSE)
endif()
set(${is_active} ${_test_act} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
function(register_gtest_sources)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
is_test_active(_is_active ${ARGN})
register_test_files_to_package(${ARGN})
if(NOT _is_active)
return()
endif()
if(_register_test_PACKAGE)
set(_list ${_gtest_PACKAGE})
list(APPEND _list ${_register_test_PACKAGE})
list(REMOVE_DUPLICATES _list)
set(_gtest_PACKAGE ${_list} PARENT_SCOPE)
endif()
foreach (_var ${_test_flags})
if(_var STREQUAL "HEADER_ONLY")
if(NOT DEFINED_register_test_${_var})
set(_gtest_${_var} OFF PARENT_SCOPE)
elseif(NOT DEFINED _gtest_${_var})
set(_gtest_${_var} ON PARENT_SCOPE)
endif()
continue()
endif()
if(_register_test_${_var})
set(_gtest_${_var} ON PARENT_SCOPE)
else()
if(_gtest_${_var})
message("Another gtest file required ${_var} to be ON it will be globally set for this folder...")
endif()
endif()
endforeach()
if(_register_test_UNPARSED_ARGUMENTS)
list(APPEND _register_test_SOURCES ${_register_test_UNPARSED_ARGUMENTS})
endif()
foreach (_var ${_test_multi_variables})
if(_register_test_${_var})
set(_list ${_gtest_${_var}})
list(APPEND _list ${_register_test_${_var}})
list(REMOVE_DUPLICATES _list)
set(_gtest_${_var} ${_list} PARENT_SCOPE)
endif()
endforeach()
endfunction()
# ==============================================================================
function(akantu_pybind11_add_module target)
package_is_activated(pybind11 _pybind11_act)
if(_pybind11_act)
package_get_all_external_informations(
INTERFACE_INCLUDE AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR
)
pybind11_add_module(${target} ${ARGN})
target_link_libraries(${target} PRIVATE akantu)
target_include_directories(${target} SYSTEM PRIVATE ${PYBIND11_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/python)
set_property(TARGET ${target} PROPERTY DEBUG_POSTFIX "")
endif()
endfunction()
# ==============================================================================
function(register_gtest_test test_name)
if(NOT _gtest_PACKAGE)
return()
endif()
set(_argn ${test_name}_gtest)
set(_link_libraries GTest::GTest GTest::Main)
list(FIND _gtest_PACKAGE python_interface _pos)
package_is_activated(python_interface _python_interface_act)
if(_python_interface_act AND (NOT _pos EQUAL -1))
list(APPEND _link_libraries pybind11::embed)
set(_compile_flags COMPILE_OPTIONS "AKANTU_TEST_USE_PYBIND11")
endif()
is_test_active(_is_active ${ARGN} PACKAGE ${_gtest_PACKAGE})
if(NOT _is_active)
return()
endif()
register_gtest_sources(${ARGN}
SOURCES ${PROJECT_SOURCE_DIR}/test/test_gtest_main.cc
LINK_LIBRARIES ${_link_libraries}
PACKAGE ${_gtest_PACKAGE}
${_compile_flags}
)
foreach (_var ${_test_flags})
if(_gtest_${_var})
list(APPEND _argn ${_var})
unset(_gtest_${_var})
endif()
endforeach()
foreach (_var ${_test_multi_variables})
if(_gtest_${_var})
list(APPEND _argn ${_var} ${_gtest_${_var}})
unset(_gtest_${_var})
endif()
endforeach()
register_test(${_argn} GTEST)
target_include_directories(${test_name}_gtest PRIVATE ${PROJECT_SOURCE_DIR}/test)
endfunction()
# ==============================================================================
function(register_test test_name)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
register_test_files_to_package(${ARGN})
is_test_active(_test_act ${ARGN})
if(NOT _test_act)
return()
endif()
set(_extra_args)
# check that the sources are files that need to be compiled
if(_register_test_SOURCES} OR _register_test_UNPARSED_ARGUMENTS)
set(_need_to_compile TRUE)
else()
set(_need_to_compile FALSE)
endif()
set(_compile_source)
foreach(_file ${_register_test_SOURCES} ${_register_test_UNPARSED_ARGUMENTS})
if(_file MATCHES "\\.cc$" OR _file MATCHES "\\.hh$")
list(APPEND _compile_source ${_file})
endif()
endforeach()
if(_compile_source)
# get the include directories for sources in activated directories
package_get_all_include_directories(
AKANTU_LIBRARY_INCLUDE_DIRS
)
# get the external packages compilation and linking informations
package_get_all_external_informations(
INTERFACE_INCLUDE AKANTU_EXTERNAL_INCLUDE_DIR
)
foreach(_pkg ${_register_test_PACKAGE})
package_get_nature(${_pkg} _nature)
if(_nature MATCHES "^external.*")
package_get_include_dir(${_pkg} _incl)
package_get_libraries(${_pkg} _libs)
list(APPEND _register_test_INCLUDE_DIRECTORIES ${_incl})
list(APPEND _register_test_LINK_LIBRARIES ${_libs})
endif()
endforeach()
# Register the executable to compile
add_executable(${test_name} ${_compile_source})
# set the proper includes to build most of the tests
target_include_directories(${test_name}
PRIVATE ${AKANTU_LIBRARY_INCLUDE_DIRS}
${AKANTU_EXTERNAL_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/src
${_register_test_INCLUDE_DIRECTORIES})
if(NOT _register_test_HEADER_ONLY)
target_link_libraries(${test_name} PRIVATE akantu ${_register_test_LINK_LIBRARIES})
else()
get_target_property(_features akantu INTERFACE_COMPILE_FEATURES)
target_link_libraries(${test_name} ${_register_test_LINK_LIBRARIES})
target_compile_features(${test_name} PRIVATE ${_features})
endif()
# add the extra compilation options
if(_register_test_COMPILE_OPTIONS)
set_target_properties(${test_name}
PROPERTIES COMPILE_DEFINITIONS "${_register_test_COMPILE_OPTIONS}")
endif()
if(AKANTU_EXTRA_CXX_FLAGS)
set_target_properties(${test_name}
PROPERTIES COMPILE_FLAGS "${AKANTU_EXTRA_CXX_FLAGS}")
endif()
else()
add_custom_target(${test_name} ALL)
if(_register_test_UNPARSED_ARGUMENTS AND NOT _register_test_SCRIPT)
set(_register_test_SCRIPT ${_register_test_UNPARSED_ARGUMENTS})
endif()
endif()
if(_register_test_DEPENDS)
add_dependencies(${test_name} ${_register_test_DEPENDS})
endif()
# copy the needed files to the build folder
if(_register_test_FILES_TO_COPY)
foreach(_file ${_register_test_FILES_TO_COPY})
_add_file_to_copy(${test_name} "${_file}")
endforeach()
endif()
# create the needed folders in the build folder
if(_register_test_DIRECTORIES_TO_CREATE)
foreach(_dir ${_register_test_DIRECTORIES_TO_CREATE})
if(IS_ABSOLUTE ${dir})
file(MAKE_DIRECTORY "${_dir}")
else()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_dir}")
endif()
endforeach()
endif()
# register the test for ctest
set(_arguments -n "${test_name}")
if(_register_test_SCRIPT)
_add_file_to_copy(${test_name} ${_register_test_SCRIPT})
if(_register_test_PYTHON)
if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp ${AKANTU_PREFERRED_PYTHON_VERSION} REQUIRED)
endif()
list(APPEND _arguments -e "${PYTHON_EXECUTABLE}")
list(APPEND _extra_args "${_register_test_SCRIPT}")
add_dependencies(${test_name} py11_akantu)
else()
list(APPEND _arguments -e "./${_register_test_SCRIPT}")
endif()
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.sh")
_add_file_to_copy(${test_name} ${test_name}.sh)
list(APPEND _arguments -e "./${test_name}.sh")
else()
list(APPEND _arguments -e "./${test_name}")
endif()
if(_register_test_GTEST)
list(APPEND _extra_args "--" "--gtest_output=xml:${PROJECT_BINARY_DIR}/gtest_reports/${test_name}.xml")
endif()
list(APPEND _arguments -E "${PROJECT_BINARY_DIR}/akantu_environement.sh")
package_is_activated(parallel _is_parallel)
if(_is_parallel AND AKANTU_TESTS_ALWAYS_USE_MPI AND NOT _register_test_PARALLEL)
set(_register_test_PARALLEL TRUE)
set(_register_test_PARALLEL_LEVEL 1)
endif()
if(_register_test_PARALLEL AND _is_parallel)
set(_exe ${MPIEXEC})
if(NOT _exe)
set(_exe ${MPIEXEC_EXECUTABLE})
endif()
list(APPEND _arguments -p "${_exe} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG}")
if(_register_test_PARALLEL_LEVEL)
set(_procs "${_register_test_PARALLEL_LEVEL}")
elseif(CMAKE_VERSION VERSION_GREATER "3.0")
set(_procs)
if(MPIEXEC_MAX_NUMPROCS)
set(N MPIEXEC_MAX_NUMPROCS)
else()
include(ProcessorCount)
ProcessorCount(N)
endif()
while(N GREATER 1)
list(APPEND _procs ${N})
math(EXPR N "${N} / 2")
endwhile()
list(APPEND _procs 1)
endif()
if(NOT _procs)
set(_procs 2)
endif()
endif()
if(_register_test_POSTPROCESS)
list(APPEND _arguments -s "${_register_test_POSTPROCESS}")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${_register_test_POSTPROCESS}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
list(APPEND _arguments -w "${CMAKE_CURRENT_BINARY_DIR}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
list(APPEND _arguments -r "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
endif()
string(REPLACE ";" " " _command "${_arguments}")
# register them test
if(_procs)
foreach(p ${_procs})
add_test(NAME ${test_name}_${p} COMMAND ${AKANTU_DRIVER_SCRIPT} ${_arguments} -N ${p} ${_extra_args})
set_property(TEST ${test_name}_${p} PROPERTY PROCESSORS ${p})
endforeach()
else()
add_test(NAME ${test_name} COMMAND ${AKANTU_DRIVER_SCRIPT} ${_arguments} ${_extra_args})
set_property(TEST ${test_name} PROPERTY PROCESSORS 1)
endif()
endfunction()
function(register_test_files_to_package)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
if(_register_test_PYTHON)
list(APPEND _register_test_PACKAGE python_interface)
endif()
set(_test_all_files)
# add the source files in the list of all files
foreach(_file ${_register_test_SOURCES} ${_register_test_UNPARSED_ARGUMENTS}
${_register_test_EXTRA_FILES} ${_register_test_SOURCES} ${_register_test_SCRIPT}
${_register_test_POSTPROCESS} ${_register_test_FILES_TO_COPY})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_file} OR EXISTS ${_file})
list(APPEND _test_all_files "${_file}")
else()
message("The file \"${_file}\" registred by the test \"${test_name}\" does not exists")
endif()
endforeach()
# add the different dependencies files (meshes, local libraries, ...)
foreach(_dep ${_register_test_DEPENDS})
get_target_list_of_associated_files(${_dep} _dep_ressources)
if(_dep_ressources)
list(APPEND _test_all_files "${_dep_ressources}")
endif()
endforeach()
# add extra files to the list of files referenced by a given test
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.sh")
list(APPEND _test_all_files "${test_name}.sh")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
list(APPEND _test_all_files "${test_name}.verified")
endif()
if(_register_test_SCRIPT)
list(APPEND _test_all_files "${_register_test_SCRIPT}")
endif()
# clean the list of all files for this test and add them in the total list
foreach(_file ${_test_all_files})
get_filename_component(_full ${_file} ABSOLUTE)
file(RELATIVE_PATH __file ${PROJECT_SOURCE_DIR} ${_full})
list(APPEND _tmp "${__file}")
endforeach()
foreach(_pkg ${_register_test_PACKAGE})
package_get_name(${_pkg} _pkg_name)
_package_add_to_variable(TESTS_FILES ${_pkg_name} ${_tmp})
endforeach()
endfunction()
diff --git a/cmake/AkantuUse.cmake b/cmake/AkantuUse.cmake
index 8973e1a4b..3ac853456 100644
--- a/cmake/AkantuUse.cmake
+++ b/cmake/AkantuUse.cmake
@@ -1,73 +1,75 @@
#===============================================================================
# @file AkantuUse.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Tue Dec 07 2010
-# @date last modification: Mon Aug 17 2015
+# @date last modification: Mon Mar 08 2021
#
# @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)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
+
if (DEFINED CMAKE_PACKAGES_SYSTEM_LOADED)
return()
endif()
set(CMAKE_PACKAGES_SYSTEM_LOADED TRUE)
function(package_is_activated pkg activated)
string(TOUPPER ${pkg} _u_pkg)
set(${activated} ${AKANTU_HAS_${_u_pkg}} PARENT_SCOPE)
endfunction()
function(package_get_include_dir pkg include_dir)
string(TOUPPER ${pkg} _u_pkg)
set(${include_dir} ${AKANTU_${_u_pkg}_INCLUDE_DIR} PARENT_SCOPE)
endfunction()
function(package_get_libraries pkg libs)
string(TOUPPER ${pkg} _u_pkg)
set(${libs} ${AKANTU_${_u_pkg}_LIBRARIES} PARENT_SCOPE)
endfunction()
function(package_get_compile_flags pkg lang flags)
string(TOUPPER ${pkg} _u_pkg)
set(${flags} ${AKANTU_${_u_pkg}_COMPILE_${lang}_FLAGS} PARENT_SCOPE)
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()
diff --git a/cmake/Modules/CMakeDebugMessages.cmake b/cmake/Modules/CMakeDebugMessages.cmake
index 0a2ae2dff..0f149f353 100644
--- a/cmake/Modules/CMakeDebugMessages.cmake
+++ b/cmake/Modules/CMakeDebugMessages.cmake
@@ -1,70 +1,73 @@
#===============================================================================
# @file CMakeDebugMessages.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
+# @date last modification: Fri Mar 16 2018
#
# @brief Debug message helper
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
if(__CMAKE_DEBUG_MESSAGES)
return()
endif()
set(__CMAKE_DEBUG_MESSAGES TRUE)
macro(cmake_register_debug_message_module module)
set(_CMAKE_DEBUG_MESSAGE_MODULES ${CMAKE_DEBUG_MESSAGE_MODULES})
list(APPEND _CMAKE_DEBUG_MESSAGE_MODULES ${module})
set(CMAKE_DEBUG_MESSAGE_MODULES "${_CMAKE_DEBUG_MESSAGE_MODULES}"
CACHE INTERNAL "List of modules handled by the debug messages system" FORCE)
endmacro()
macro(cmake_activate_debug_message)
set(_default FALSE)
if(ARGC EQUAL 0)
set(_default TRUE)
endif()
foreach(_module ${CMAKE_DEBUG_MESSAGE_MODULES})
set(CMAKE_DEBUG_MESSAGE_${_module} ${_default} CACHE INTERNAL "" FORCE)
endforeach()
foreach(_module ${ARGN})
set(CMAKE_DEBUG_MESSAGE_${_module} TRUE CACHE INTERNAL "" FORCE)
endforeach()
endmacro()
macro(cmake_deactivate_debug_message)
foreach(_module ${CMAKE_DEBUG_MESSAGE_MODULES})
if(CMAKE_DEBUG_MESSAGE_${_module})
set(CMAKE_DEBUG_MESSAGE_${_module} FALSE CACHE INTERNAL "" FORCE)
endif()
endforeach()
endmacro()
macro(cmake_debug_message module)
if(CMAKE_DEBUG_MESSAGE_${module})
message("${PROJECT_NAME} - ${module}: ${ARGN}")
endif()
endmacro()
\ No newline at end of file
diff --git a/cmake/Modules/CMakeDetermineCCompiler.cmake b/cmake/Modules/CMakeDetermineCCompiler.cmake
index 1def08a1e..b1a4edc11 100644
--- a/cmake/Modules/CMakeDetermineCCompiler.cmake
+++ b/cmake/Modules/CMakeDetermineCCompiler.cmake
@@ -1,66 +1,66 @@
#===============================================================================
# @file CMakeDetermineCCompiler.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
+# @date last modification: Fri Mar 16 2018
#
# @brief CMake file to determine the compiler
#
-# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+# 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 <http://www.gnu.org/licenses/>.
#
#===============================================================================
macro(determine_compiler_version COMPILER)
exec_program(${CMAKE_CXX_COMPILER}
ARGS --version
OUTPUT_VARIABLE _temp
)
set(${COMPILER}_COMPILER_VERSION "" CACHE STRING "Vesion of ${COMPILER} compiler.")
string(REGEX MATCH "([0-9\\.]+)"
${COMPILER}_COMPILER_VERSION
${_temp}
)
mark_as_advanced(${COMPILER}_COMPILER_VERSION)
endmacro()
# Code from James Bigler (http://www.cmake.org/pipermail/cmake/2007-June/014460.html)
set(MANTA_COMPILER_NAME_REGEXPR "icc.*$")
if(NOT CMAKE_COMPILER_IS_GNUCC)
# This regular expression also matches things like icc-9.1
if(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
set(AKANTU_USING_ICC TRUE)
endif(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
else(NOT CMAKE_COMPILER_IS_GNUCC)
set(AKANTU_USING_GNUCC TRUE)
endif(NOT CMAKE_COMPILER_IS_GNUCC)
set(MANTA_COMPILER_NAME_REGEXPR "icpc.*$")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
set(AKANTU_USING_ICPC TRUE)
determine_compiler_version(INTEL)
#else mvsc/clang/ibm/... ?
endif(CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR})
else(NOT CMAKE_COMPILER_IS_GNUCXX)
set(AKANTU_USING_GNUCXX TRUE)
determine_compiler_version(GCC)
endif(NOT CMAKE_COMPILER_IS_GNUCXX)
diff --git a/cmake/Modules/CMakeDetermineCompiler.cmake b/cmake/Modules/CMakeDetermineCompiler.cmake
index 511ebfa74..b1ef6f01d 100644
--- a/cmake/Modules/CMakeDetermineCompiler.cmake
+++ b/cmake/Modules/CMakeDetermineCompiler.cmake
@@ -1,103 +1,101 @@
#===============================================================================
# @file CMakeDetermineCompiler.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
+# @date last modification: Fri Mar 16 2018
#
-# @brief
#
-# @section LICENSE
-#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+# 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 <http://www.gnu.org/licenses/>.
#
#===============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
macro(_cmake_find_compiler lang)
# Use already-enabled languages for reference.
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
list(REMOVE_ITEM _languages "${lang}")
if(CMAKE_${lang}_COMPILER_INIT)
# Search only for the specified compiler.
set(CMAKE_${lang}_COMPILER_LIST "${CMAKE_${lang}_COMPILER_INIT}")
else()
# Re-order the compiler list with preferred vendors first.
set(_${lang}_COMPILER_LIST "${CMAKE_${lang}_COMPILER_LIST}")
set(CMAKE_${lang}_COMPILER_LIST "")
# Prefer vendors of compilers from reference languages.
foreach(l ${_languages})
list(APPEND CMAKE_${lang}_COMPILER_LIST
${_${lang}_COMPILER_NAMES_${CMAKE_${l}_COMPILER_ID}})
endforeach()
# Prefer vendors based on the platform.
list(APPEND CMAKE_${lang}_COMPILER_LIST ${CMAKE_${lang}_COMPILER_NAMES})
# Append the rest of the list and remove duplicates.
list(APPEND CMAKE_${lang}_COMPILER_LIST ${_${lang}_COMPILER_LIST})
unset(_${lang}_COMPILER_LIST)
list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_LIST)
if(CMAKE_${lang}_COMPILER_EXCLUDE)
list(REMOVE_ITEM CMAKE_${lang}_COMPILER_LIST
${CMAKE_${lang}_COMPILER_EXCLUDE})
endif()
endif()
# Look for directories containing compilers of reference languages.
set(_${lang}_COMPILER_HINTS)
foreach(l ${_languages})
if(CMAKE_${l}_COMPILER AND IS_ABSOLUTE "${CMAKE_${l}_COMPILER}")
get_filename_component(_hint "${CMAKE_${l}_COMPILER}" PATH)
if(IS_DIRECTORY "${_hint}")
list(APPEND _${lang}_COMPILER_HINTS "${_hint}")
endif()
unset(_hint)
endif()
endforeach()
# Find the compiler.
if(_${lang}_COMPILER_HINTS)
# Prefer directories containing compilers of reference languages.
list(REMOVE_DUPLICATES _${lang}_COMPILER_HINTS)
find_program(CMAKE_${lang}_COMPILER
NAMES ${CMAKE_${lang}_COMPILER_LIST}
PATHS ${_${lang}_COMPILER_HINTS}
NO_DEFAULT_PATH
DOC "${lang} compiler")
endif()
find_program(CMAKE_${lang}_COMPILER NAMES ${CMAKE_${lang}_COMPILER_LIST} DOC "${lang} compiler")
if(CMAKE_${lang}_COMPILER_INIT AND NOT CMAKE_${lang}_COMPILER)
set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_INIT}" CACHE FILEPATH "${lang} compiler" FORCE)
endif()
unset(_${lang}_COMPILER_HINTS)
unset(_languages)
# Look for a make tool provided by Xcode
if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE)
foreach(comp ${CMAKE_${lang}_COMPILER_LIST})
execute_process(COMMAND xcrun --find ${comp}
OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE _xcrun_err)
if(_xcrun_out)
set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}")
break()
endif()
endforeach()
endif()
endmacro()
diff --git a/cmake/Modules/CMakeFlagsHandling.cmake b/cmake/Modules/CMakeFlagsHandling.cmake
index 5de3a0716..2efd26c1a 100644
--- a/cmake/Modules/CMakeFlagsHandling.cmake
+++ b/cmake/Modules/CMakeFlagsHandling.cmake
@@ -1,69 +1,71 @@
#===============================================================================
# @file CMakeFlagsHandling.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
-# @date last modification: Tue Jul 14 2015
+# @date last modification: Fri Jan 15 2016
#
# @brief Set of macros used by akantu to handle the package system
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
if(_CMAKE_FLAGS_HANDLING)
return()
endif()
set(_CMAKE_FLAGS_HANDLING TRUE)
#===============================================================================
# Compilation options handling
#===============================================================================
macro(_get_flags_message type desc)
if(${type} MATCHES "C..")
set(${desc} "Flags used by the compiler during all build types.")
elseif(${type} MATCHES "EXE_LINKER")
set(${desc} "Flags used by the linker.")
elseif(${type} MATCHES "SHARED_LINKER")
set(${desc} "Flags used by the linker during the creation of dll's.")
endif()
endmacro()
#===============================================================================
macro(add_flags type flag)
string(TOUPPER ${type} _type)
set(_var CMAKE_${_type}_FLAGS)
_get_flags_message(${_type} _desc)
string(REPLACE "${flag}" "match" _temp_var "${${_var}}")
if(NOT _temp_var MATCHES "match")
set(${_var} "${flag} ${${_var}}" CACHE STRING ${_desc} FORCE)
endif()
endmacro()
#===============================================================================
macro(remove_flags type flag)
string(TOUPPER ${type} _type)
set(_var CMAKE_${_type}_FLAGS)
_get_flags_message(${_type} _desc)
string(REPLACE "${flag} " "" ${_var} "${${_var}}")
set(${_var} "${${_var}}" CACHE STRING ${_desc} FORCE)
endmacro()
#===============================================================================
diff --git a/cmake/Modules/CMakePackagesSystem.cmake b/cmake/Modules/CMakePackagesSystem.cmake
index a8d2eea0e..d8bfd34c0 100644
--- a/cmake/Modules/CMakePackagesSystem.cmake
+++ b/cmake/Modules/CMakePackagesSystem.cmake
@@ -1,1106 +1,1108 @@
#===============================================================================
# @file CMakePackagesSystem.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
-# @date creation: Wed Nov 05 2014
-# @date last modification: Wed Jan 20 2016
+# @date creation: Sun Oct 19 2014
+# @date last modification: Mon Mar 08 2021
#
# @brief Set of macros used by akantu to handle the package system
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#[=======================================================================[.rst:
#CMakePackagesSystem
#-------------------
#
#This package defines multiple function to handle packages. This packages can
#be of two kinds regular ones and extra_packages (ex: in akantu the LGPL part
#is regular packages and extra packages are on Propetary license)
#
#Package are loaded with the help of the command:
#
#.. command:: package_list_packages
#
# package_list_packages(<regular_package_folder>
# [ EXTRA_PACKAGE_FOLDER <extra_package_folder> ]
# [ SOURCE_FOLDER <source_folder>]
# [ TEST_FOLDER <test_folder> ]
# [ MANUAL_FOLDER <manual_folder> ]
# )
#
# This command will look for packages name like ``<regular_package_folder>/<package>.cmake``
# OR ``<extra_package_folder>/<package>/package.cmake``
#
#A package is a cmake script that should contain at list the declaration of a
#package
#
#.. command:: package_declare
#
# package_declare(<package real name>
# [EXTERNAL] [META] [ADVANCED] [NOT_OPTIONAL]
# [DESCRIPTION <description>] [DEFAULT <default_value>]
# [DEPENDS <pkg> ...]
# [BOOST_COMPONENTS <pkg> ...]
# [EXTRA_PACKAGE_OPTIONS <opt> ...]
# [COMPILE_FLAGS <lang> <flags>]
# [SYSTEM <ON|OFF|AUTO> [ <script_to_compile> ]]
# [FEATURES_PUBLIC <feature> ...]
# [FEATURES_PRIVATE <feature> ...]
# [EXCLUDE_FROM_ALL]
# )
#
#.. command:: package_declare_sources
#
# It can also declare multiple informations:
# source files:
#
# package_declare_sources(<package real name>
# <src1> <src2> ... <srcn>)
#
#.. command:: package_declare_documentation
#
# a LaTeX documentation
# package_declare_documentation(<package real name>
# <line1> <line2> ...<linen>)
#
#.. command:: package_declare_documentation_files
#
# LaTeX documentation files
# package_declare_documentation_files(<package real name>
# <file1> <file2> ... <filen>)
#
#Different function can also be retrieved from the package system by using the
#different accessors
#
#.. command:: package_get_name
# package_get_name(<pkg> <retval>)
#
#.. command:: package_get_real_name
# package_get_real_name(<pkg> <retval>)
#
#.. command:: package_get_option_name
# package_get_option_name(<pkg> <retval>)
#
#.. command:: package_use_system
# package_use_system(<pkg> <retval>)
#
#.. command:: package_get_nature
# package_get_nature(<pkg> <retval>)
#
#.. command:: package_get_description
# package_get_description(<pkg> <retval>)
#
#.. command:: package_get_filename
# package_get_filename(<pkg> <retval>)
#
#.. command:: package_get_sources_folder
# package_get_sources_folder(<pkg> <retval>)
#.. command:: package_get_tests_folder
# package_get_tests_folder(<pkg> <retval>)
#.. command:: package_get_manual_folder
# package_get_manual_folder(<pkg> <retval>)
#
#.. command:: package_get_find_package_extra_options
# package_get_find_package_extra_options(<pkg> <retval>)
#
#.. command:: package_get_compile_flags
# package_get_compile_flags(<pkg> <lang> <retval>)
#.. command:: package_set_compile_flags
# package_set_compile_flags(<pkg> <lang> <flag1> <flag2> ... <flagn>)
#
#.. command:: package_get_include_dir
# package_get_include_dir(<pkg> <retval>)
#.. command:: package_set_include_dir
# package_set_include_dir(<pkg> <inc1> <inc2> ... <incn>)
#.. command:: package_add_include_dir
# package_add_include_dir(<pkg> <inc1> <inc2> ... <incn>)
#
#.. command:: package_get_libraries
# package_get_libraries(<pkg> <retval>)
#.. command:: package_set_libraries
# package_set_libraries(<pkg> <lib1> <lib2> ... <libn>)
#
#.. command:: package_add_extra_dependency
# package_add_extra_dependency(pkg <dep1> <dep2> ... <depn>)
#.. command:: package_rm_extra_dependency
# package_rm_extra_dependency(<pkg> <dep>)
#.. command:: package_get_extra_dependencies
# package_get_extra_dependencies(<pkg> <retval>)
#
#.. command:: package_is_activated
# package_is_activated(<pkg> <retval>)
#.. command:: package_is_deactivated
# package_is_deactivated(<pkg> <retval>)
#
#.. command:: package_get_dependencies
# package_get_dependencies(<pkg> <PRIVATE|INTERFACE> <retval>)
#.. command:: package_add_dependencies
# package_add_dependencies(<pkg> <PRIVATE|INTERFACE> <dep1> <dep2> ... <depn>)
# package_remove_dependencies(<pkg> <dep1> <dep2> ... <depn>)
# package_remove_dependency(<pkg> <dep>)
#
#.. command:: package_on_enabled_script
# package_on_enabled_script(<pkg> <script>)
#
#.. command:: package_get_all_source_files
# package_get_all_source_files(<srcs> <public_headers> <private_headers>)
#.. command:: package_get_all_include_directories
# package_get_all_include_directories(<inc_dirs>)
#.. command:: package_get_all_external_informations
# package_get_all_external_informations(<include_dir> <libraries>)
#.. command:: package_get_all_definitions
# package_get_all_definitions(<definitions>)
#.. command:: package_get_all_extra_dependencies
# package_get_all_extra_dependencies(<dependencies>)
#.. command:: package_get_all_test_folders
# package_get_all_test_folders(<test_dirs>)
#.. command:: package_get_all_documentation_files
# package_get_all_documentation_files(<doc_files>)
#.. command:: package_get_all_activated_packages
# package_get_all_activated_packages(<activated_list>)
#.. command:: package_get_all_deactivated_packages
# package_get_all_deactivated_packages(<deactivated_list>)
#.. command:: package_get_all_packages
# package_get_all_packages(<packages_list>)
#.. command:: package_get_all_features_public
# package_get_all_features_public(<features>)
#.. command:: package_get_all_features_private
# package_get_all_features_private(<features>)
#
#
# .. command:: package_set_package_system_dependency
#
# package_set_package_system_dependency(<pkg> <system> <dep1>
# <dep2> ... <depn>)
#
# .. command:: package_get_package_system_dependency
#
# package_get_package_system_dependency(<pkg> <var>)
#
#
#]=======================================================================]
if (DEFINED CMAKE_PACKAGES_SYSTEM_LOADED)
return()
endif()
set(CMAKE_PACKAGES_SYSTEM_LOADED TRUE)
include(CMakeParseArguments)
#===============================================================================
# Package Management
#===============================================================================
if(__CMAKE_PACKAGES_SYSTEM)
return()
endif()
set(__CMAKE_PACKAGES_SYSTEM TRUE)
if(CMAKE_VERSION VERSION_GREATER 3.1.2)
cmake_policy(SET CMP0054 NEW)
endif()
#===============================================================================
option(AUTO_MOVE_UNKNOWN_FILES
"Give to cmake the permission to move the unregistered files to the ${PROJECT_SOURCE_DIR}/tmp directory" FALSE)
mark_as_advanced(AUTO_MOVE_UNKNOWN_FILES)
include(CMakePackagesSystemGlobalFunctions)
include(CMakePackagesSystemPrivateFunctions)
# ==============================================================================
# "Public" Accessors
# ==============================================================================
# ------------------------------------------------------------------------------
# Package name
# ------------------------------------------------------------------------------
function(package_get_name pkg pkg_name)
string(TOUPPER ${PROJECT_NAME} _project)
string(REPLACE "-" "_" _str_pkg "${pkg}")
string(TOUPPER ${_str_pkg} _u_package)
set(${pkg_name} ${_project}_PKG_${_u_package} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Real name
# ------------------------------------------------------------------------------
function(package_get_real_name pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_real_name(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Option name
# ------------------------------------------------------------------------------
function(package_get_option_name pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_option_name(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Set if system package or compile external lib
# ------------------------------------------------------------------------------
function(package_use_system pkg ret)
package_get_name(${pkg} _pkg_name)
_package_use_system(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_add_third_party_script_variable pkg var)
package_get_name(${pkg} _pkg_name)
_package_add_third_party_script_variable(${_pkg_name} ${var} ${ARGN})
set(${var} ${ARGN} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Add package's targets to the export list
# ------------------------------------------------------------------------------
function(package_add_to_export_list pkg)
package_get_name(${pkg} _pkg_name)
_package_add_to_export_list(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Removes packages's targets from export list
# ------------------------------------------------------------------------------
function(package_remove_from_export_list pkg)
package_get_name(${pkg} _pkg_name)
_package_remove_from_export_list(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Nature
# ------------------------------------------------------------------------------
function(package_get_nature pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_nature(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Description
# ------------------------------------------------------------------------------
function(package_get_description pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_description(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Package file name
# ------------------------------------------------------------------------------
function(package_get_filename pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_filename(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Source files
# ------------------------------------------------------------------------------
function(package_get_source_files pkg ret_srcs ret_pub ret_priv)
package_get_name(${pkg} _pkg_name)
_package_get_source_files(${_pkg_name} _tmp_srcs _tmp_pub _tmp_priv)
set(${ret_srcs} ${_tmp_srcs} PARENT_SCOPE)
set(${ret_pub} ${_tmp_pub} PARENT_SCOPE)
set(${ret_priv} ${_tmp_pric} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Source folder
# ------------------------------------------------------------------------------
function(package_get_sources_folder pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_sources_folder(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Test folder
# ------------------------------------------------------------------------------
function(package_get_tests_folder pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_tests_folder(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Manual folder
# ------------------------------------------------------------------------------
function(package_get_manual_folder pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_manual_folder(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Extra option for the find_package
# ------------------------------------------------------------------------------
function(package_get_find_package_extra_options pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_find_package_extra_options(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_set_find_package_extra_options pkg)
package_get_name(${pkg} _pkg_name)
_package_set_find_package_extra_options(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Compilation flags
# ------------------------------------------------------------------------------
function(package_get_compile_flags pkg lang ret)
package_get_name(${pkg} _pkg_name)
_package_get_compile_flags(${_pkg_name} ${lang} _tmp)
set(${ret} "${_tmp}" PARENT_SCOPE)
endfunction()
function(package_set_compile_flags pkg lang)
package_get_name(${pkg} _pkg_name)
_package_set_compile_flags(${_pkg_name} ${lang} ${ARGN})
endfunction()
function(package_unset_compile_flags pkg lang)
package_get_name(${pkg} _pkg_name)
_package_unset_compile_flags(${_pkg_name} ${lang})
endfunction()
# ------------------------------------------------------------------------------
# Include dir
# ------------------------------------------------------------------------------
function(package_get_include_dir pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_include_dir(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_set_include_dir pkg)
package_get_name(${pkg} _pkg_name)
_package_set_include_dir(${_pkg_name} ${ARGN})
endfunction()
function(package_add_include_dir pkg)
package_get_name(${pkg} _pkg_name)
_package_add_include_dir(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Libraries
# ------------------------------------------------------------------------------
function(package_get_libraries pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_libraries(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_set_libraries pkg)
package_get_name(${pkg} _pkg_name)
_package_set_libraries(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Extra dependencies like custom commands of ExternalProject
# ------------------------------------------------------------------------------
function(package_add_extra_dependency pkg)
package_get_name(${pkg} _pkg_name)
_package_add_extra_dependency(${_pkg_name} ${ARGN})
endfunction()
function(package_rm_extra_dependency pkg dep)
package_get_name(${pkg} _pkg_name)
_package_rm_extra_dependency(${_pkg_name} ${dep})
endfunction()
function(package_get_extra_dependencies pkg ret)
package_get_name(${pkg} _pkg_name)
_package_get_extra_dependencies(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Activate/deactivate
# ------------------------------------------------------------------------------
function(package_is_activated pkg ret)
package_get_name(${pkg} _pkg_name)
_package_is_activated(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_is_deactivated pkg ret)
package_get_name(${pkg} _pkg_name)
_package_is_deactivated(${_pkg_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Direct dependencies
# ------------------------------------------------------------------------------
function(package_get_dependencies pkg type ret)
package_get_name(${pkg} _pkg_name)
_package_get_dependencies(${_pkg_name} ${type} _tmp_name)
_package_get_real_name(${_tmp_name} _tmp)
set(${ret} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_add_dependencies pkg type)
package_get_name(${pkg} _pkg_name)
foreach(_dep ${ARGN})
package_get_name(${_dep} _dep_pkg_name)
list(APPEND _tmp_deps ${_dep_pkg_name})
endforeach()
_package_add_dependencies(${_pkg_name} ${type} ${_tmp_deps})
endfunction()
function(package_remove_dependencies pkg type)
foreach(_dep ${ARGN})
package_remove_dependency(${pkg} _dep)
endforeach()
endfunction()
function(package_remove_dependency pkg dep)
package_get_name(${pkg} _pkg_name)
package_get_name(${dep} _dep_pkg_name)
_package_remove_dependency(${_pkg_name} PRIVATE ${_dep_pkg_name})
_package_remove_dependency(${_pkg_name} INTERFACE ${_dep_pkg_name})
endfunction()
# ------------------------------------------------------------------------------
# Documentation related functions
# ------------------------------------------------------------------------------
function(package_declare_documentation pkg)
package_get_name(${pkg} _pkg_name)
_package_set_documentation(${_pkg_name} ${ARGN})
endfunction()
function(package_declare_documentation_files pkg)
package_get_name(${pkg} _pkg_name)
_package_set_documentation_files(${_pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Set any user variables needed
# ------------------------------------------------------------------------------
function(package_set_variable variable pkg)
package_get_name(${pkg} _pkg_name)
_package_set_variable(${variable} ${_pkg_name} ${ARGN})
endfunction()
function(package_add_to_variable variable pkg)
package_get_name(${pkg} _pkg_name)
_package_add_to_variable(${variable} ${_pkg_name} ${ARGN})
endfunction()
function(package_get_variable variable pkg value)
package_get_name(${pkg} _pkg_name)
_package_get_variable(${variable} ${_pkg_name} _value_tmp)
if(_value_tmp)
set(${value} ${_value_tmp} PARENT_SCOPE)
else()
unset(${value} PARENT_SCOPE)
endif()
endfunction()
# ------------------------------------------------------------------------------
# Exteral package system as apt rpm dependencies
# ------------------------------------------------------------------------------
function(package_set_package_system_dependency pkg system)
package_get_name(${pkg} _pkg_name)
_package_set_package_system_dependency(${_pkg_name} ${system} ${ARGN})
endfunction()
function(package_get_package_system_dependency pkg system var)
package_get_name(${pkg} _pkg_name)
_package_set_package_system_dependency(${_pkg_name} ${sytem} _tmp)
set(${var} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# ==============================================================================
# Global accessors
# ==============================================================================
# ------------------------------------------------------------------------------
# get the list of source files
# ------------------------------------------------------------------------------
function(package_get_all_source_files SRCS PUBLIC_HEADERS PRIVATE_HEADERS)
string(TOUPPER ${PROJECT_NAME} _project)
unset(_tmp_srcs)
unset(_tmp_public_headers)
unset(_tmp_private_headers)
package_get_all_activated_packages(_activated_list)
foreach(_pkg_name ${_activated_list})
_package_get_source_files(${_pkg_name}
_pkg_srcs
_pkg_public_headers
_pkg_private_headers
)
list(APPEND _tmp_srcs ${_pkg_srcs})
list(APPEND _tmp_public_headers ${_pkg_public_headers})
list(APPEND _tmp_private_headers ${_pkg_private_headers})
endforeach()
set(${SRCS} ${_tmp_srcs} PARENT_SCOPE)
set(${PUBLIC_HEADERS} ${_tmp_public_headers} PARENT_SCOPE)
set(${PRIVATE_HEADERS} ${_tmp_private_headers} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get include directories
# ------------------------------------------------------------------------------
function(package_get_all_include_directories inc_dirs)
set(_tmp)
package_get_all_activated_packages(_activated_list)
foreach(_pkg_name ${_activated_list})
foreach(_type SRCS PUBLIC_HEADERS PRIVATE_HEADERS)
foreach(_file ${${_pkg_name}_${_type}})
get_filename_component(_path "${_file}" PATH)
list(APPEND _tmp "${_path}")
endforeach()
endforeach()
endforeach()
if(_tmp)
list(REMOVE_DUPLICATES _tmp)
endif()
set(${inc_dirs} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get external libraries informations
# ------------------------------------------------------------------------------
function(package_get_all_external_informations)
cmake_parse_arguments(_opt "" "PRIVATE_INCLUDE;INTERFACE_INCLUDE;LIBRARIES" "" ${ARGN})
foreach(_type PRIVATE INTERFACE)
if(_opt_${_type}_INCLUDE)
_package_get_variable_for_external_dependencies(INCLUDE_DIR ${_type} tmp_INCLUDE_DIR)
foreach(_dir ${tmp_INCLUDE_DIR})
string(FIND "${_dir}" "${CMAKE_CURRENT_SOURCE_DIR}" _pos)
if(NOT _pos EQUAL -1)
list(REMOVE_ITEM tmp_INCLUDE_DIR ${_dir})
endif()
endforeach()
set(${_opt_${_type}_INCLUDE} ${tmp_INCLUDE_DIR} PARENT_SCOPE)
endif()
endforeach()
if(_opt_LIBRARIES)
_package_get_variable_for_external_dependencies(LIBRARIES PRIVATE tmp_LIBRARIES)
_package_get_variable_for_external_dependencies(LIBRARIES INTERFACE tmp_LIBRARIES_INTERFACE)
set(${_opt_LIBRARIES} ${tmp_LIBRARIES} ${tmp_LIBRARIES_INTERFACE} PARENT_SCOPE)
endif()
endfunction()
# ------------------------------------------------------------------------------
# Get export list for all activated packages
# ------------------------------------------------------------------------------
function(package_get_all_export_list export_list)
_package_get_variable_for_activated(EXPORT_LIST _tmp)
set(${export_list} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get definitions like external projects
# ------------------------------------------------------------------------------
function(package_get_all_definitions definitions)
_package_get_variable_for_activated(OPTION_NAME _tmp)
set(${definitions} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get extra dependencies like external projects
# ------------------------------------------------------------------------------
function(package_get_all_extra_dependencies deps)
_package_get_variable_for_activated(EXTRA_DEPENDENCY _tmp)
set(${deps} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get extra infos
# ------------------------------------------------------------------------------
function(package_get_all_test_folders TEST_DIRS)
_package_get_variable_for_activated(TEST_FOLDER _tmp)
set(${TEST_DIRS} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get compilation flags
# ------------------------------------------------------------------------------
function(package_get_all_compilation_flags LANG FLAGS)
_package_get_variable_for_activated(COMPILE_${LANG}_FLAGS _tmp_flags)
string(REPLACE ";" " " _flags "${_tmp_flags}")
set(${FLAGS} ${_flags} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Documentation informations
# ------------------------------------------------------------------------------
function(package_get_all_documentation_files doc_files)
set(_tmp_DOC_FILES)
package_get_all_activated_packages(_activated_list)
foreach(_pkg_name ${_activated_list})
_package_get_manual_folder(${_pkg_name} _doc_dir)
_package_get_documentation_files(${_pkg_name} _doc_files)
foreach(_doc_file ${_doc_files})
list(APPEND _tmp_DOC_FILES ${_doc_dir}/${_doc_file})
endforeach()
endforeach()
if(_tmp_DOC_FILES)
list(REMOVE_DUPLICATES _tmp_DOC_FILES)
endif()
set(${doc_files} ${_tmp_DOC_FILES} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Get package systems dependencies
# ------------------------------------------------------------------------------
function(package_get_all_package_system_dependency system deps)
string(TOUPPER ${system} _u_system)
_package_get_variable_for_activated(PACKAGE_SYSTEM_${_u_system} _tmp)
set(${deps} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# List packages
# ------------------------------------------------------------------------------
function(package_get_all_activated_packages activated_list)
package_get_project_variable(ACTIVATED_PACKAGE_LIST _activated_list)
set(${activated_list} ${_activated_list} PARENT_SCOPE)
endfunction()
function(package_get_all_deactivated_packages deactivated_list)
package_get_project_variable(DEACTIVATED_PACKAGE_LIST _deactivated_list)
set(${deactivated_list} ${_deactivated_list} PARENT_SCOPE)
endfunction()
function(package_get_all_packages packages_list)
package_get_project_variable(ALL_PACKAGES_LIST _packages_list)
set(${packages_list} ${_packages_list} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# List all the needed features
# ------------------------------------------------------------------------------
function(package_get_all_features_public features)
_package_get_variable_for_activated(FEATURES_PUBLIC _tmp)
set(${features} ${_tmp} PARENT_SCOPE)
endfunction()
function(package_get_all_features_private features)
_package_get_variable_for_activated(FEATURES_PRIVATE _tmp)
set(${features} ${_tmp} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Callbacks
# ------------------------------------------------------------------------------
function(package_on_enabled_script pkg script)
package_get_name(${pkg} _pkg_name)
_package_on_enable_script(${_pkg_name} "${script}")
endfunction()
# ------------------------------------------------------------------------------
# list all the packages in the PACKAGE_FOLDER
# extra packages can be given with an EXTRA_PACKAGE_FOLDER
# <package_folder>/<package>.cmake
#
# Extra packages folder structure
# <extra_package_folder>/<package>/package.cmake
# /src
# /test
# /manual
#
# ------------------------------------------------------------------------------
function(package_list_packages PACKAGE_FOLDER)
cmake_parse_arguments(_opt_pkg
"NO_AUTO_COMPILE_FLAGS"
"SOURCE_FOLDER;EXTRA_PACKAGES_FOLDER;TEST_FOLDER;MANUAL_FOLDER"
""
${ARGN})
string(TOUPPER ${PROJECT_NAME} _project)
# Cleaning some states to start correctly
package_get_all_packages(_already_loaded_pkg)
foreach(_pkg_name ${_already_loaded_pkg})
_package_unset_extra_dependencies(${_pkg_name})
_package_unset_dependencies(${_pkg_name} PRIVATE)
_package_unset_dependencies(${_pkg_name} INTERFACE)
_package_unset_activated(${_pkg_name})
endforeach()
if(_opt_pkg_SOURCE_FOLDER)
set(_src_folder "${_opt_pkg_SOURCE_FOLDER}")
else()
set(_src_folder "src/")
endif()
get_filename_component(_abs_src_folder ${_src_folder} ABSOLUTE)
if(_opt_pkg_TEST_FOLDER)
set(_test_folder "${_opt_pkg_TEST_FOLDER}")
else()
set(_test_folder "test/")
endif()
if(_opt_pkg_MANUAL_FOLDER)
set(_manual_folder "${_opt_pkg_MANUAL_FOLDER}")
else()
set(_manual_folder "doc/manual")
endif()
if(_opt_pkg_NO_AUTO_COMPILE_FLAGS)
package_set_project_variable(NO_AUTO_COMPILE_FLAGS TRUE)
else()
package_set_project_variable(NO_AUTO_COMPILE_FLAGS FALSE)
endif()
get_filename_component(_abs_test_folder ${_test_folder} ABSOLUTE)
get_filename_component(_abs_manual_folder ${_manual_folder} ABSOLUTE)
# check all the packages in the <package_folder>
file(GLOB _package_list "${PACKAGE_FOLDER}/*.cmake")
set(_package_files)
foreach(_pkg ${_package_list})
get_filename_component(_basename ${_pkg} NAME)
if(NOT _basename MATCHES "^\\.#.*")
list(APPEND _package_files ${_basename})
endif()
endforeach()
if(_package_files)
list(SORT _package_files)
endif()
# check all packages
set(_packages_list_all)
foreach(_pkg_file ${_package_files})
string(REGEX REPLACE "[0-9]+_" "" _pkg_file_stripped ${_pkg_file})
string(REGEX REPLACE "\\.cmake" "" _pkg ${_pkg_file_stripped})
set(_current_src_folder "${_abs_src_folder}" CACHE INTERNAL "" FORCE)
set(_current_test_folder "${_abs_test_folder}" CACHE INTERNAL "" FORCE)
set(_current_manual_folder "${_abs_manual_folder}" CACHE INTERNAL "" FORCE)
include("${PACKAGE_FOLDER}/${_pkg_file}")
unset(_current_src_folder CACHE)
unset(_current_test_folder CACHE)
unset(_current_manual_folder CACHE)
endforeach()
# check the extra_packages if they exists
if(_opt_pkg_EXTRA_PACKAGES_FOLDER)
file(GLOB _extra_package_list RELATIVE
"${_opt_pkg_EXTRA_PACKAGES_FOLDER}" "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/*")
foreach(_pkg ${_extra_package_list})
if(EXISTS "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/package.cmake")
package_get_name(${_pkg} _pkg_name)
_package_set_filename(${_pkg_name}
"${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/package.cmake")
set(_current_src_folder "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/src" CACHE INTERNAL "" FORCE)
if(EXISTS "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/test")
set(_current_test_folder "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/test" CACHE INTERNAL "" FORCE)
endif()
if(EXISTS "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/manual")
set(_current_manual_folder "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/manual" CACHE INTERNAL "" FORCE)
endif()
list(APPEND _extra_pkg_src_folders "${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/src")
include("${_opt_pkg_EXTRA_PACKAGES_FOLDER}/${_pkg}/package.cmake")
unset(_current_src_folder CACHE)
unset(_current_test_folder CACHE)
unset(_current_manual_folder CACHE)
endif()
endforeach()
endif()
_package_build_rdependencies()
_package_load_packages()
_package_check_files_exists()
_package_check_files_registered(${_abs_src_folder} ${_extra_pkg_src_folders})
# Load boost components if boost was loaded
package_is_activated(Boost _ret)
if(_ret)
_package_load_boost_components()
endif()
endfunction()
# ------------------------------------------------------------------------------
# macro to include internal/external packages packages
# package_declare(<package real name>
# [EXTERNAL] [META] [ADVANCED] [NOT_OPTIONAL]
# [DESCRIPTION <description>] [DEFAULT <default_value>]
# [DEPENDS <pkg> ...]
# [BOOST_COMPONENTS <pkg> ...]
# [EXTRA_PACKAGE_OPTIONS <opt> ...]
# [COMPILE_FLAGS <lang> <flags>]
# [SYSTEM <bool> [ <script_to_compile> ]]
# [FEATURES_PUBLIC <feature> ...]
# [FEATURES_PRIVATE <feature> ...])
# ------------------------------------------------------------------------------
function(package_declare pkg)
package_get_name(${pkg} _pkg_name)
_package_set_real_name(${_pkg_name} ${pkg})
_package_set_filename(${_pkg_name} "${CMAKE_CURRENT_LIST_FILE}")
_package_set_sources_folder(${_pkg_name} "${_current_src_folder}")
_package_variable_unset(SRCS ${_pkg_name})
_package_variable_unset(PUBLIC_HEADERS ${_pkg_name})
_package_variable_unset(PRIVATE_HEADERS ${_pkg_name})
if(_current_test_folder)
_package_set_tests_folder(${_pkg_name} "${_current_test_folder}")
endif()
if(_current_manual_folder)
_package_set_manual_folder(${_pkg_name} "${_current_manual_folder}")
endif()
package_get_project_variable(ALL_PACKAGES_LIST _tmp_pkg_list)
list(APPEND _tmp_pkg_list ${_pkg_name})
list(REMOVE_DUPLICATES _tmp_pkg_list)
package_set_project_variable(ALL_PACKAGES_LIST ${_tmp_pkg_list})
set(_options
EXTERNAL
NOT_OPTIONAL
META
ADVANCED
EXCLUDE_FROM_ALL)
set(_one_valued_options
DEFAULT
DESCRIPTION)
set(_multi_valued_options
DEPENDS
EXTRA_PACKAGE_OPTIONS
COMPILE_FLAGS
BOOST_COMPONENTS
SYSTEM
FEATURES_PUBLIC
FEATURES_PRIVATE)
cmake_parse_arguments(_opt_pkg
"${_options}"
"${_one_valued_options}"
"${_multi_valued_options}"
${ARGN})
if(_opt_pkg_UNPARSED_ARGUMENTS)
message("You gave to many arguments while registering the package ${pkg} \"${_opt_pkg_UNPARSED_ARGUMENTS}\"")
endif()
# set the nature
if(_opt_pkg_EXTERNAL)
_package_set_nature(${_pkg_name} "external")
elseif(_opt_pkg_META)
_package_set_nature(${_pkg_name} "meta")
else()
_package_set_nature(${_pkg_name} "internal")
endif()
_package_declare_option(${_pkg_name})
# set description
if(_opt_pkg_DESCRIPTION)
_package_set_description(${_pkg_name} ${_opt_pkg_DESCRIPTION})
else()
_package_set_description(${_pkg_name} "")
endif()
_package_get_option_name(${_pkg_name} _option_name)
_package_get_description(${_pkg_name} _description)
# get the default value
if(DEFINED _opt_pkg_DEFAULT)
set(_default ${_opt_pkg_DEFAULT})
else()
if(_opt_pkg_NOT_OPTIONAL)
set(_default ON)
else()
set(_default OFF)
endif()
endif()
# set the option if needed
if(_opt_pkg_NOT_OPTIONAL)
_package_get_nature(${_pkg_name} _nature)
_package_set_nature(${_pkg_name} "${_nature}_not_optional")
set(${_option_name} ${_default} CACHE INTERNAL "${_description}" FORCE)
mark_as_advanced(${_option_name})
else()
option(${_option_name} "${_description}" ${_default})
if(_opt_pkg_ADVANCED OR _opt_pkg_EXTERNAL)
mark_as_advanced(${_option_name})
endif()
endif()
# Set the option for third-partie that can be compiled as an ExternalProject
if(DEFINED _opt_pkg_SYSTEM)
list(LENGTH _opt_pkg_SYSTEM _length)
list(GET _opt_pkg_SYSTEM 0 _bool)
_package_set_system_option(${_pkg_name} ${_bool})
if(_length GREATER 1)
list(GET _opt_pkg_SYSTEM 1 _script)
_package_set_system_script(${_pkg_name} ${_script})
endif()
endif()
# set the dependecies
if(_opt_pkg_DEPENDS)
set(_deps_types PRIVATE PUBLIC INTERFACE)
cmake_parse_arguments(_pkg_deps
""
""
"${_deps_types}"
${_opt_pkg_DEPENDS})
list(APPEND _pkg_deps_PRIVATE ${_pkg_deps_UNPARSED_ARGUMENTS})
foreach(_type ${_deps_types})
set(_depends)
foreach(_dep ${_pkg_deps_${_type}})
package_get_name(${_dep} _dep_pkg_name)
list(APPEND _depends ${_dep_pkg_name})
endforeach()
_package_add_dependencies(${_pkg_name} ${_type} ${_depends})
endforeach()
endif()
# keep the extra option for the future find package
if(_opt_pkg_EXTRA_PACKAGE_OPTIONS)
_package_set_find_package_extra_options(${_pkg_name} "${_opt_pkg_EXTRA_PACKAGE_OPTIONS}")
endif()
# register the compilation flags
if(_opt_pkg_COMPILE_FLAGS)
set(_languages C CXX Fortran)
cmake_parse_arguments(_compile_flags
"" "" "${_languages}"
${_opt_pkg_COMPILE_FLAGS}
)
# this is done to maintain backward compatibility
if(_compile_flags_UNPARSED_ARGUMENTS)
set(_compile_flags_CXX ${_compile_flags_UNPARSED_ARGUMENTS})
endif()
foreach(_lang ${_languages})
if(_compile_flags_${_lang})
_package_set_compile_flags(${_pkg_name} ${_lang} ${_compile_flags_${_lang}})
else()
_package_unset_compile_flags(${_pkg_name} ${_lang})
endif()
endforeach()
endif()
# set the boost dependencies
if(_opt_pkg_BOOST_COMPONENTS)
_package_set_boost_component_needed(${_pkg_name} "${_opt_pkg_BOOST_COMPONENTS}")
endif()
set(_variables FEATURES_PUBLIC FEATURES_PRIVATE EXCLUDE_FROM_ALL)
foreach(_variable ${_variables})
if(_opt_pkg_${_variable})
_package_set_variable(${_variable} ${_pkg_name} "${_opt_pkg_${_variable}}")
endif()
endforeach()
endfunction()
# ------------------------------------------------------------------------------
# declare the source files of a given package
#
# package_declare_sources(<package> <list of sources>
# SOURCES <source file> ...
# PUBLIC_HEADER <header file> ...
# PRIVATE_HEADER <header file> ...)
# ------------------------------------------------------------------------------
function(package_declare_sources pkg)
package_get_name(${pkg} _pkg_name)
# get 3 lists, if none of the options given try to distinguish the different lists
cmake_parse_arguments(_opt_pkg
""
""
"SOURCES;PUBLIC_HEADERS;PRIVATE_HEADERS"
${ARGN})
set(_tmp_srcs ${_opt_pkg_SOURCES})
set(_tmp_pub_hdrs ${_opt_pkg_PUBLIC_HEADER})
set(_tmp_pri_hdrs ${_opt_pkg_PRIVATE_HEADERS})
foreach(_file ${_opt_pkg_UNPARSED_ARGUMENTS})
if(${_file} MATCHES ".*inline.*\\.cc")
list(APPEND _tmp_pub_hdrs ${_file})
elseif(${_file} MATCHES ".*\\.h+")
list(APPEND _tmp_pub_hdrs ${_file})
else()
list(APPEND _tmp_srcs ${_file})
endif()
endforeach()
_package_get_sources_folder(${_pkg_name} _src_folder)
foreach(_type _srcs _pub_hdrs _pri_hdrs)
set(${_type})
foreach(_file ${_tmp${_type}})
# get the full name
set(_full_path "${_src_folder}/${_file}")
list(APPEND ${_type} "${_full_path}")
endforeach()
endforeach()
set(${_pkg_name}_SRCS "${_srcs}"
CACHE INTERNAL "List of sources files" FORCE)
set(${_pkg_name}_PUBLIC_HEADERS "${_pub_hdrs}"
CACHE INTERNAL "List of public header files" FORCE)
set(${_pkg_name}_PRIVATE_HEADERS "${_pri_hdrs}"
CACHE INTERNAL "List of private header files" FORCE)
endfunction()
# ------------------------------------------------------------------------------
diff --git a/cmake/Modules/CMakePackagesSystemGlobalFunctions.cmake b/cmake/Modules/CMakePackagesSystemGlobalFunctions.cmake
index 2d8c1a484..cd91211b8 100644
--- a/cmake/Modules/CMakePackagesSystemGlobalFunctions.cmake
+++ b/cmake/Modules/CMakePackagesSystemGlobalFunctions.cmake
@@ -1,132 +1,134 @@
#===============================================================================
# @file CMakePackagesSystemGlobalFunctions.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sat Jul 18 2015
-# @date last modification: Mon Jan 18 2016
+# @date last modification: Fri Mar 16 2018
#
# @brief Set of macros used by the package system to set internal variables
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
# ==============================================================================
# Package system meta functions
# ==============================================================================
function(package_set_project_variable variable)
string(TOUPPER ${PROJECT_NAME} _u_project)
set(${_u_project}_${variable} "${ARGN}" CACHE INTERNAL "" FORCE)
endfunction()
function(package_get_project_variable variable value_out)
string(TOUPPER ${PROJECT_NAME} _u_project)
set(${value_out} ${${_u_project}_${variable}} PARENT_SCOPE)
endfunction()
function(package_add_to_project_variable variable)
package_get_project_variable(${variable} _tmp_list)
list(APPEND _tmp_list ${ARGN})
if(_tmp_list)
list(REMOVE_DUPLICATES _tmp_list)
endif()
package_set_project_variable(${variable} ${_tmp_list})
endfunction()
# ==============================================================================
function(_package_set_variable variable pkg_name)
set(${pkg_name}_${variable} ${ARGN} CACHE INTERNAL "" FORCE)
endfunction()
function(_package_get_variable variable pkg_name value)
#unset(${value} PARENT_SCOPE)
if(DEFINED ${pkg_name}_${variable})
set(${value} ${${pkg_name}_${variable}} PARENT_SCOPE)
elseif(DEFINED ARGN)
set(${value} ${ARGN} PARENT_SCOPE)
else()
set(${value} PARENT_SCOPE)
endif()
endfunction()
# ==============================================================================
function(_package_variable_unset variable pkg_name)
unset(${pkg_name}_${variable} CACHE)
endfunction()
# ==============================================================================
function(_package_add_to_variable variable pkg_name)
_package_get_variable(${variable} ${pkg_name} _tmp_list)
list(APPEND _tmp_list ${ARGN})
if(_tmp_list)
list(REMOVE_DUPLICATES _tmp_list)
endif()
_package_set_variable(${variable} ${pkg_name} ${_tmp_list})
endfunction()
function(_package_remove_from_variable variable pkg_name value)
_package_get_variable(${variable} ${pkg_name} _tmp_list)
list(LENGTH _tmp_list _length)
if(_length GREATER 0)
list(REMOVE_ITEM _tmp_list ${value})
_package_set_variable(${variable} ${pkg_name} ${_tmp_list})
endif()
endfunction()
# ==============================================================================
function(_package_get_variable_for_packages variable values)
set(_list_values)
foreach(_pkg_name ${ARGN})
_package_get_variable(${variable} ${_pkg_name} _value)
list(APPEND _list_values ${_value})
endforeach()
if (_list_values)
list(REMOVE_DUPLICATES _list_values)
endif()
set(${values} ${_list_values} PARENT_SCOPE)
endfunction()
# ==============================================================================
function(_package_get_variable_for_activated variable values)
package_get_all_activated_packages(_activated_list)
_package_get_variable_for_packages(${variable} _list_values ${_activated_list})
set(${values} ${_list_values} PARENT_SCOPE)
endfunction()
# ==============================================================================
function(_package_get_variable_for_external_dependencies variable type values)
set(_list_packages)
package_get_all_activated_packages(_activated_list)
foreach(_pkg_name ${_activated_list})
_package_get_nature(${_pkg_name} _nature)
if(_nature MATCHES "^external.*")
list(APPEND _list_packages ${_pkg_name})
endif()
endforeach()
if (_list_packages)
list(REMOVE_DUPLICATES _list_packages)
_package_get_variable_for_packages(${variable} _list_values_deps ${_list_packages})
set(${values} ${_list_values_deps} PARENT_SCOPE)
endif()
endfunction()
# ==============================================================================
diff --git a/cmake/Modules/CMakePackagesSystemPrivateFunctions.cmake b/cmake/Modules/CMakePackagesSystemPrivateFunctions.cmake
index d1a58736a..42eca6811 100644
--- a/cmake/Modules/CMakePackagesSystemPrivateFunctions.cmake
+++ b/cmake/Modules/CMakePackagesSystemPrivateFunctions.cmake
@@ -1,981 +1,984 @@
#===============================================================================
# @file CMakePackagesSystemPrivateFunctions.cmake
#
+# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sat Jul 18 2015
-# @date last modification: Wed Jan 20 2016
+# @date last modification: Mon Mar 08 2021
#
# @brief Set of macros used by the package system, internal functions
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
if (DEFINED CMAKE_PACKAGES_SYSTEM_PRIVATE_FUNCTIONS_LOADED)
return()
endif()
set(CMAKE_PACKAGES_SYSTEM_PRIVATE_FUNCTIONS_LOADED TRUE)
# ==============================================================================
# "Private" Accessors
# ==============================================================================
# ------------------------------------------------------------------------------
# Real name
# ------------------------------------------------------------------------------
function(_package_get_real_name pkg_name real_name)
set(${real_name} ${${pkg_name}} PARENT_SCOPE)
endfunction()
function(_package_set_real_name pkg_name real_name)
set(${pkg_name} ${real_name} CACHE INTERNAL "" FORCE)
endfunction()
# ------------------------------------------------------------------------------
# Option name
# ------------------------------------------------------------------------------
function(_package_declare_option pkg_name)
string(TOUPPER "${PROJECT_NAME}" _project)
_package_get_real_name(${pkg_name} _real_name)
string(TOUPPER "${_real_name}" _u_package)
_package_get_nature(${pkg_name} _nature)
if(${_nature} MATCHES "internal" OR ${_nature} MATCHES "meta")
set(_opt_name ${_project}_${_u_package})
elseif(${_nature} MATCHES "external")
set(_opt_name ${_project}_USE_${_u_package})
else()
set(_opt_name UNKNOWN_NATURE_${_project}_${_u_package})
endif()
_package_set_variable(OPTION_NAME ${pkg_name} ${_opt_name})
endfunction()
function(_package_get_option_name pkg_name opt_name)
_package_get_variable(OPTION_NAME ${pkg_name} _opt_name)
set(${opt_name} ${_opt_name} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Set if system package or compile external lib
# ------------------------------------------------------------------------------
function(_package_set_system_option pkg_name default)
string(TOUPPER "${PROJECT_NAME}" _project)
_package_get_real_name(${pkg_name} _real_name)
string(TOUPPER "${_real_name}" _u_package)
set(${_project}_USE_SYSTEM_${_u_package} ${default} CACHE STRING
"Should akantu compile the third-party: \"${_real_name}\"")
mark_as_advanced(${_project}_USE_SYSTEM_${_u_package})
set_property(CACHE ${_project}_USE_SYSTEM_${_u_package} PROPERTY STRINGS ON OFF AUTO)
endfunction()
function(_package_use_system pkg_name use)
string(TOUPPER "${PROJECT_NAME}" _project)
_package_get_real_name(${pkg_name} _real_name)
string(TOUPPER "${_real_name}" _u_package)
if(DEFINED ${_project}_USE_SYSTEM_${_u_package})
if(${${_project}_USE_SYSTEM_${_u_package}} MATCHES "(ON|AUTO)")
set(${use} TRUE PARENT_SCOPE)
else()
set(${use} FALSE PARENT_SCOPE)
endif()
else()
set(${use} TRUE PARENT_SCOPE)
endif()
endfunction()
function(_package_has_system_fallback pkg_name fallback)
string(TOUPPER "${PROJECT_NAME}" _project)
_package_get_real_name(${pkg_name} _real_name)
string(TOUPPER "${_real_name}" _u_package)
if(DEFINED ${_project}_USE_SYSTEM_${_u_package})
if(${${_project}_USE_SYSTEM_${_u_package}} MATCHES "AUTO")
set(${fallback} TRUE PARENT_SCOPE)
else()
set(${fallback} FALSE PARENT_SCOPE)
endif()
else()
set(${fallback} FALSE PARENT_SCOPE)
endif()
endfunction()
function(_package_set_system_script pkg_name script)
_package_set_variable(COMPILE_SCRIPT ${pkg_name} "${script}")
endfunction()
function(_package_add_third_party_script_variable pkg_name var)
_package_set_variable(VARIABLE_${var} ${pkg_name} "${ARGN}")
set(${var} ${ARGN} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
function(_package_load_third_party_script pkg_name)
if(${pkg_name}_COMPILE_SCRIPT)
# set the stored variable
get_cmake_property(_all_vars VARIABLES)
foreach(_var ${_all_vars})
if(_var MATCHES "^${pkg_name}_VARIABLE_.*")
string(REPLACE "${pkg_name}_VARIABLE_" "" _orig_var "${_var}")
set(${_orig_var} ${${_var}})
endif()
endforeach()
_package_get_real_name(${pkg_name} _name)
string(TOUPPER "${_name}" _u_name)
_package_get_option_name(${pkg_name} _opt_name)
if(${_opt_name}_VERSION)
set(_version "${${_opt_name}_VERSION}")
set(${_u_name}_VERSION "${_version}" CACHE INTERNAL "" FORCE)
elseif(${_u_name}_VERSION)
set(_version "${${_u_name}_VERSION}")
endif()
# load the script
include(ExternalProject)
include(${${pkg_name}_COMPILE_SCRIPT})
if(${_u_name}_LIBRARIES)
_package_set_libraries(${pkg_name} ${${_u_name}_LIBRARIES})
list(APPEND _required_vars ${_u_name}_LIBRARIES)
endif()
if(${_u_name}_INCLUDE_DIR)
_package_set_include_dir(${pkg_name} ${${_u_name}_INCLUDE_DIR})
list(APPEND _required_vars ${_u_name}_INCLUDE_DIR)
endif()
include(FindPackageHandleStandardArgs)
if (NOT _required_vars)
message(FATAL_ERROR "The package ${_name} does not define any of the variables ${_u_name}_INCLUDE_DIR nor ${_u_name}_LIBRARIES")
endif()
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
find_package_handle_standard_args(${_name}
REQUIRED_VARS ${_required_vars}
VERSION_VAR _version
FAIL_MESSAGE "Something was not configured by a the third-party script for ${_name}"
)
else()
find_package_handle_standard_args(${_name}
"Something was not configured by a the third-party script for ${_name}"
${_required_vars}
)
endif()
endif()
set(${pkg_name}_USE_SYSTEM_PREVIOUS FALSE CACHE INTERNAL "" FORCE)
endfunction()
# ------------------------------------------------------------------------------
# Nature
# ------------------------------------------------------------------------------
function(_package_set_nature pkg_name nature)
_package_set_variable(NATURE ${pkg_name} ${nature})
endfunction()
function(_package_get_nature pkg_name nature)
_package_get_variable(NATURE ${pkg_name} _nature "unknown")
set(${nature} ${_nature} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Description
# ------------------------------------------------------------------------------
function(_package_set_description pkg_name desc)
_package_set_variable(DESC ${pkg_name} ${desc})
endfunction()
function(_package_get_description pkg_name desc)
_package_get_variable(DESC ${pkg_name} _desc "No description set for the package ${${pkg_name}} (${pkg_name})")
set(${desc} ${_desc} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Package file name
# ------------------------------------------------------------------------------
function(_package_set_filename pkg_name file)
_package_set_variable(FILE ${pkg_name} ${file})
endfunction()
function(_package_get_filename pkg_name file)
_package_get_variable(FILE ${pkg_name} _file "No filename set for the package ${${pkg_name}}")
set(${file} ${_file} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Source folder
# ------------------------------------------------------------------------------
function(_package_set_sources_folder pkg_name src_folder)
_package_set_variable(SRC_FOLDER ${pkg_name} ${src_folder})
endfunction()
function(_package_get_sources_folder pkg_name src_folder)
_package_get_variable(SRC_FOLDER ${pkg_name} _src_folder)
set(${src_folder} ${_src_folder} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Test folder
# ------------------------------------------------------------------------------
function(_package_set_tests_folder pkg_name test_folder)
_package_set_variable(TEST_FOLDER ${pkg_name} ${test_folder})
endfunction()
function(_package_get_tests_folder pkg_name test_folder)
_package_get_variable(TEST_FOLDER ${pkg_name} _test_folder)
set(${test_folder} ${_test_folder} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Manual folder
# ------------------------------------------------------------------------------
function(_package_set_manual_folder pkg_name manual_folder)
_package_set_variable(MANUAL_FOLDER ${pkg_name} ${manual_folder})
endfunction()
function(_package_get_manual_folder pkg_name manual_folder)
_package_get_variable(MANUAL_FOLDER ${pkg_name} _manual_folder)
set(${manual_folder} ${_manual_folder} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Extra option for the find_package
# ------------------------------------------------------------------------------
function(_package_set_find_package_extra_options pkg_name)
_package_set_variable(FIND_PKG_OPTIONS ${pkg_name} ${ARGN})
endfunction()
function(_package_get_find_package_extra_options pkg_name options)
_package_get_variable(FIND_PKG_OPTIONS ${pkg_name} _options)
set(${options} ${_options} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Compilation flags
# ------------------------------------------------------------------------------
function(_package_set_compile_flags pkg_name lang)
_package_set_variable(COMPILE_${lang}_FLAGS ${pkg_name} ${ARGN})
endfunction()
function(_package_unset_compile_flags pkg_name lang)
_package_variable_unset(COMPILE_${lang}_FLAGS ${pkg_name})
endfunction()
function(_package_get_compile_flags pkg_name lang flags)
_package_get_variable(COMPILE_${lang}_FLAGS ${pkg_name} _tmp_flags)
string(REPLACE ";" " " _flags "${_tmp_flags}")
set(${flags} "${_flags}" PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Include dir
# ------------------------------------------------------------------------------
function(_package_set_include_dir pkg_name)
_package_set_variable(INCLUDE_DIR ${pkg_name} ${ARGN})
endfunction()
function(_package_get_include_dir pkg_name include_dir)
_package_get_variable(INCLUDE_DIR ${pkg_name} _include_dir "")
set(${include_dir} ${_include_dir} PARENT_SCOPE)
endfunction()
function(_package_add_include_dir pkg_name)
_package_add_to_variable(INCLUDE_DIR ${pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Libraries
# ------------------------------------------------------------------------------
function(_package_set_libraries pkg_name)
_package_set_variable(LIBRARIES ${pkg_name} ${ARGN})
endfunction()
function(_package_get_libraries pkg_name libraries)
_package_get_variable(LIBRARIES ${pkg_name} _libraries "")
set(${libraries} ${_libraries} PARENT_SCOPE)
endfunction()
function(_package_add_libraries pkg_name)
_package_add_to_variable(LIBRARIES ${pkg_name} ${ARGN})
endfunction()
# ------------------------------------------------------------------------------
# Extra dependencies like custom commands of ExternalProject
# ------------------------------------------------------------------------------
function(_package_add_extra_dependency pkg_name)
_package_add_to_variable(EXTRA_DEPENDENCY ${pkg_name} ${ARGN})
endfunction()
function(_package_rm_extra_dependency pkg_name dep)
_package_remove_from_variable(EXTRA_DEPENDENCY ${pkg_name} ${dep})
endfunction()
function(_package_set_extra_dependencies pkg)
_package_set_variable(EXTRA_DEPENDENCY ${pkg_name} ${ARGN})
endfunction()
function(_package_get_extra_dependencies pkg deps)
_package_get_variable(EXTRA_DEPENDENCY ${pkg_name} _deps "")
set(${deps} ${_deps} PARENT_SCOPE)
endfunction()
function(_package_unset_extra_dependencies pkg_name)
_package_variable_unset(EXTRA_DEPENDENCY ${pkg_name})
endfunction()
# ------------------------------------------------------------------------------
# Activate/deactivate
# ------------------------------------------------------------------------------
function(_package_activate pkg_name)
_package_set_variable(STATE ${pkg_name} ON)
endfunction()
function(_package_deactivate pkg_name)
_package_set_variable(STATE ${pkg_name} OFF)
endfunction()
function(_package_is_activated pkg_name act)
_package_get_variable(STATE ${pkg_name} _state OFF)
if(_state)
set(${act} TRUE PARENT_SCOPE)
else()
set(${act} FALSE PARENT_SCOPE)
endif()
endfunction()
function(_package_is_deactivated pkg_name act)
_package_get_variable(STATE ${pkg_name} _state OFF)
if(NOT _state)
set(${act} TRUE PARENT_SCOPE)
else()
set(${act} FALSE PARENT_SCOPE)
endif()
endfunction()
function(_package_unset_activated pkg_name)
_package_variable_unset(STATE ${pkg_name})
endfunction()
# ------------------------------------------------------------------------------
# Callbacks
# ------------------------------------------------------------------------------
function(_package_on_enable_script pkg_name script)
string(TOLOWER "${pkg_name}" _l_pkg_name)
set(_output_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_l_pkg_name}.cmake")
file(WRITE "${_output_file}"
"${script}")
_package_set_variable(CALLBACK_SCRIPT ${pkg_name} "${_output_file}")
endfunction()
function(_package_get_callback_script pkg_name filename)
_package_get_variable(CALLBACK_SCRIPT ${pkg_name} _filename NOTFOUND)
set(${filename} ${_filename} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Export list
# ------------------------------------------------------------------------------
function(_package_add_to_export_list pkg_name)
_package_add_to_variable(EXPORT_LIST ${pkg_name} ${ARGN})
endfunction()
function(_package_remove_from_export_list pkg_name)
_package_remove_from_variable(EXPORT_LIST ${pkg_name} ${ARGN})
endfunction()
function(_package_get_export_list pkg_name export_list)
_package_get_variable(EXPORT_LIST ${pkg_name} _export_list)
set(${export_list} ${_export_list} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Direct dependencies
# ------------------------------------------------------------------------------
function(_package_add_dependencies pkg_name type)
_package_add_to_variable(DEPENDENCIES_${type} ${pkg_name} ${ARGN})
endfunction()
function(_package_get_dependencies pkg_name type dependencies)
_package_get_variable(DEPENDENCIES_${type} ${pkg_name} _dependencies)
set(${dependencies} ${_dependencies} PARENT_SCOPE)
endfunction()
function(_package_unset_dependencies pkg_name type)
_package_variable_unset(DEPENDENCIES_${type} ${pkg_name})
endfunction()
function(_package_remove_dependency pkg_name type dep)
set(_deps ${${pkg_name}_DEPENDENCIES_${type}})
_package_get_fdependencies(${dep} _fdeps)
# check if this is the last reverse dependency
list(LENGTH _fdeps len)
list(FIND _fdeps ${pkg_name} pos)
if((len EQUAL 1) AND (NOT pos EQUAL -1))
_package_get_description(${dep} _dep_desc)
_package_get_option_name(${dep} _dep_option_name)
set(${_dep_option_name} ${${dep}_OLD} CACHE BOOL "${_dep_desc}" FORCE)
unset(${dep}_OLD CACHE)
endif()
# remove the pkg_name form the reverse dependency
_package_remove_fdependency(${dep} ${pkg_name})
list(FIND _deps ${dep} pos)
if(NOT pos EQUAL -1)
list(REMOVE_AT _deps ${pos})
_package_set_variable(DEPENDENCIES_${type} ${pkg_name} ${_deps})
endif()
endfunction()
# ------------------------------------------------------------------------------
# Functions to handle reverse dependencies
# ------------------------------------------------------------------------------
function(_package_set_rdependencies pkg_name)
_package_set_variable(RDEPENDENCIES ${pkg_name} ${ARGN})
endfunction()
function(_package_get_rdependencies pkg_name rdependencies)
_package_get_variable(RDEPENDENCIES ${pkg_name} _rdependencies)
set(${rdependencies} ${_rdependencies} PARENT_SCOPE)
endfunction()
function(_package_add_rdependency pkg_name rdep)
# store the reverse dependency
_package_add_to_variable(RDEPENDENCIES ${pkg_name} ${rdep})
endfunction()
function(_package_remove_rdependency pkg_name rdep)
_package_remove_from_variable(RDEPENDENCIES ${pkg_name} ${rdep})
endfunction()
# ------------------------------------------------------------------------------
# Function to handle forcing dependencies (Package turn ON that enforce their
# dependencies ON)
# ------------------------------------------------------------------------------
function(_package_set_fdependencies pkg_name)
_package_set_variable(FDEPENDENCIES ${pkg_name} ${ARGN})
endfunction()
function(_package_get_fdependencies pkg_name fdependencies)
_package_get_variable(FDEPENDENCIES ${pkg_name} _fdependencies)
set(${fdependencies} ${_fdependencies} PARENT_SCOPE)
endfunction()
function(_package_add_fdependency pkg_name fdep)
# store the reverse dependency
_package_add_to_variable(FDEPENDENCIES ${pkg_name} ${fdep})
endfunction()
function(_package_remove_fdependency pkg_name fdep)
_package_remove_from_variable(FDEPENDENCIES ${pkg_name} ${fdep})
endfunction()
# ------------------------------------------------------------------------------
# Exteral package system as apt rpm dependencies
# ------------------------------------------------------------------------------
function(_package_set_package_system_dependency pkg system)
string(TOUPPER "${_system}" _u_system)
_package_set_variable(PACKAGE_SYSTEM_${_u_system} ${_pkg_name} ${ARGN})
endfunction()
function(_package_get_package_system_dependency pkg system var)
string(TOUPPER "${_system}" _u_system)
_package_get_variable(PACKAGE_SYSTEM_${_u_system} ${_pkg_name} ${_deps})
set(${var} ${_deps} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Documentation related functions
# ------------------------------------------------------------------------------
function(_package_set_documentation_files pkg_name)
_package_set_variable(DOCUMENTATION_FILES ${pkg_name} ${ARGN})
endfunction()
function(_package_get_documentation_files pkg_name doc_files)
_package_get_variable(DOCUMENTATION_FILES ${pkg_name} _doc_files "")
set(${doc_files} ${_doc_files} PARENT_SCOPE)
endfunction()
function(_package_set_documentation pkg_name)
# \n replaced by && and \\ by ££ to avoid cache problems
set(_doc_str "")
foreach(_str ${ARGN})
set(_doc_str "${_doc_str}&&${_str}")
endforeach()
string(REPLACE "\\" "££" _doc_escaped "${_doc_str}")
_package_set_variable(DOCUMENTATION ${pkg_name} "${_doc_str}")
endfunction()
function(_package_get_documentation pkg_name _doc)
# \n replaced by && and \\ by ££ to avoid cache problems
_package_get_variable(DOCUMENTATION ${pkg_name} _doc_tmp "")
string(REPLACE "££" "\\" _doc_escaped "${_doc_tmp}")
string(REPLACE "&&" "\n" _doc_newlines "${_doc_escaped}")
set(${_doc} "${_doc_newlines}" PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Special boost thingy
# ------------------------------------------------------------------------------
function(_package_set_boost_component_needed pkg_name)
_package_add_to_variable(BOOST_COMPONENTS_NEEDED ${pkg_name} ${ARGN})
package_get_name(Boost _boost_pkg_name)
_package_add_dependencies(${pkg_name} PRIVATE ${_boost_pkg_name})
endfunction()
function(_package_get_boost_component_needed pkg_name needed)
_package_get_variable(BOOST_COMPONENTS_NEEDED ${pkg_name} _needed)
set(${needed} ${_needed} PARENT_SCOPE)
endfunction()
function(_package_load_boost_components)
string(TOUPPER ${PROJECT_NAME} _project)
_package_get_variable_for_activated(BOOST_COMPONENTS_NEEDED _boost_needed_components)
package_get_name(Boost _pkg_name)
if(_boost_needed_components)
message(STATUS "Looking for Boost liraries: ${_boost_needed_components}")
foreach(_comp ${_boost_needed_components})
find_package(Boost COMPONENTS ${_comp} QUIET)
string(TOUPPER ${_comp} _u_comp)
if(Boost_${_u_comp}_FOUND)
message(STATUS " ${_comp}: FOUND")
package_set_project_variable(BOOST_${_u_comp} TRUE)
# Generate the libraries for the package
_package_add_libraries(${_pkg_name} ${Boost_${_u_comp}_LIBRARY})
else()
message(STATUS " ${_comp}: NOT FOUND")
endif()
endforeach()
endif()
endfunction()
# ------------------------------------------------------------------------------
# get the list of source files for a given package
# ------------------------------------------------------------------------------
function(_package_get_source_files pkg_name SRCS PUBLIC_HEADERS PRIVATE_HEADERS)
string(TOUPPER ${PROJECT_NAME} _project)
set(tmp_SRCS)
set(tmp_PUBLIC_HEADERS)
set(tmp_PRIVATE_HEADERS)
foreach(_type SRCS PUBLIC_HEADERS PRIVATE_HEADERS)
foreach(_file ${${pkg_name}_${_type}})
string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" _rel_file "${_file}")
list(APPEND tmp_${_type} "${_rel_file}")
endforeach()
endforeach()
set(${SRCS} ${tmp_SRCS} PARENT_SCOPE)
set(${PUBLIC_HEADERS} ${tmp_PUBLIC_HEADERS} PARENT_SCOPE)
set(${PRIVATE_HEADERS} ${tmp_PRIVATE_HEADERS} PARENT_SCOPE)
endfunction()
# ==============================================================================
# Internal functions
# ==============================================================================
# ------------------------------------------------------------------------------
# Build the reverse dependencies from the dependencies
# ------------------------------------------------------------------------------
function(_package_build_rdependencies)
package_get_all_packages(_pkg_list)
# set empty lists
foreach(_pkg_name ${_pkg_list})
set(${_pkg_name}_rdeps)
endforeach()
# fill the dependencies list
foreach(_pkg_name ${_pkg_list})
_package_get_dependencies(${_pkg_name} PRIVATE _deps_priv)
_package_get_dependencies(${_pkg_name} INTERFACE _deps_interface)
foreach(_dep_name ${_deps_priv} ${_deps_interface})
list(APPEND ${_dep_name}_rdeps ${_pkg_name})
endforeach()
endforeach()
# clean and set the reverse dependencies
foreach(_pkg_name ${_pkg_list})
if(${_pkg_name}_rdeps)
list(REMOVE_DUPLICATES ${_pkg_name}_rdeps)
_package_set_rdependencies(${_pkg_name} ${${_pkg_name}_rdeps})
endif()
endforeach()
endfunction()
# ------------------------------------------------------------------------------
# This function resolve the dependance order run the needed find_packages
# ------------------------------------------------------------------------------
function(_package_load_packages)
package_get_all_packages(_pkg_list)
# Activate the dependencies of activated package and generate an ordered list
# of dependencies
set(ordered_loading_list)
foreach(_pkg_name ${_pkg_list})
_package_load_dependencies_package(${_pkg_name} ordered_loading_list)
endforeach()
# Load the packages in the propoer order
foreach(_pkg_name ${ordered_loading_list})
_package_get_option_name(${_pkg_name} _option_name)
if(${_option_name})
_package_load_package(${_pkg_name})
else()
# deactivate the packages than can already be deactivated
_package_deactivate(${_pkg_name})
endif()
endforeach()
# generates the activated and unactivated lists of packages
set(_packages_activated)
set(_packages_deactivated)
foreach(_pkg_name ${_pkg_list})
_package_is_activated(${_pkg_name} _active)
set(_exclude FALSE)
_package_get_variable(EXCLUDE_FROM_ALL ${_pkg_name} _exclude)
if(_active AND NOT _exclude)
list(APPEND _packages_activated ${_pkg_name})
else()
list(APPEND _packages_deactivated ${_pkg_name})
endif()
endforeach()
# generate the list usable by the calling code
package_set_project_variable(ACTIVATED_PACKAGE_LIST "${_packages_activated}")
package_set_project_variable(DEACTIVATED_PACKAGE_LIST "${_packages_deactivated}")
endfunction()
# ------------------------------------------------------------------------------
# This load an external package and recursively all its dependencies
# ------------------------------------------------------------------------------
function(_package_load_dependencies_package pkg_name loading_list)
# Get packages informations
_package_get_option_name(${pkg_name} _pkg_option_name)
_package_get_dependencies(${pkg_name} PRIVATE _deps_private)
_package_get_dependencies(${pkg_name} INTERFACE _deps_interface)
set(_dependencies ${_deps_private} ${_deps_interface})
# handle the dependencies
foreach(_dep_name ${_dependencies})
_package_get_description(${_dep_name} _dep_desc)
_package_get_option_name(${_dep_name} _dep_option_name)
_package_get_fdependencies(${_dep_name} _fdeps)
if(${_pkg_option_name})
if("${_fdeps}" STREQUAL "")
set(${_dep_name}_OLD ${${_dep_option_name}} CACHE INTERNAL "" FORCE)
endif()
# set the option to on
set(_type BOOL)
_package_get_nature(${_dep_name} _nature)
if(_nature MATCHES ".*not_optional$")
set(_type INTERNAL)
endif()
set(${_dep_option_name} ON CACHE BOOL "${_dep_desc}" FORCE)
# store the reverse dependency
_package_add_fdependency(${_dep_name} ${pkg_name})
else()
# check if this is the last reverse dependency
list(LENGTH _fdeps len)
list(FIND _fdeps ${pkg_name} pos)
if((len EQUAL 1) AND (NOT pos EQUAL -1))
set(${_dep_option_name} ${${_dep_name}_OLD} CACHE BOOL "${_dep_desc}" FORCE)
unset(${_dep_name}_OLD CACHE)
endif()
# remove the pkg_name form the reverse dependency
_package_remove_fdependency(${_dep_name} ${pkg_name})
endif()
# recusively load the dependencies
_package_load_dependencies_package(${_dep_name} ${loading_list})
endforeach()
# get the compile flags
_package_get_compile_flags(${pkg_name} CXX _pkg_compile_flags)
package_get_project_variable(NO_AUTO_COMPILE_FLAGS _no_auto_compile_flags)
# if package option is on add it in the list
if(${_pkg_option_name})
list(FIND ${loading_list} ${pkg_name} _pos)
if(_pos EQUAL -1)
set(_tmp_loading_list ${${loading_list}})
list(APPEND _tmp_loading_list ${pkg_name})
set(${loading_list} "${_tmp_loading_list}" PARENT_SCOPE)
endif()
#add the comilation flags if needed
if(_pkg_compile_flags AND NOT _no_auto_compile_flags)
add_flags(cxx ${_pkg_compile_flags})
endif()
else()
#remove the comilation flags if needed
if(_pkg_comile_flags AND NOT _no_auto_compile_flags)
remove_flags(cxx ${_pkg_compile_flags})
endif()
endif()
endfunction()
# ------------------------------------------------------------------------------
# Load the package if it is an external one
# ------------------------------------------------------------------------------
function(_package_load_package pkg_name)
# load the package if it is an external
_package_get_nature(${pkg_name} _nature)
if(${_nature} MATCHES "external")
_package_use_system(${pkg_name} _use_system)
set(_activated TRUE)
if(_use_system)
_package_load_external_package(${pkg_name} _activated)
endif()
_package_has_system_fallback(${pkg_name} _fallback)
if((NOT _use_system) OR (_fallback AND (NOT _activated)))
_package_load_third_party_script(${pkg_name})
set(_activated TRUE)
endif()
if(_activated)
_package_activate(${pkg_name})
elseif()
_package_deactivate(${pkg_name})
endif()
else()
_package_activate(${pkg_name})
endif()
endfunction()
# ------------------------------------------------------------------------------
# Load external packages
# ------------------------------------------------------------------------------
function(_package_load_external_package pkg_name activate)
_package_get_real_name(${pkg_name} _real_name)
string(TOUPPER ${_real_name} _u_package)
if(NOT ${pkg_name}_USE_SYSTEM_PREVIOUS)
#if system was off before clear the cache of preset variables
get_cmake_property(_all_vars VARIABLES)
foreach(_var ${_all_vars})
if(_var MATCHES "^${_u_package}_.*")
unset(${_var} CACHE)
endif()
endforeach()
set(${pkg_name}_USE_SYSTEM_PREVIOUS TRUE CACHE INTERNAL "" FORCE)
endif()
_package_get_find_package_extra_options(${pkg_name} _options)
if(_options)
cmake_parse_arguments(_opt_pkg "" "LANGUAGE" "LINK_LIBRARIES;PREFIX;FOUND;ARGS" ${_options})
if(_opt_pkg_UNPARSED_ARGUMENTS)
message("You passed too many options for the find_package related to ${${pkg_name}} \"${_opt_pkg_UNPARSED_ARGUMENTS}\"")
endif()
endif()
if(_opt_pkg_LANGUAGE)
foreach(_language ${_opt_pkg_LANGUAGE})
enable_language(${_language})
endforeach()
endif()
# find the package
set(_required REQUIRED)
_package_has_system_fallback(${pkg_name} _fallback)
if(_fallback)
set(_required QUIET)
endif()
find_package(${_real_name} ${_required} ${_opt_pkg_ARGS})
# check if the package is found
if(_opt_pkg_PREFIX)
set(_package_prefix ${_opt_pkg_PREFIX})
else()
set(_package_prefix ${_u_package})
endif()
set(_act FALSE)
set(_prefix_to_consider)
if(DEFINED _opt_pkg_FOUND)
if(${_opt_pkg_FOUND})
set(_act TRUE)
set(_prefix_to_consider ${_package_prefix})
endif()
else()
foreach(_prefix ${_package_prefix})
if(${_prefix}_FOUND)
set(_act TRUE)
list(APPEND _prefix_to_consider ${_prefix})
endif()
endforeach()
endif()
if(_act)
foreach(_prefix ${_prefix_to_consider})
# Generate the include dir for the package
if(DEFINED ${_prefix}_INCLUDE_DIRS)
_package_set_include_dir(${pkg_name} ${${_prefix}_INCLUDE_DIRS})
elseif(DEFINED ${_prefix}_INCLUDE_DIR)
_package_set_include_dir(${pkg_name} ${${_prefix}_INCLUDE_DIR})
elseif(DEFINED ${_prefix}_INCLUDE_PATH)
_package_set_include_dir(${pkg_name} ${${_prefix}_INCLUDE_PATH})
endif()
# Generate the libraries for the package
if(_opt_pkg_LINK_LIBRARIES)
_package_set_libraries(${pkg_name} ${_opt_pkg_LINK_LIBRARIES})
elseif(DEFINED ${_prefix}_LIBRARIES)
_package_set_libraries(${pkg_name} ${${_prefix}_LIBRARIES})
elseif(DEFINED ${_prefix}_LIBRARY)
_package_set_libraries(${pkg_name} ${${_prefix}_LIBRARY})
endif()
endforeach()
_package_get_callback_script(${pkg_name} _script_file)
if(_script_file)
include("${_script_file}")
endif()
endif()
set(${activate} ${_act} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
# Sanity check functions
# ------------------------------------------------------------------------------
function(_package_check_files_exists)
set(_message FALSE)
package_get_all_packages(_pkg_list)
foreach(_pkg_name ${_pkg_list})
set(_pkg_files
${${_pkg_name}_SRCS}
${${_pkg_name}_PUBLIC_HEADERS}
${${_pkg_name}_PRIVATE_HEADERS}
)
_package_get_real_name(${_pkg_name} _real_name)
foreach(_file ${_pkg_files})
if(NOT EXISTS "${_file}")
if(NOT _message)
set(_message TRUE)
message("This file(s) is(are) present in a package but are not present on disk.")
endif()
message(" PACKAGE ${_real_name} FILE ${_file}")
endif()
endforeach()
endforeach()
if(_message)
message(SEND_ERROR "Please check the content of your packages to correct this warnings")
endif()
endfunction()
# ------------------------------------------------------------------------------
function(_package_check_files_registered)
set(_pkg_files)
package_get_all_packages(_pkg_list)
# generates a file list of registered files
foreach(_pkg_name ${_pkg_list})
list(APPEND _pkg_files
${${_pkg_name}_SRCS}
${${_pkg_name}_PUBLIC_HEADERS}
${${_pkg_name}_PRIVATE_HEADERS}
)
endforeach()
# generates the list of files in the source folders
set(_all_src_files)
foreach(_src_folder ${ARGN})
foreach(_ext "cc" "hh" "c" "h" "hpp")
file(GLOB_RECURSE _src_files "${_src_folder}/*.${_ext}")
list(APPEND _all_src_files ${_src_files})
endforeach()
endforeach()
if(_all_src_files)
list(REMOVE_DUPLICATES _all_src_files)
endif()
set(_not_registerd_files)
# check only sources files in the source folders
foreach(_src_folder ${ARGN})
foreach(_file ${_all_src_files})
if("${_file}" MATCHES "${_src_folder}")
list(FIND _pkg_files "${_file}" _index)
if (_index EQUAL -1)
list(APPEND _not_registerd_files ${_file})
endif()
endif()
endforeach()
endforeach()
if(AUTO_MOVE_UNKNOWN_FILES)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/unknown_files)
endif()
# warn the user and move the files if needed
if(_not_registerd_files)
if(EXISTS ${PROJECT_BINARY_DIR}/missing_files_in_packages)
file(REMOVE ${PROJECT_BINARY_DIR}/missing_files_in_packages)
endif()
message("This files are present in the source folders but are not registered in any package")
foreach(_file ${_not_registerd_files})
message(" ${_file}")
if(AUTO_MOVE_UNKNOWN_FILES)
get_filename_component(_file_name ${_file} NAME)
file(RENAME ${_file} ${PROJECT_BINARY_DIR}/unknown_files/${_file_name})
endif()
file(APPEND ${PROJECT_BINARY_DIR}/missing_files_in_packages "${_file}
")
endforeach()
if(AUTO_MOVE_UNKNOWN_FILES)
message(SEND_ERROR "The files where moved in the followinf folder ${PROJECT_BINARY_DIR}/unknown_files\n
Please register them in the good package or clean the sources")
else()
message(SEND_ERROR "Please register them in the good package or clean the sources")
endif()
endif()
endfunction()
# ------------------------------------------------------------------------------
diff --git a/cmake/Modules/CMakeVersionGenerator.cmake b/cmake/Modules/CMakeVersionGenerator.cmake
index 222d3418b..74a30e938 100644
--- a/cmake/Modules/CMakeVersionGenerator.cmake
+++ b/cmake/Modules/CMakeVersionGenerator.cmake
@@ -1,85 +1,241 @@
#===============================================================================
# @file CMakeVersionGenerator.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
# @date last modification: Mon Jan 18 2016
#
# @brief Set of macros used by akantu to handle the package system
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
if(__DEFINE_PROJECT_VERSION__)
return()
endif()
set(__DEFINE_PROJECT_VERSION__ TRUE)
-macro(define_project_version)
- string(TOUPPER ${PROJECT_NAME} _project)
+function(_match_semver _input_semver prefix)
+ set(_semver_regexp
+ "^([0-9]+(\\.[0-9]+)?(\\.[0-9]+)?)(-([a-zA-Z0-9-]*))?(\\+(.*))?")
- if(EXISTS ${PROJECT_SOURCE_DIR}/VERSION)
- file(STRINGS ${PROJECT_SOURCE_DIR}/VERSION ${_project}_VERSION)
-
- if("${${_project}_VERSION}" MATCHES "^([0-9]+)")
- string(REGEX REPLACE "^([0-9]+).*" "\\1" _ver_major "${${_project}_VERSION}")
- set(${_project}_MAJOR_VERSION ${_ver_major})
-
- if("${${_project}_VERSION}" MATCHES "^${_ver_major}\\.([0-9]+)")
- string(REGEX REPLACE "^${_ver_major}\\.([0-9]+).*" "\\1" _ver_minor "${${_project}_VERSION}")
- set(${_project}_MINOR_VERSION ${_ver_minor})
- if("${${_project}_VERSION}" MATCHES "^${_ver_major}\\.${_ver_minor}\\.([0-9a-zA-Z\\-]+)")
- string(REGEX REPLACE "^${_ver_major}\\.${_ver_minor}\\.([0-9a-zA-Z\\-]+).*" "\\1" _ver_build "${${_project}_VERSION}")
- set(${_project}_BUILD_VERSION ${_ver_build})
+ if(_input_semver MATCHES "^([0-9]+(\\.[0-9]+)?(\\.[0-9]+)?)(-([a-zA-Z0-9-]*))?(\\+(.*))?")
+ set(${prefix}_version ${CMAKE_MATCH_1} PARENT_SCOPE)
+ if(CMAKE_MATCH_4)
+ set(${prefix}_version_prerelease "${CMAKE_MATCH_5}" PARENT_SCOPE)
+ endif()
+
+ if(CMAKE_MATCH_6)
+ set(${prefix}_version_metadata "${CMAKE_MATCH_7}" PARENT_SCOPE)
+ endif()
+
+ endif()
+endfunction()
+
+function(_get_version_from_git)
+ if(NOT CMAKE_VERSION_GENERATOR_TAG_PREFIX)
+ set(CMAKE_VERSION_GENERATOR_TAG_PREFIX "av")
+ endif()
+
+
+ find_package(Git)
+ if(Git_FOUND)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe
+ --tags
+ --abbrev=0
+ --match ${CMAKE_VERSION_GENERATOR_TAG_PREFIX}*
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ RESULT_VARIABLE _res
+ OUTPUT_VARIABLE _out_tag
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _err_tag)
+
+ if(NOT _res EQUAL 0)
+ return()
+ endif()
+
+ string(REGEX REPLACE "^${CMAKE_VERSION_GENERATOR_TAG_PREFIX}(.*)" "\\1" _tag "${_out_tag}")
+
+ _match_semver("${_tag}" _tag)
+
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe
+ --tags
+ --dirty
+ --always
+ --long
+ --match ${CMAKE_VERSION_GENERATOR_TAG_PREFIX}*
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ RESULT_VARIABLE _res
+ OUTPUT_VARIABLE _out
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ set(_git_version ${_tag_version} PARENT_SCOPE)
+
+ if(_tag_version_prerealease)
+ set(_git_version_prerelease ${_tag_version_prerealease} PARENT_SCOPE)
+ endif()
+
+ # git describe to PEP404 version
+ set(_version_regex
+ "^${CMAKE_VERSION_GENERATOR_TAG_PREFIX}${_tag}(-([0-9]+)-g([0-9a-f]+)(-dirty)?)?$")
+
+ if(_out MATCHES ${_version_regex})
+ if(CMAKE_MATCH_1)
+ if(_tag_version_metadata)
+ set(_metadata "${_tag_version_metadata}.")
+ endif()
+ set(_metadata "${_metadata}${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
+ endif()
+ if(CMAKE_MATCH_4)
+ set(_metadata "${_metadata}.dirty")
+ endif()
+ else()
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+ RESULT_VARIABLE _res
+ OUTPUT_VARIABLE _out_count
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(_out MATCHES "^([0-9a-f]+)(-dirty)?$")
+ set(_metadata "${CMAKE_MATCH_1}")
+ if(_res EQUAL 0)
+ set(_metadata "${_out_count}.${_metadata}")
+ endif()
+
+ if(CMAKE_MATCH_2)
+ set(_metadata "${_metadata}.dirty")
endif()
endif()
endif()
- # else()
- # find_package(Subversion)
-
- # if(SUBVERSION_FOUND)
- # subversion_wc_info(${PROJECT_SOURCE_DIR} ${_project} ERROR_QUIET)
- # if(${${_project}_WC_FOUND})
- # set(${_project}_BUILD_VERSION ${${_project}_WC_REVISION})
- # set(${_project}_VERSION
- # "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}.${${_project}_BUILD_VERSION}"
- # )
- # endif()
- # endif()
+
+ set(_git_version_metadata ${_metadata} PARENT_SCOPE)
endif()
+endfunction()
- if(NOT ${_project}_VERSION)
- set(${_project}_VERSION
- "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}"
- )
+function(_get_version_from_file)
+ if(EXISTS ${PROJECT_SOURCE_DIR}/VERSION)
+ file(STRINGS ${PROJECT_SOURCE_DIR}/VERSION _file_version)
+ _match_semver("${_file_version}" "_file")
+ set(_file_version ${_file_version} PARENT_SCOPE)
+ if(_file_version_metadata)
+ set(_file_version_metadata ${_file_version_metadata} PARENT_SCOPE)
+ endif()
+
+ if(_file_version_prerelease)
+ set(_file_version_prerelease ${_file_version_prerelease} PARENT_SCOPE)
+ endif()
endif()
+endfunction()
- # Append the library version information to the library target properties
- if(NOT ${_project}_NO_LIBRARY_VERSION)
- message(STATUS "${PROJECT_NAME} version: ${${_project}_VERSION}")
+function(_get_metadata_from_ci)
+ if(NOT DEFINED ENV{CI})
+ return()
+ endif()
+
+ if(DEFINED ENV{CI_MERGE_REQUEST_ID})
+ set(_ci_version_metadata "ci.mr$ENV{CI_MERGE_REQUEST_ID}" PARENT_SCOPE)
+ elseif(DEFINED ENV{CI_COMMIT_SHORT_SHA})
+ set(_ci_version_metadata "ci.$ENV{CI_COMMIT_SHORT_SHA}" PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(define_project_version)
+ string(TOUPPER ${PROJECT_NAME} _project)
+
+ _get_version_from_git()
+
+ if(_git_version)
+ set(_git_version ${_file_version})
+ if(_version_metadata)
+ set(_version_metadata "${_git_version_metadata}")
+ endif()
+
+ if (_git_version_prerelease)
+ set(_version_prerelease "${_git_version_prerelease}")
+ endif()
+ else()
+ # we can get metadata if and no version if not tag is properly defined
+ if(_git_version_metadata)
+ set(git_version_metadata ".${_git_version_metadata}")
+ endif()
+
+ _get_version_from_file()
+
+ if(_file_version_metadata)
+ set(_version_metadata "${_version_metadata}${_git_version_metadata}")
+ endif()
+ if (_file_version)
+ set(_version "${_file_version}")
+ endif()
+
+ if (_file_version_prerelease)
+ set(_version_prerelease "${_file_version_prerelease}")
+ endif()
+ endif()
+
+ _get_metadata_from_ci()
+
+ if(_version)
+ set(${_project}_VERSION ${_version} PARENT_SCOPE)
+ if(_version_prerelease)
+ set(_version_prerelease "-${_version_prerelease}")
+ endif()
+ if(_version_metadata)
+ set(_version_metadata "+${_version_metadata}")
+ if(_ci_version_metadata)
+ set(_version_metadata "${_version_metadata}.${_ci_version_metadata}")
+ endif()
+ endif()
+
+ set(_semver "${_version}${_version_prerelease}${_version_metadata}")
+ set(${_project}_SEMVER "${_semver}" PARENT_SCOPE)
+ message(STATUS "${PROJECT_NAME} version: ${_semver}")
+
+ if(_version MATCHES "^([0-9]+)(\\.([0-9]+))?(\\.([0-9]+))?")
+ set(_major_version ${CMAKE_MATCH_1})
+ set(${_project}_MAJOR_VERSION ${_major_version} PARENT_SCOPE)
+ if(CMAKE_MATCH_2)
+ set(_minor_version ${CMAKE_MATCH_3})
+ set(${_project}_MINOR_VERSION ${_minor_version} PARENT_SCOPE)
+ endif()
+ if(CMAKE_MATCH_4)
+ set(_patch_version ${CMAKE_MATCH_5})
+ set(${_project}_PATCH_VERSION ${_patch_version} PARENT_SCOPE)
+ endif()
+ endif()
+ else()
+ message(FATAL_ERROR "Could not determine the VERSION for ${PROJECT_NAME}")
+ endif()
+
+ if(NOT ${_project}_NO_LIBRARY_VERSION)
set(${_project}_LIBRARY_PROPERTIES ${${_project}_LIBRARY_PROPERTIES}
- VERSION "${${_project}_VERSION}"
- SOVERSION "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}"
+ VERSION "${_version}"
+ SOVERSION "${_major_version}.${_minor_version}"
)
endif()
-endmacro()
+endfunction()
diff --git a/cmake/Modules/FindCppArray.cmake b/cmake/Modules/FindCppArray.cmake
index 260351a19..d8230583d 100644
--- a/cmake/Modules/FindCppArray.cmake
+++ b/cmake/Modules/FindCppArray.cmake
@@ -1,34 +1,37 @@
#===============================================================================
# @file FindCppArray.cmake
#
# @author Alejandro M. Aragón <alejandro.aragon@epfl.ch>
#
-# @date creation: Sun Oct 19 2014
+# @date creation: Fri Sep 03 2010
+# @date last modification: Fri Mar 16 2018
#
# @brief The find_package file for cpp-array library
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
find_path (CPPARRAY_INCLUDE_DIR expr.hpp PATH_SUFFIXES array)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CppArray DEFAULT_MSG CPPARRAY_INCLUDE_DIR)
diff --git a/cmake/Modules/FindEPSN.cmake b/cmake/Modules/FindEPSN.cmake
deleted file mode 100644
index d32e9e87b..000000000
--- a/cmake/Modules/FindEPSN.cmake
+++ /dev/null
@@ -1,55 +0,0 @@
-#===============================================================================
-# @file FindEPSN.cmake
-#
-# @author Nicolas Richart <nicolas.richart@epfl.ch>
-#
-# @date creation: Sun Oct 19 2014
-#
-# @brief The find_package file for EPSN
-#
-# @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 <http://www.gnu.org/licenses/>.
-#
-#===============================================================================
-
-#===============================================================================
-find_path(EPSN_DIR EPSNConfig.cmake
- PATHS $ENV{EPSN_TOP}
- )
-
-
-if(EPSN_DIR)
- include(${EPSN_DIR}/EPSNConfig.cmake)
- set(EPSN_LIB_PATH ${EPSN_DIR}/lib
- ${EPSN_LIBRARIES_DIR}
- )
- find_library(EPSN_COMMON_LIBRARY epsn_common
- PATHS ${EPSN_LIB_PATH}
- )
- find_library(EPSN_SIMULATION_LIBRARY epsn_simulation
- PATHS ${EPSN_LIB_PATH}
- )
- include(${EPSN_DIR}/EPSNLibraryDepends.cmake)
-
- set(EPSN_LIBRARIES ${EPSN_SIMULATION_LIBRARY} ${EPSN_COMMON_LIBRARY})
-endif(EPSN_DIR)
-
-#===============================================================================
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(EPSN DEFAULT_MSG
- EPSN_LIBRARIES EPSN_INCLUDE_DIR)
diff --git a/cmake/Modules/FindFFTW.cmake b/cmake/Modules/FindFFTW.cmake
deleted file mode 100644
index b1e2d7996..000000000
--- a/cmake/Modules/FindFFTW.cmake
+++ /dev/null
@@ -1,71 +0,0 @@
-#===============================================================================
-# @file FindFFTW.cmake
-#
-# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
-#
-# @date creation: Sun Oct 19 2014
-#
-# @brief find_package for fftw
-#
-# @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 <http://www.gnu.org/licenses/>.
-#
-#===============================================================================
-
-set(FFTW_VERSION "3" CACHE INTEGER "Version of FFTW required")
-
-if (FFTW_FIND_VERSION)
- set(FFTW_VERSION ${FFTW_FIND_VERSION} CACHE INTEGER "Version of FFTW required")
-endif()
-
-if (FFTW_VERSION EQUAL "2")
- find_library(FFTW_LIBRARIES fftw
- PATHS ${FFTW_DIR}
- PATH_SUFFIXES fftw/.libs/ lib
- )
- find_path(FFTW_INCLUDE_PATH fftw.h
- PATHS ${FFTW_DIR} $ENV{INCLUDE_PATH}
- PATH_SUFFIXES include fftw
- )
-else()
-
- find_library(FFTW_LIBRARIES fftw3
- PATHS ENV LD_LIBRARY_PATH
- )
- find_library(FFTW_THREAD_LIBRARY fftw3_threads
- PATHS ENV LD_LIBRARY_PATH
- )
- find_library(FFTW_OPENMP_LIBRARY fftw3_omp
- PATHS ENV LD_LIBRARY_PATH
- )
- find_path(FFTW_INCLUDE_PATH fftw3.h
- PATHS ENV INCLUDE_PATH
- PATH_SUFFIXES include fftw
- )
-endif()
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(FFTW DEFAULT_MSG
- FFTW_LIBRARIES FFTW_INCLUDE_PATH)
-
-
-if(NOT FFTW_FOUND)
- set(FFTW_DIR "" CACHE PATH "Location of FFTW library.")
-endif(NOT FFTW_FOUND)
-
-mark_as_advanced(FFTW_LIBRARIES FFTW_OPENMP_LIBRARY FFTW_THREAD_LIBRARY FFTW_INCLUDE_PATH FFTW_VERSION)
diff --git a/cmake/Modules/FindGMSH.cmake b/cmake/Modules/FindGMSH.cmake
index 4661bc8ac..212bae0e4 100644
--- a/cmake/Modules/FindGMSH.cmake
+++ b/cmake/Modules/FindGMSH.cmake
@@ -1,110 +1,113 @@
#===============================================================================
# @file FindGMSH.cmake
#
+# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
-# @date creation: Mon Dec 08 2014
-# @date last modification: Tue Jan 19 2016
+# @date creation: Sun Oct 19 2014
+# @date last modification: Wed Aug 14 2019
#
# @brief Find gmsh and delacre the add_mesh macro
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
find_program(GMSH gmsh
DOC "The mesh generetor gmsh")
mark_as_advanced(GMSH)
if (GMSH)
execute_process(COMMAND ${GMSH} --version
ERROR_VARIABLE GMSH_VERSION
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
find_package(PackageHandleStandardArgs)
find_package_handle_standard_args(GMSH
REQUIRED_VARS GMSH
VERSION_VAR GMSH_VERSION)
#===============================================================================
function(ADD_MESH MESH_TARGET GEO_FILE)
if(NOT GMSH_FOUND)
return()
endif()
set(arguments
${MESH_TARGET} ${GEO_FILE}
${ARGN}
)
cmake_parse_arguments(_add_mesh
""
"OUTPUT;DIM;ORDER"
""
${arguments}
)
if(NOT _add_mesh_DIM AND NOT _add_mesh_ORDER)
list(GET _add_mesh_UNPARSED_ARGUMENTS 2 _add_mesh_DIM)
list(GET _add_mesh_UNPARSED_ARGUMENTS 3 _add_mesh_ORDER)
endif()
if(NOT _add_mesh_DIM)
set(_add_mesh_DIM 3)
endif()
if(NOT _add_mesh_ORDER)
set(_add_mesh_ORDER 1)
endif()
set(_geo_file ${CMAKE_CURRENT_SOURCE_DIR}/${GEO_FILE})
set(_r_geo_file "${GEO_FILE}")
if(_add_mesh_OUTPUT)
set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${_add_mesh_OUTPUT})
set(_r_msh_file "${_add_mesh_OUTPUT}")
else(_add_mesh_OUTPUT)
get_filename_component(_msh_file "${GEO_FILE}" NAME_WE)
set(_r_msh_file "${_msh_file}.msh")
set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${_msh_file}.msh)
endif(_add_mesh_OUTPUT)
if(GMSH_VERSION VERSION_LESS 3.0.0)
set(OPTIMIZE -optimize)
endif()
if(EXISTS ${_geo_file})
add_custom_command(
OUTPUT ${_msh_file}
DEPENDS ${_geo_file}
COMMAND ${GMSH}
ARGS -${_add_mesh_DIM} -order ${_add_mesh_ORDER} ${OPTIMIZE} -o ${_msh_file} ${_geo_file} 2>&1 > /dev/null
COMMENT "Generating the ${_add_mesh_DIM}D mesh ${_r_msh_file} (order ${_add_mesh_ORDER}) form the geometry ${_r_geo_file}"
)
add_custom_target(${MESH_TARGET}
DEPENDS ${_msh_file})
set_target_properties(${MESH_TARGET} PROPERTIES RESSOURCES ${_geo_file})
else(EXISTS ${_geo_file})
message(WARNING
"File ${_geo_file} not found for target ${MESH_TARGET}")
endif(EXISTS ${_geo_file})
endfunction()
diff --git a/cmake/Modules/FindGSL.cmake b/cmake/Modules/FindGSL.cmake
deleted file mode 100644
index 76ffa0bcd..000000000
--- a/cmake/Modules/FindGSL.cmake
+++ /dev/null
@@ -1,54 +0,0 @@
-#===============================================================================
-# @file FindGSL.cmake
-#
-# @author Nicolas Richart <nicolas.richart@epfl.ch>
-#
-# @date creation: Sun Oct 19 2014
-#
-# @brief find package for gsl
-#
-# @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 <http://www.gnu.org/licenses/>.
-#
-#===============================================================================
-
-find_path(GSL_INCLUDE_PATH gsl_math.h
- PATHS ${GSL_DIR} ENV C_INCLUDE_PATH
- PATH_SUFFIXES gsl
- )
-
-find_library(GSL_MAIN_LIBRARY NAME gsl
- PATHS ${GSL_DIR} ENV LIBRARY_PATH
- PATH_SUFFIXES lib
- )
-
-find_library(GSL_BLAS_LIBRARY NAME gslcblas
- PATHS ${GSL_DIR} ENV LIBRARY_PATH
- PATH_SUFFIXES lib
-)
-
-mark_as_advanced(GSL_INCLUDE_PATH)
-mark_as_advanced(GSL_MAIN_LIBRARY NAME)
-mark_as_advanced(GSL_BLAS_LIBRARY NAME)
-
-set(GSL_LIBRARIES ${GSL_MAIN_LIBRARY} ${GSL_BLAS_LIBRARY})
-
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(GSL DEFAULT_MSG
- GSL_LIBRARIES GSL_INCLUDE_PATH)
diff --git a/cmake/Modules/FindIOHelper.cmake b/cmake/Modules/FindIOHelper.cmake
index 1b9698dd8..9d4676559 100644
--- a/cmake/Modules/FindIOHelper.cmake
+++ b/cmake/Modules/FindIOHelper.cmake
@@ -1,59 +1,62 @@
#===============================================================================
# @file FindIOHelper.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Sun Oct 19 2014
+# @date last modification: Fri Jan 15 2016
#
# @brief The find_package file for IOHelper
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# 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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
#===============================================================================
#set(IOHELPER_LIBRARY "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
find_library(IOHELPER_LIBRARY iohelper
PATHS ${IOHELPER_DIR}
PATH_SUFFIXES lib
)
find_path(IOHELPER_INCLUDE_DIR io_helper.hh
PATHS ${IOHELPER_DIR}
PATH_SUFFIXES include include/iohelper
)
#===============================================================================
mark_as_advanced(IOHELPER_LIBRARY)
mark_as_advanced(IOHELPER_INCLUDE_DIR)
#===============================================================================
find_package(ZLIB REQUIRED)
set(IOHELPER_LIBRARIES_ALL ${IOHELPER_LIBRARY} ${ZLIB_LIBRARIES})
set(IOHELPER_LIBRARIES ${IOHELPER_LIBRARIES_ALL} CACHE INTERNAL "Libraries for IOHelper" FORCE)
#===============================================================================
if(NOT IOHELPER_FOUND)
set(IOHELPER_DIR "" CACHE PATH "Location of IOHelper source directory.")
endif()
#===============================================================================
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IOHelper DEFAULT_MSG IOHELPER_LIBRARY IOHELPER_INCLUDE_DIR)
diff --git a/cmake/Modules/FindInkscape.cmake b/cmake/Modules/FindInkscape.cmake
deleted file mode 100644
index c35b302ae..000000000
--- a/cmake/Modules/FindInkscape.cmake
+++ /dev/null
@@ -1,93 +0,0 @@
-#===============================================================================
-# @file FindInkscape.cmake
-#
-# @author Nicolas Richart <nicolas.richart@epfl.ch>
-#
-# @date creation: Sun Oct 19 2014
-#
-# @brief find_package for inkscape
-#
-# @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 <http://www.gnu.org/licenses/>.
-#
-#===============================================================================
-
-# Module thaat checks for inkscape
-#
-# Sets the following variables
-#
-# INSCAPE: Path to inkscape to generate .png's form .svg's
-#
-# Provides the following functions:
-#
-# inkscape_generate_png_from_svg([OUTPUT_DIR <output_dir>] <pngfile1.png> [<pngfile2.png> ....])
-#
-# Generates pngfile1, ... from svg input files pngfile1.svg, ....
-# The output directory can be specified with the option OUTPUT_DIR. If it is omitted
-# the files will be generated in CMAKE_CURRENT_BINARY_DIR.
-
-find_program(INKSCAPE inkscape DOC "Path to inkscape to generate png files from svg files")
-find_program(CONVERT convert DOC "Path to convert program")
-if(INKSCAPE)
- set(INKSCAPE_FOUND True)
-endif(INKSCAPE)
-
-include(CMakeParseArguments)
-
-function(inkscape_generate_png_from_svg)
- if(NOT INKSCAPE)
- return()
- endif(NOT INKSCAPE)
- cmake_parse_arguments(INKSCAPE "" "DPI" "" ${ARGN})
- if(NOT INKSCAPE_DPI)
- set(INKSCAPE_DPI 90)
- endif(NOT INKSCAPE_DPI)
-
- foreach(pic ${INKSCAPE_UNPARSED_ARGUMENTS})
- string(REGEX REPLACE "\\.[a-zA-Z]+" ".png" output ${pic})
- add_custom_command(OUTPUT ${output}
- COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${output} -f ${pic}
- DEPENDS ${pic}
- COMMENT "Generating ${output} from ${pic}"
- )
- endforeach(pic)
-endfunction(inkscape_generate_png_from_svg)
-
-function(inkscape_generate_eps_from_svg)
- cmake_parse_arguments(INKSCAPE "" "INPUT_DIR;OUTPUT_DIR;DPI" "" ${ARGN})
- if(NOT INKSCAPE_INPUT_DIR)
- set(INKSCAPE_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
- endif(NOT INKSCAPE_INPUT_DIR)
- if(NOT INKSCAPE_INPUT_DIR)
- set(INKSCAPE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
- endif(NOT INKSCAPE_INPUT_DIR)
-
- foreach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS})
- string(REGEX REPLACE "\\.[a-zA-Z]+" ".png" input "${_pic}")
- string(REGEX REPLACE "\\.[a-zA-Z]+" ".svg" svginput "${_pic}")
-
- add_custom_target(${input}
- COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${input} ${CMAKE_CURRENT_SOURCE_DIR}/${svginput}
- COMMENT "Generating ${INKSCAPE_OUTPUT_DIR}/${pic} from ${CMAKE_CURRENT_SOURCE_DIR}/${input}")
- add_custom_command(OUTPUT ${_pic}
- COMMAND ${CONVERT} ${INKSCAPE_INPUT_DIR}/${input} EPS:${_pic}
- DEPENDS ${input}
- COMMENT "Converting ${INKSCAPE_INPUT_DIR}/${input} to ${INKSCAPE_OUTPUT_DIR}/${_pic}"
- WORKING_DIRECTORY ${INKSCAPE_OUTPUT_DIR})
- endforeach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS})
-endfunction(inkscape_generate_eps_from_svg)
\ No newline at end of file
diff --git a/cmake/Modules/FindLAMMPS.cmake b/cmake/Modules/FindLAMMPS.cmake
deleted file mode 100644
index 81f456ef3..000000000
--- a/cmake/Modules/FindLAMMPS.cmake
+++ /dev/null
@@ -1,68 +0,0 @@
-#===============================================================================
-# @file FindLAMMPS.cmake
-#
-# @author Nicolas Richart <nicolas.richart@epfl.ch>
-#
-# @date creation: Sun Oct 19 2014
-#
-# @brief find package for lammps
-#
-# @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 <http://www.gnu.org/licenses/>.
-#
-#===============================================================================
-
-find_path(LAMMPS_INCLUDE_PATH lammps.h
- PATHS ${LAMMPS_DIR} ENV C_INCLUDE_PATH
- PATH_SUFFIXES src
- )
-
-#if (not ${LAMMPS_ARCH})
- file(GLOB ARCHS "${LAMMPS_INCLUDE_PATH}/liblmp*")
- foreach(loop_var IN ITEMS ${ARCHS})
- get_filename_component(loop_var ${loop_var} NAME)
- string(REGEX REPLACE ".so" "" loop_var ${loop_var})
- string(REGEX REPLACE "liblmp_" "" loop_var ${loop_var})
-# MESSAGE ("possible archs compiled for lammps : ${loop_var}")
- SET(LAMMPS_ARCH ${loop_var} CACHE INTERNAL "internal built version of lammps detection" FORCE)
-# MESSAGE ("libname : lmp_${LAMMPS_ARCH}")
- endforeach(loop_var)
-#endif(not ${LAMMPS_ARCH})
-
-
-find_library(LAMMPS_MAIN_LIBRARY NAME lmp_${LAMMPS_ARCH}
- PATHS ${LAMMPS_DIR}
- PATH_SUFFIXES src
- )
-
-if (NOT LAMMPS_MAIN_LIBRARY)
-set(LAMMPS_DIR "" CACHE PATH "Location of LAMMPS library.")
-endif (NOT LAMMPS_MAIN_LIBRARY)
-
-find_library(LAMMPS_MEAM_LIBRARIES NAME meam
- PATHS ${LAMMPS_DIR}
- PATH_SUFFIXES lib/meam
-)
-
-set(LAMMPS_LIBRARIES ${LAMMPS_MAIN_LIBRARY} ${LAMMPS_MEAM_LIBRARIES})
-SEPARATE_ARGUMENTS(LAMMPS_LIBRARIES)
-
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LAMMPS DEFAULT_MSG
- LAMMPS_LIBRARIES LAMMPS_INCLUDE_PATH)
\ No newline at end of file
diff --git a/cmake/Modules/FindMETIS.cmake b/cmake/Modules/FindMETIS.cmake
index 267cf264d..7cfe8c513 100644
--- a/cmake/Modules/FindMETIS.cmake
+++ b/cmake/Modules/FindMETIS.cmake
@@ -1,37 +1,69 @@
+#===============================================================================
+# @file FindMETIS.cmake
+#
+# @author Nicolas Richart <nicolas.richart@epfl.ch>
+#
+# @date creation: Fri Apr 22 2016
+# @date last modification: Fri Mar 16 2018
+#
+# @brief FindPackage for the metis library
+#
+#
+# @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 <http://www.gnu.org/licenses/>.
+#
+#===============================================================================
+
+
find_path(METIS_INCLUDE_DIR metis.h
PATHS "${METIS_DIR}"
ENV METIS_DIR
PATH_SUFFIXES include
)
find_library(METIS_LIBRARY NAMES metis
PATHS "${METIS_DIR}"
ENV METIS_DIR
PATH_SUFFIXES lib
)
mark_as_advanced(METIS_LIBRARY METIS_INCLUDE_DIR)
#===============================================================================
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.12)
if(METIS_INCLUDE_DIR)
file(STRINGS ${METIS_INCLUDE_DIR}/metis.h _versions
REGEX "^#define\ +METIS_VER_(MAJOR|MINOR|SUBMINOR) .*")
foreach(_ver ${_versions})
string(REGEX MATCH "METIS_VER_(MAJOR|MINOR|SUBMINOR) *([0-9.]+)" _tmp "${_ver}")
set(_metis_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endforeach()
set(METIS_VERSION "${_metis_MAJOR}.${_metis_MINOR}" CACHE INTERNAL "")
endif()
find_package_handle_standard_args(METIS
REQUIRED_VARS
METIS_LIBRARY
METIS_INCLUDE_DIR
VERSION_VAR
METIS_VERSION)
else()
find_package_handle_standard_args(METIS DEFAULT_MSG
METIS_LIBRARY METIS_INCLUDE_DIR)
endif()
diff --git a/cmake/Modules/FindMumps.cmake b/cmake/Modules/FindMumps.cmake
index 0db04fb96..30e60646c 100644
--- a/cmake/Modules/FindMumps.cmake
+++ b/cmake/Modules/FindMumps.cmake
@@ -1,315 +1,320 @@
#===============================================================================
# @file FindMumps.cmake
#
+# @author Mathias Lebihain <mathias.lebihain@enpc.fr>
+# @author Philip Mueller <philip.mueller@math.ethz.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
-# @date creation: Fri Oct 24 2014
-# @date last modification: Wed Jan 13 2016
+# @date creation: Sun Oct 19 2014
+# @date last modification: Fri Jan 22 2021
#
# @brief The find_package file for the Mumps solver
#
+#
# @section LICENSE
#
-# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
-# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+# Copyright (©) 2015-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
+# 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
+#
+# 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
+# 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 <http://www.gnu.org/licenses/>.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
+
+
set(_MUMPS_COMPONENTS "sequential" "parallel" "double" "float" "complex_double" "complex_float")
if(NOT Mumps_FIND_COMPONENTS)
set(Mumps_FIND_COMPONENTS "parallel" "double" "float" "complex_double" "complex_float")
endif()
#===============================================================================
enable_language(Fortran)
set(MUMPS_PRECISIONS)
set(MUMPS_PLAT)
foreach(_comp ${Mumps_FIND_COMPONENTS})
if("${_comp}" STREQUAL "sequential")
set(MUMPS_PLAT _seq) #default plat on debian based distribution
endif()
if("${_comp}" STREQUAL "float")
list(APPEND MUMPS_PRECISIONS s)
endif()
if("${_comp}" STREQUAL "double")
list(APPEND MUMPS_PRECISIONS d)
endif()
if("${_comp}" STREQUAL "complex_float")
list(APPEND MUMPS_PRECISIONS c)
endif()
if("${_comp}" STREQUAL "complex_double")
list(APPEND MUMPS_PRECISIONS z)
endif()
endforeach()
if(NOT MUMPS_PRECISIONS)
set(MUMPS_PRECISIONS s d c z)
endif()
list(GET MUMPS_PRECISIONS 0 _first_precision)
string(TOUPPER "${_first_precision}" _u_first_precision)
find_path(MUMPS_INCLUDE_DIR ${_first_precision}mumps_c.h
PATHS "${MUMPS_DIR}"
ENV MUMPS_DIR
PATH_SUFFIXES include
)
mark_as_advanced(MUMPS_INCLUDE_DIR)
set(_mumps_required_vars)
foreach(_precision ${MUMPS_PRECISIONS})
string(TOUPPER "${_precision}" _u_precision)
find_library(MUMPS_LIBRARY_${_u_precision}MUMPS NAMES ${_precision}mumps${MUMPS_PREFIX}
PATHS "${MUMPS_DIR}"
ENV MUMPS_DIR
PATH_SUFFIXES lib
)
mark_as_advanced(MUMPS_LIBRARY_${_u_precision}MUMPS)
list(APPEND _mumps_required_vars MUMPS_LIBRARY_${_u_precision}MUMPS)
list(APPEND MUMPS_LIBRARIES_ALL ${MUMPS_LIBRARY_${_u_precision}MUMPS})
endforeach()
if(MUMPS_LIBRARY_${_u_first_precision}MUMPS MATCHES ".*${_first_precision}mumps.*${CMAKE_STATIC_LIBRARY_SUFFIX}")
# Assuming mumps was compiled as a static library
set(MUMPS_LIBRARY_TYPE STATIC CACHE INTERNAL "" FORCE)
if (CMAKE_Fortran_COMPILER MATCHES ".*gfortran")
set(_compiler_specific gfortran)
elseif (CMAKE_Fortran_COMPILER MATCHES ".*ifort")
set(_compiler_specific ifcore)
else()
message("Compiler ${CMAKE_Fortran_COMPILER} is not known, you will probably "
"have to add semething instead of this message to be able to test mumps "
"install")
endif()
else()
set(MUMPS_LIBRARY_TYPE SHARED CACHE INTERNAL "" FORCE)
endif()
function(mumps_add_dependency _pdep _libs)
string(TOUPPER ${_pdep} _u_pdep)
if(_pdep STREQUAL "mumps_common")
find_library(MUMPS_LIBRARY_COMMON mumps_common${MUMPS_PREFIX}
PATHS "${MUMPS_DIR}"
ENV MUMPS_DIR
PATH_SUFFIXES lib
)
set(${_libs} ${MUMPS_LIBRARY_COMMON} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_COMMON)
elseif(_pdep STREQUAL "pord")
find_library(MUMPS_LIBRARY_PORD pord${MUMPS_PREFIX}
PATHS "${MUMPS_DIR}"
ENV MUMPS_DIR
PATH_SUFFIXES lib
)
set(${_libs} ${MUMPS_LIBRARY_PORD} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_PORD)
elseif(_pdep MATCHES "Scotch")
find_package(Scotch REQUIRED ${ARGN} QUIET)
if(ARGN)
list(GET ARGN 1 _comp)
string(TOUPPER ${_comp} _u_comp)
set(${_libs} ${SCOTCH_LIBRARY_${_u_comp}} PARENT_SCOPE)
else()
set(${_libs} ${${_u_pdep}_LIBRARIES} PARENT_SCOPE)
endif()
elseif(_pdep MATCHES "MPI")
if(MUMPS_PLAT STREQUAL "_seq")
find_library(MUMPS_LIBRARY_MPISEQ mpiseq${MUMPS_PREFIX}
PATHS "${MUMPS_DIR}"
ENV MUMPS_DIR
PATH_SUFFIXES lib
)
if (NOT MUMPS_LIBRARY_MPISEQ)
message("Could not find libmpiseq for sequential version of MUMPS, was "
"MUMPS compiled in sequential ?")
endif()
set(${_libs} ${MUMPS_LIBRARY_MPISEQ} PARENT_SCOPE)
mark_as_advanced(MUMPS_LIBRARY_MPISEQ)
else()
find_package(MPI REQUIRED C Fortran QUIET)
set(${_libs} ${MPI_C_LIBRARIES} ${MPI_Fortran_LIBRARIES} PARENT_SCOPE)
endif()
elseif(_pdep MATCHES "Threads")
find_package(Threads REQUIRED)
set(${_libs} Threads::Threads PARENT_SCOPE)
elseif(_pdep MATCHES "OpenMP")
find_package(OpenMP REQUIRED)
set(${_libs} OpenMP::OpenMP_C PARENT_SCOPE)
elseif(_pdep MATCHES "Math")
set(${_libs} m PARENT_SCOPE)
else()
find_package(${_pdep} REQUIRED QUIET)
set(${_libs} ${${_u_pdep}_LIBRARIES} ${${_u_pdep}_LIBRARY} PARENT_SCOPE)
endif()
endfunction()
function(mumps_find_dependencies)
set(_libraries_all m ${MUMPS_LIBRARIES_ALL})
set(_include_dirs ${MUMPS_INCLUDE_DIR})
set(_mumps_test_dir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}")
file(READ ${CMAKE_CURRENT_LIST_DIR}/CheckFindMumps.c _output)
file(WRITE "${_mumps_test_dir}/mumps_test_code.c"
"#include <${_first_precision}mumps_c.h>
${_u_first_precision}MUMPS_STRUC_C id;
#define mumps_c ${_first_precision}mumps_c
#define Real ${_u_first_precision}MUMPS_REAL
")
if(MUMPS_PLAT STREQUAL _seq)
file(APPEND "${_mumps_test_dir}/mumps_test_code.c"
"#define MUMPS_SEQ
")
else()
file(APPEND "${_mumps_test_dir}/mumps_test_code.c"
"// #undef MUMPS_SEQ
")
find_package(MPI REQUIRED)
list(APPEND _compiler_specific ${MPI_C_LIBRARIES})
list(APPEND _include_dirs ${MPI_C_INCLUDE_PATH} ${MPI_INCLUDE_DIR})
endif()
file(APPEND "${_mumps_test_dir}/mumps_test_code.c" "${_output}")
#===============================================================================
set(_mumps_dep_symbol_BLAS ${_first_precision}gemm)
set(_mumps_dep_symbol_ScaLAPACK numroc)
set(_mumps_dep_symbol_LAPACK ilaenv)
set(_mumps_dep_symbol_MPI mpi_send)
set(_mumps_dep_symbol_Scotch SCOTCH_graphInit)
set(_mumps_dep_symbol_Scotch_ptscotch scotchfdgraphexit)
set(_mumps_dep_symbol_Scotch_esmumps esmumps)
set(_mumps_dep_symbol_mumps_common mumps_abort)
set(_mumps_dep_symbol_pord SPACE_ordering)
set(_mumps_dep_symbol_METIS metis_nodend)
set(_mumps_dep_symbol_Threads pthread_create)
set(_mumps_dep_symbol_OpenMP GOMP_loop_end_nowait)
# TODO find missing symbols for IOMP
set(_mumps_dep_symbol_Math lround)
set(_mumps_dep_symbol_ParMETIS ParMETIS_V3_NodeND)
# added for fucking macosx that cannot fail at link
set(_mumps_run_dep_symbol_mumps_common mumps_fac_descband)
set(_mumps_run_dep_symbol_MPI mpi_bcast)
set(_mumps_run_dep_symbol_ScaLAPACK idamax)
set(_mumps_dep_comp_Scotch_ptscotch COMPONENTS ptscotch)
set(_mumps_dep_comp_Scotch_esmumps COMPONENTS esmumps)
set(_mumps_potential_dependencies
mumps_common pord
BLAS LAPACK ScaLAPACK
MPI
Scotch Scotch_ptscotch Scotch_esmumps
METIS ParMETIS
Threads OpenMP
Math)
#===============================================================================
set(_retry_try_run TRUE)
set(_retry_count 0)
# trying only as long as we add dependencies to avoid inifinte loop in case of an unkown dependency
while (_retry_try_run AND _retry_count LESS 100)
try_run(_mumps_run _mumps_compiles
"${_mumps_test_dir}"
"${_mumps_test_dir}/mumps_test_code.c"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}"
LINK_LIBRARIES ${_libraries_all} ${_libraries_all} ${_compiler_specific}
RUN_OUTPUT_VARIABLE _run
COMPILE_OUTPUT_VARIABLE _out)
set(_retry_compile FALSE)
#message("COMPILATION outputs: \n${_out} \n RUN OUTPUT \n${_run}")
if(_mumps_compiles AND NOT (_mumps_run STREQUAL "FAILED_TO_RUN"))
break()
endif()
foreach(_pdep ${_mumps_potential_dependencies})
#message("CHECKING ${_pdep}")
set(_add_pdep FALSE)
if (NOT _mumps_compiles AND
_out MATCHES "undefined reference.*${_mumps_dep_symbol_${_pdep}}")
set(_add_pdep TRUE)
#message("NEED COMPILE ${_pdep}")
elseif(_mumps_run STREQUAL "FAILED_TO_RUN" AND
DEFINED _mumps_run_dep_symbol_${_pdep} AND
_run MATCHES "${_mumps_run_dep_symbol_${_pdep}}")
set(_add_pdep TRUE)
#message("NEED RUN ${_pdep}")
endif()
if(_add_pdep)
mumps_add_dependency(${_pdep} _libs ${_mumps_dep_comp_${_pdep}})
#message("ADDING ${_libs}")
if(NOT _libs)
message(FATAL_ERROR "MUMPS depends on ${_pdep} but no libraries where found")
endif()
list(APPEND _libraries_all ${_libs})
set(_retry_try_run TRUE)
endif()
endforeach()
math(EXPR _retry_count "${_retry_count} + 1")
endwhile()
if(_retry_count GREATER 10)
message(FATAL_ERROR "Do not know what to do to link with mumps on your system, I give up!")
message("Last compilation outputs: \n${_out} \n And last run output \n${_run}")
endif()
if(APPLE)
# in doubt add some stuff because mumps was perhaps badly compiled
mumps_add_dependency(pord _libs)
list(APPEND _libraries_all ${_libs})
endif()
set(MUMPS_LIBRARIES_ALL ${_libraries_all} PARENT_SCOPE)
endfunction()
mumps_find_dependencies()
set(MUMPS_LIBRARIES ${MUMPS_LIBRARIES_ALL} CACHE INTERNAL "" FORCE)
#===============================================================================