diff --git a/CMakeLists.txt b/CMakeLists.txt index 450b7c7..26512eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,143 +1,148 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief Main configuration file # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= cmake_minimum_required(VERSION 3.5.0) project(µSpectre) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(BUILD_SHARED_LIBS ON) add_compile_options(-Wall -Wextra -Weffc++) enable_testing() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) include(muspectreTools) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # using Clang add_compile_options(-Wno-missing-braces) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC add_compile_options(-Wno-non-virtual-dtor) string( TOLOWER "${CMAKE_BUILD_TYPE}" build_type ) if ("release" STREQUAL "${build_type}" ) add_compile_options(-march=native) endif() if ("debug" STREQUAL "${build_type}" ) add_compile_options(-O0) endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # using Intel C++ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # using Visual Studio C++ endif() find_package(Boost COMPONENTS unit_test_framework REQUIRED) add_external_package(Eigen3 VERSION 3.3 CONFIG) add_external_package(pybind11 VERSION 2.2 CONFIG) include_directories( ${CMAKE_SOURCE_DIR}/tests ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR} ) +if(APPLE) + include_directories(${CMAKE_INSTALL_PREFIX}/include) +endif() + #find_package(MPI REQUIRED) find_package(FFTW REQUIRED) #find_package(FFTWMPI REQUIRED) #build tests file( GLOB TEST_SRCS "${CMAKE_SOURCE_DIR}/tests/test_*.cc") +file( GLOB TEST_HDRS "${CMAKE_SOURCE_DIR}/tests/*.hh") -add_executable(main_test_suite tests/main_test_suite.cc ${TEST_SRCS}) +add_executable(main_test_suite tests/main_test_suite.cc ${TEST_SRCS} ${TEST_HDRS}) target_link_libraries(main_test_suite ${Boost_LIBRARIES} muSpectre) add_test(main_test_suite main_test_suite --report_level=detailed --build_info=TRUE) # compile the library add_compile_options( -Werror) add_subdirectory( ${CMAKE_SOURCE_DIR}/src/ ) add_subdirectory( ${CMAKE_SOURCE_DIR}/language_bindings/ ) add_subdirectory( ${CMAKE_SOURCE_DIR}/doc/ ) #compile executables file( GLOB binaries "${CMAKE_SOURCE_DIR}/bin/*.cc") foreach(binaryfile ${binaries}) get_filename_component(binaryname ${binaryfile} NAME_WE) add_executable(${binaryname} ${binaryfile}) target_link_libraries(${binaryname} ${Boost_LIBRARIES} muSpectre) endforeach(binaryfile ${binaries}) #or copy them file (GLOB pybins "${CMAKE_SOURCE_DIR}/bin/*.py") foreach(pybin ${pybins}) get_filename_component(binaryname ${pybin} NAME_WE) configure_file( ${pybin} "${CMAKE_BINARY_DIR}/${binaryname}.py" COPYONLY) endforeach(pybin ${pybins}) # compile benchmarks file(GLOB benchmarks "${CMAKE_SOURCE_DIR}/benchmarks/benchmark*cc") foreach(benchmark ${benchmarks}) get_filename_component(benchmark_name ${benchmark} NAME_WE) add_executable(${benchmark_name} ${benchmark}) target_link_libraries(${benchmark_name} ${BOOST_LIBRARIES} muSpectre) endforeach(benchmark ${benchmark}) # copy python test #build tests file( GLOB PY_TEST_SRCS "${CMAKE_SOURCE_DIR}/tests/python_*.py") foreach(pytest ${PY_TEST_SRCS}) get_filename_component(pytest_name ${pytest} NAME) configure_file( ${pytest} "${CMAKE_BINARY_DIR}/${pytest_name}" COPYONLY) endforeach(pytest ${PY_TEST_SRCS}) add_test(python_binding_test python_binding_tests.py) \ No newline at end of file diff --git a/language_bindings/python/CMakeLists.txt b/language_bindings/python/CMakeLists.txt index c37ee33..ffcd126 100644 --- a/language_bindings/python/CMakeLists.txt +++ b/language_bindings/python/CMakeLists.txt @@ -1,49 +1,55 @@ #============================================================================== # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for python binding using pybind11 # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # if(APPLE) # pybind11 (installed via homebrew) does not set include directories properly. # This is necessary to find Python.h. - find_package(PythonLibs 3) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "from distutils import sysconfig as s;print(s.get_python_inc(plat_specific=True));" + RESULT_VARIABLE _PYTHON_SUCCESS + OUTPUT_VARIABLE _PYTHON_VALUES + ERROR_VARIABLE _PYTHON_ERROR_VALUE) + list(GET _PYTHON_VALUES 0 PYTHON_INCLUDE_DIR) + include_directories(${PYTHON_INCLUDE_DIR}) endif() set (PY_BINDING_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_module.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_common.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_system.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_material.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_solvers.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_fftengine.cc ${CMAKE_CURRENT_SOURCE_DIR}/bind_py_projections.cc ) pybind11_add_module(pyMuSpectre ${PY_BINDING_SRCS}) target_link_libraries(pyMuSpectre PRIVATE muSpectre) # Want to rename the output, so that the python module is called muSpectre set_target_properties(pyMuSpectre PROPERTIES OUTPUT_NAME muSpectre) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 729dffd..0c2ceeb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,64 +1,66 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief Configuration for libmuSpectre # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= include_directories( common materials system ) set (muSpectre_SRC ) +set (muSpectre_HDR + ) add_subdirectory(common) add_subdirectory(materials) add_subdirectory(fft) add_subdirectory(system) add_subdirectory(solver) find_package(FFTW REQUIRED) # The following checks whether std::optional exists and replaces it by # boost::optional if necessary include(CheckCXXSourceCompiles) CHECK_CXX_SOURCE_COMPILES( "#include int main() { std::experimental::optional A{}; }" HAS_STD_OPTIONAL) if( NOT HAS_STD_OPTIONAL) add_definitions(-DNO_EXPERIMENTAL) endif() -add_library(muSpectre ${muSpectre_SRC}) +add_library(muSpectre ${muSpectre_SRC} ${muSpectre_HDR}) target_link_libraries(muSpectre Eigen3::Eigen ${FFTW_LIBRARIES}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 61403e9..4c8028c 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -1,39 +1,65 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for files in common # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= set (common_SRC #${CMAKE_CURRENT_SOURCE_DIR}/units.cc ${CMAKE_CURRENT_SOURCE_DIR}/common.cc ${CMAKE_CURRENT_SOURCE_DIR}/voigt_conversion.cc ) +set (common_HDR + ${CMAKE_CURRENT_SOURCE_DIR}/T4_map_proxy.hh + ${CMAKE_CURRENT_SOURCE_DIR}/ccoord_operations.hh + ${CMAKE_CURRENT_SOURCE_DIR}/common.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_collection.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_collection_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_collection_global.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_collection_local.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_map.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_map_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_map_scalar.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_map_tensor.hh + ${CMAKE_CURRENT_SOURCE_DIR}/iterators.hh + ${CMAKE_CURRENT_SOURCE_DIR}/tensor_algebra.hh + ${CMAKE_CURRENT_SOURCE_DIR}/utilities.hh + ${CMAKE_CURRENT_SOURCE_DIR}/voigt_conversion.hh + ${CMAKE_CURRENT_SOURCE_DIR}/eigen_tools.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field_map_matrixlike.hh + ${CMAKE_CURRENT_SOURCE_DIR}/field.hh + ) + set (muSpectre_SRC ${muSpectre_SRC} ${common_SRC} PARENT_SCOPE) + +set (muSpectre_HDR + ${muSpectre_HDR} + ${common_HDR} + PARENT_SCOPE) diff --git a/src/fft/CMakeLists.txt b/src/fft/CMakeLists.txt index 391edfc..a90149e 100644 --- a/src/fft/CMakeLists.txt +++ b/src/fft/CMakeLists.txt @@ -1,44 +1,60 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for fft-related files # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= set (fft_engine_SRC ${CMAKE_CURRENT_SOURCE_DIR}/fft_utils.cc ${CMAKE_CURRENT_SOURCE_DIR}/fft_engine_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/fftw_engine.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_default.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_small_strain.cc ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain_fast.cc ) +set (fft_engine_HDR + ${CMAKE_CURRENT_SOURCE_DIR}/fft_engine_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/fft_utils.hh + ${CMAKE_CURRENT_SOURCE_DIR}/fftw_engine.hh + ${CMAKE_CURRENT_SOURCE_DIR}/projection_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/projection_default.hh + ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain.hh + ${CMAKE_CURRENT_SOURCE_DIR}/projection_finite_strain_fast.hh + ${CMAKE_CURRENT_SOURCE_DIR}/projection_small_strain.hh + ) + set (muSpectre_SRC ${muSpectre_SRC} ${fft_engine_SRC} PARENT_SCOPE) + +set (muSpectre_HDR + ${muSpectre_HDR} + ${fft_engine_HDR} + PARENT_SCOPE) diff --git a/src/materials/CMakeLists.txt b/src/materials/CMakeLists.txt index 5c10a02..43dba26 100644 --- a/src/materials/CMakeLists.txt +++ b/src/materials/CMakeLists.txt @@ -1,42 +1,54 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for material laws # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= set (materials_SRC ${CMAKE_CURRENT_SOURCE_DIR}/material_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic1.cc ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic2.cc ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic3.cc ) +set (materials_HDR + ${CMAKE_CURRENT_SOURCE_DIR}/material_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic1.hh + ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic2.hh + ${CMAKE_CURRENT_SOURCE_DIR}/material_linear_elastic3.hh + ${CMAKE_CURRENT_SOURCE_DIR}/material_muSpectre_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/materials_toolbox.hh + ) + set (muSpectre_SRC ${muSpectre_SRC} ${materials_SRC} PARENT_SCOPE) - +set (muSpectre_HDR + ${muSpectre_HDR} + ${materials_HDR} + PARENT_SCOPE) diff --git a/src/solver/CMakeLists.txt b/src/solver/CMakeLists.txt index e68a7d7..2cb8404 100644 --- a/src/solver/CMakeLists.txt +++ b/src/solver/CMakeLists.txt @@ -1,40 +1,53 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for solvers # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= set (solvers_SRC ${CMAKE_CURRENT_SOURCE_DIR}/solver_base.cc ${CMAKE_CURRENT_SOURCE_DIR}/solver_cg.cc ${CMAKE_CURRENT_SOURCE_DIR}/solver_cg_eigen.cc ${CMAKE_CURRENT_SOURCE_DIR}/solvers.cc ) +set (solvers_HDR + ${CMAKE_CURRENT_SOURCE_DIR}/solver_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/solver_cg.hh + ${CMAKE_CURRENT_SOURCE_DIR}/solver_cg_eigen.hh + ${CMAKE_CURRENT_SOURCE_DIR}/solver_error.hh + ${CMAKE_CURRENT_SOURCE_DIR}/solvers.hh + ) + set (muSpectre_SRC ${muSpectre_SRC} ${solvers_SRC} PARENT_SCOPE) + +set (muSpectre_HDR + ${muSpectre_HDR} + ${solvers_HDR} + PARENT_SCOPE) diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt index 14028ef..581046d 100644 --- a/src/system/CMakeLists.txt +++ b/src/system/CMakeLists.txt @@ -1,37 +1,48 @@ # ============================================================================= # file CMakeLists.txt # # @author Till Junge # # @date 08 Jan 2018 # # @brief configuration for system implementations # # @section LICENSE # # Copyright © 2018 Till Junge # # µSpectre is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3, or (at # your option) any later version. # # µSpectre 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Emacs; see the file COPYING. If not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # ============================================================================= set (systems_SRC ${CMAKE_CURRENT_SOURCE_DIR}/system_base.cc ) +set (systems_HDR + ${CMAKE_CURRENT_SOURCE_DIR}/system_base.hh + ${CMAKE_CURRENT_SOURCE_DIR}/system_factory.hh + ${CMAKE_CURRENT_SOURCE_DIR}/system_traits.hh + ) + set (muSpectre_SRC ${muSpectre_SRC} ${systems_SRC} PARENT_SCOPE) + +set (muSpectre_HDR + ${muSpectre_HDR} + ${systems_HDR} + PARENT_SCOPE)