diff --git a/CMakeLists.txt b/CMakeLists.txt index c22a19765..5ad0b871f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,181 +1,182 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 # @date last modification: Fri Jan 22 2016 # # @brief main configuration file # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # # @section DESCRIPTION #------------------------------------------------------------------------------- # _ _ # | | | | # __ _| | ____ _ _ __ | |_ _ _ # / _` | |/ / _` | '_ \| __| | | | # | (_| | < (_| | | | | |_| |_| | # \__,_|_|\_\__,_|_| |_|\__|\__,_| # #=============================================================================== #=============================================================================== # CMake Project #=============================================================================== cmake_minimum_required(VERSION 2.8.12) # add this options before PROJECT keyword set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) project(Akantu) enable_language(CXX) #=============================================================================== # Misc. config for cmake #=============================================================================== set(AKANTU_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules") set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") mark_as_advanced(BUILD_SHARED_LIBS) if(NOT AKANTU_TARGETS_EXPORT) set(AKANTU_TARGETS_EXPORT AkantuLibraryDepends) endif() include(CMakeVersionGenerator) include(CMakePackagesSystem) include(CMakeFlagsHandling) include(AkantuPackagesSystem) include(AkantuMacros) #cmake_activate_debug_message() #=============================================================================== # Version Number #=============================================================================== # AKANTU version number. An even minor number corresponds to releases. set(AKANTU_MAJOR_VERSION 3) set(AKANTU_MINOR_VERSION 0) set(AKANTU_PATCH_VERSION 0) define_project_version() #=============================================================================== # Options #=============================================================================== # Debug set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DAKANTU_NDEBUG" CACHE STRING "Flags used by the compiler during release builds" FORCE) #add_flags(cxx "-Wall -Wextra -pedantic -Werror") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_flags(cxx "-Wall -Wextra -pedantic") else() add_flags(cxx "-Wall") endif() include(AkantuExtraCompilationProfiles) #=============================================================================== # Dependencies #=============================================================================== declare_akantu_types() package_list_packages(${PROJECT_SOURCE_DIR}/packages EXTRA_PACKAGES_FOLDER ${PROJECT_SOURCE_DIR}/extra_packages NO_AUTO_COMPILE_FLAGS) ## meta option \todo better way to do it when multiple package give enable the ## same feature if(AKANTU_SCOTCH) set(AKANTU_PARTITIONER ON) else() set(AKANTU_PARTITIONER OFF) endif() if(AKANTU_MUMPS) set(AKANTU_SOLVER ON) else() set(AKANTU_SOLVER OFF) endif() #=============================================================================== # Akantu library #=============================================================================== add_subdirectory(src) #=============================================================================== # Documentation #=============================================================================== if(AKANTU_DOCUMENTATION_DOXYGEN OR AKANTU_DOCUMENTATION_MANUAL) add_subdirectory(doc) else() set(AKANTU_DOC_EXCLUDE_FILES "${PROJECT_SOURCE_DIR}/doc/manual" CACHE INTERNAL "") endif() #=============================================================================== # Examples and tests #=============================================================================== option(AKANTU_EXAMPLES "Activate examples" OFF) option(AKANTU_TESTS "Activate tests" OFF) include(AkantuTestsMacros) include(AkantuExampleMacros) -if(AKANTU_EXAMPLES OR AKANTU_TESTS) +if(AKANTU_TESTS) option(AKANTU_BUILD_ALL_TESTS "Build all tests" ON) find_package(GMSH REQUIRED) endif() if(AKANTU_EXAMPLES) + find_package(GMSH REQUIRED) add_subdirectory(examples) endif() # tests add_test_tree(test) #=============================================================================== # Python interface #=============================================================================== package_is_activated(python_interface _python_act) if(_python_act) if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") set(AKANTU_PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) else() set(AKANTU_PYTHON_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") endif() add_subdirectory(python) endif() #=============================================================================== # Install and Packaging #=============================================================================== include(AkantuInstall) option(AKANTU_DISABLE_CPACK "This option commands the generation of extra info for the \"make package\" target" ON) mark_as_advanced(AKANTU_DISABLE_CPACK) if(NOT AKANTU_DISABLE_CPACK) include(AkantuCPack) endif() diff --git a/cmake/AkantuExampleMacros.cmake b/cmake/AkantuExampleMacros.cmake index 552a5e70f..1cb3c59c4 100644 --- a/cmake/AkantuExampleMacros.cmake +++ b/cmake/AkantuExampleMacros.cmake @@ -1,87 +1,103 @@ #=============================================================================== # @file AkantuExampleMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jan 18 2016 # @date last modification: Fri Jan 22 2016 # # @brief macros for examples # # @section LICENSE # # Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory # (LSMS - Laboratoire de Simulation en Mécanique des Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # # @section DESCRIPTION # #=============================================================================== include(AkantuSimulationMacros) # ============================================================================== function(register_example example_name) _add_akantu_simulation(${example_name} ${ARGN} LIST_FILES _example_files) if(DEFINED _add_examples_pkg) package_add_to_variable(EXAMPLES_FILES ${_add_examples_pkg} ${_example_files}) endif() endfunction() # ============================================================================== function(add_example et_name desc) string(TOUPPER ${et_name} upper_name) - if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${et_name}) - message(FATAL_ERROR "The folder ${CMAKE_CURRENT_SOURCE_DIR}/${et_name} " - "that you try to register as an example sub-folder, does not exists.") + if(NOT _build_all_ex) + option(AKANTU_BUILD_ALL_EXAMPLES "Activate all examples" OFF) + set( _build_all_ex TRUE) endif() - cmake_parse_arguments(_manage_example - "" - "" - "PACKAGE" - ${ARGN} - ) + option(AKANTU_BUILD_EXAMPLES_${upper_name} ${desc} OFF) - if(_manage_example_PACKAGE) - set(_act TRUE) - foreach(_pkg ${_manage_example_PACKAGE}) - package_is_activated(${_pkg} _activated) - if(NOT _activated) - set(_act FALSE) - endif() - endforeach() + if(AKANTU_BUILD_ALL_EXAMPLES) + mark_as_advanced(FORCE AKANTU_BUILD_EXAMPLES_${upper_name}) else() - message(SEND_ERROR "Examples should be associated to a package") + mark_as_advanced(CLEAR AKANTU_BUILD_EXAMPLES_${upper_name}) endif() - if(${_act}) - if(DEFINED _add_examples_pkg) - set(_save_add_examples_pkg ${_add_examples_pkg}) + if(AKANTU_BUILD_EXAMPLES_${upper_name} OR AKANTU_BUILD_ALL_EXAMPLES) + + if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${et_name}) + message(FATAL_ERROR "The folder ${CMAKE_CURRENT_SOURCE_DIR}/${et_name} " + "that you try to register as an example sub-folder, does not exists.") + endif() + + cmake_parse_arguments(_manage_example + "" + "" + "PACKAGE" + ${ARGN} + ) + + if(_manage_example_PACKAGE) + set(_act TRUE) + foreach(_pkg ${_manage_example_PACKAGE}) + package_is_activated(${_pkg} _activated) + if(NOT _activated) + set(_act FALSE) + endif() + endforeach() + else() + message(SEND_ERROR "Examples should be associated to a package") endif() - list(GET _manage_example_PACKAGE 0 _pkg) - set(_add_examples_pkg ${_pkg}) - add_subdirectory(${et_name}) + if(_act) + if(DEFINED _add_examples_pkg) + set(_save_add_examples_pkg ${_add_examples_pkg}) + endif() + list(GET _manage_example_PACKAGE 0 _pkg) + set(_add_examples_pkg ${_pkg}) + + add_subdirectory(${et_name}) - unset(_add_examples_pkg) - if(DEFINED _save_add_examples_pkg) - set(_add_examples_pkg ${_save_add_examples_pkg}) - unset(_save_add_examples_pkg) + unset(_add_examples_pkg) + if(DEFINED _save_add_examples_pkg) + set(_add_examples_pkg ${_save_add_examples_pkg}) + unset(_save_add_examples_pkg) + endif() endif() endif() endfunction() diff --git a/cmake/AkantuTestsMacros.cmake b/cmake/AkantuTestsMacros.cmake index 9b7733680..282c3fafe 100644 --- a/cmake/AkantuTestsMacros.cmake +++ b/cmake/AkantuTestsMacros.cmake @@ -1,414 +1,417 @@ #=============================================================================== # @file AkantuTestsMacros.cmake # # @author Nicolas Richart # # @date creation: Fri Sep 03 2010 # @date last modification: Fri Jan 22 2016 # # @brief macros for tests # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== #[=======================================================================[.rst: #AkantuTestsMacros #----------------- # #This modules provides the functions to helper to declare tests and folders #containing tests in akantu # #.. command:: add_test_tree # # add_test_tree() # # ```` is the entry direcroty of the full structure of # subfolders containing tests # #.. command:: add_akantu_test # # add_akantu_test( ) # # This function add a subdirectory ```` of tests that will be conditionnaly # activable and will be visible only if the parent folder as been activated An # option ``AKANTU_BUILD_TEST_`` will appear in ccmake with the description # ````. The compilation of all tests can be forced with the option # ``AKANTU_BUILD_ALL_TESTS`` # #.. command:: register_test # # register_test( # SOURCES ... # PACKAGE ... # SCRIPT # [FILES_TO_COPY ...] # [DEPENDS ...] # [DIRECTORIES_TO_CREATE ...] # [COMPILE_OPTIONS ...] # [EXTRA_FILES ...] # [UNSABLE] # [PARALLEL] # ) # # This function defines a test ``_run`` this test could be of # different nature depending on the context. If Just sources are provided the # test consist of running the executable generated. If a file ``.sh`` # is present the test will execute the script. And if a ``.verified`` # exists the output of the test will be compared to this reference file # # The options are: # # ``SOURCES ...`` # The list of source files to compile to generate the executable of the test # # ``PACKAGE ...`` # The list of package to which this test belongs. The test will be activable # only of all the packages listed are activated # # ``SCRIPT