diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake index bcb92d031..43007b49e 100644 --- a/cmake/AkantuMacros.cmake +++ b/cmake/AkantuMacros.cmake @@ -1,240 +1,245 @@ #=============================================================================== # @file AkantuMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Fri Oct 22 2010 # @date last modification: Tue Jan 19 2016 # # @brief Set of macros used by akantu cmake files # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== #=============================================================================== function(set_third_party_shared_libirary_name _var _lib) set(${_var} ${PROJECT_BINARY_DIR}/third-party/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_lib}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE FILEPATH "" FORCE) endfunction() # ============================================================================== function(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( - AKANTU_EXTERNAL_INCLUDE_DIR - AKANTU_EXTERNAL_LIBRARIES + 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_EXTERNAL_INCLUDE_DIR}) + 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/Modules/CMakePackagesSystem.cmake b/cmake/Modules/CMakePackagesSystem.cmake index 101e9f3ae..ff7313457 100644 --- a/cmake/Modules/CMakePackagesSystem.cmake +++ b/cmake/Modules/CMakePackagesSystem.cmake @@ -1,1064 +1,1092 @@ #=============================================================================== # @file CMakePackagesSystem.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Wed Nov 05 2014 # @date last modification: Wed Jan 20 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) # # 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: #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( # [ EXTRA_PACKAGE_FOLDER ] # [ SOURCE_FOLDER ] # [ TEST_FOLDER ] # [ MANUAL_FOLDER ] # ) # # This command will look for packages name like ``/.cmake`` # OR ``//package.cmake`` # #A package is a cmake script that should contain at list the declaration of a #package # #.. command:: package_declare # # package_declare( # [EXTERNAL] [META] [ADVANCED] [NOT_OPTIONAL] # [DESCRIPTION ] [DEFAULT ] # [DEPENDS ...] # [BOOST_COMPONENTS ...] # [EXTRA_PACKAGE_OPTIONS ...] # [COMPILE_FLAGS ] # [SYSTEM [ ]] # [FEATURES_PUBLIC ...] # [FEATURES_PRIVATE ...] # [EXCLUDE_FROM_ALL] # ) # #.. command:: package_declare_sources # # It can also declare multiple informations: # source files: # # package_declare_sources( # ... ) # #.. command:: package_declare_documentation # # a LaTeX documentation # package_declare_documentation( # ...) # #.. command:: package_declare_documentation_files # # LaTeX documentation files # package_declare_documentation_files( # ... ) # #Different function can also be retrieved from the package system by using the #different accessors # #.. command:: package_get_name # package_get_name( ) # #.. command:: package_get_real_name # package_get_real_name( ) # #.. command:: package_get_option_name # package_get_option_name( ) # #.. command:: package_use_system # package_use_system( ) # #.. command:: package_get_nature # package_get_nature( ) # #.. command:: package_get_description # package_get_description( ) # #.. command:: package_get_filename # package_get_filename( ) # #.. command:: package_get_sources_folder # package_get_sources_folder( ) #.. command:: package_get_tests_folder # package_get_tests_folder( ) #.. command:: package_get_manual_folder # package_get_manual_folder( ) # #.. command:: package_get_find_package_extra_options # package_get_find_package_extra_options( ) # #.. command:: package_get_compile_flags # package_get_compile_flags( ) #.. command:: package_set_compile_flags # package_set_compile_flags( ... ) # #.. command:: package_get_include_dir # package_get_include_dir( ) #.. command:: package_set_include_dir # package_set_include_dir( ... ) #.. command:: package_add_include_dir # package_add_include_dir( ... ) # #.. command:: package_get_libraries # package_get_libraries( ) #.. command:: package_set_libraries # package_set_libraries( ... ) # #.. command:: package_add_extra_dependency # package_add_extra_dependency(pkg ... ) #.. command:: package_rm_extra_dependency # package_rm_extra_dependency( ) #.. command:: package_get_extra_dependencies # package_get_extra_dependencies( ) # #.. command:: package_is_activated # package_is_activated( ) #.. command:: package_is_deactivated # package_is_deactivated( ) # #.. command:: package_get_dependencies -# package_get_dependencies( ) +# package_get_dependencies( ) #.. command:: package_add_dependencies -# package_add_dependencies( ... ) +# package_add_dependencies( ... ) # package_remove_dependencies( ... ) # package_remove_dependency( ) # #.. command:: package_on_enabled_script # package_on_enabled_script(