Skip to content
Snippets Groups Projects
Commit d598c8ca authored by Santiago Ospina De Los Ríos's avatar Santiago Ospina De Los Ríos
Browse files

Export configuration CMake file

Now targets seem to be importable in a very simple manner.
parent 763dd6a4
No related branches found
No related tags found
1 merge request!49Resolve "Finish installation and usage instruction on the documentation"
Pipeline #32906 failed
# We require version CMake version 3.1 to prevent issues
# with dune_enable_all_packages and older CMake versions.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.13)
project(dune-copasi CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
......@@ -13,8 +11,10 @@ cmake_policy(SET CMP0074 NEW)
#find dune-common and set the module path
find_package(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules"
${dune-common_MODULE_PATH})
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake/modules"
"${dune-common_MODULE_PATH}"
)
#include the dune macros
include(DuneMacros)
......@@ -35,43 +35,72 @@ endif()
# Single domain target
set(DUNE_COPASI_SD_EXECUTABLE OFF
CACHE BOOL "Build singledomain executable by default"
CACHE BOOL "Build SingleDomain executable by default"
)
set(DUNE_COPASI_SD_LIBRARY ${DUNE_COPASI_SD_EXECUTABLE}
CACHE BOOL "Include precompiled SingleDomain objects in dune-copasi library (optional)"
)
# Multiple domain target
set(DUNE_COPASI_MD_EXECUTABLE ON
CACHE BOOL "Build multidomain executable by default"
CACHE BOOL "Build MultiDimain executable by default"
)
set(DUNE_COPASI_MD_LIBRARY ${DUNE_COPASI_MD_EXECUTABLE}
CACHE BOOL "Include precompiled MultiDimain objects in dune-copasi library (optional)"
)
# main target
add_custom_target(dune_copasi ALL)
add_library(dune-copasi)
target_include_directories(dune-copasi PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(dune-copasi PUBLIC ${DUNE_LIBS} TIFF::TIFF muparser::muparser)
option(DUNE_COPASI_COMPILE_3D "Compile 3D cases in libraries and executables" OFF)
if (DUNE_COPASI_COMPILE_3D)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_COMPILE_3D)
endif()
if(USE_FALLBACK_FILESYSTEM)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_USE_FALLBACK_FILESYSTEM)
target_link_libraries(dune-copasi PUBLIC ghc_filesystem)
elseif(Filesystem_FOUND)
target_link_libraries(dune-copasi PUBLIC std::filesystem)
endif()
add_subdirectory(src)
add_subdirectory(dune)
add_subdirectory(lib)
add_subdirectory(src)
if (dune-testtools_FOUND)
add_subdirectory(python)
endif()
add_subdirectory(doc)
add_subdirectory(test)
add_subdirectory(cmake/modules)
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
install(TARGETS dune-copasi
EXPORT dune-copasi-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(EXPORT dune_copasi
install(EXPORT dune-copasi-targets
FILE
dune-copasi-targets.cmake
NAMESPACE
dune_copasi::
dune::
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/dune-copasi"
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"dune-copasi-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/dune-copasi-config.cmake"
INSTALL_DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/dune-copasi-config"
)
# finalize the dune project: Generate and install config.h, cmake targets and version
include(SetupDuneCopasiConfig)
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
add_subdirectory(test)
# include(CPack)
set(modules "DuneCopasiMacros.cmake")
install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
install(FILES
DuneCopasiMacros.cmake
FindFilesystem.cmake
Findmuparser.cmake
SetupDuneCopasiConfig.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR})
# This settings define the installed cmake config file. It adds a minimal setup
# for the dune requirements without cluttering the whole project with old CMake
set_property(GLOBAL PROPERTY DUNE_MODULE_LIBRARIES dune-copasi)
set(DUNE_CUSTOM_PKG_CONFIG_SECTION
"
include(CMakeFindDependencyMacro)
find_dependency(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH \${dune-common_MODULE_PATH})
include(DuneMacros)
include(CheckCXXFeatures)
include(DuneCxaDemangle)
include(DuneMPI)
set(DUNE_PYTHON_VIRTUALENV_SETUP ${DUNE_PYTHON_VIRTUALENV_SETUP})
set(ProjectName dune-copasi)
define_property(GLOBAL PROPERTY DUNE_MODULE_LIBRARIES
BRIEF_DOCS \"List of libraries of the module. DO NOT EDIT!\"
FULL_DOCS \"List of libraries of the module. Used to generate CMake's package configuration files. DO NOT EDIT!\")
find_file(\${ProjectName}_MODULE_DIR dune.module
HINTS
\"\${\${ProjectName}_PREFIX}\"
\"\${\${ProjectName}_PREFIX}/lib/dunecontrol/\${ProjectName}\"
\"\${\${ProjectName}_PREFIX}/lib64/dunecontrol/\${ProjectName}\"
REQUIRED
NO_DEFAULT_PATH
)
string(REPLACE dune.module \"\" \${ProjectName}_MODULE_DIR \${\${ProjectName}_MODULE_DIR})
dune_module_information(\${\${ProjectName}_MODULE_DIR})
dune_create_dependency_tree()
dune_process_dependency_macros()
unset(ProjectName)
")
......@@ -31,7 +31,7 @@ mkdir -m 777 dunecopasi && cd dunecopasi
```
This working directory will be accessible to your text editor and paraview as
well as to the `dune_copasi_md` executable inside the docker container. Thus,
well as to the `dune-copasi-md` executable inside the docker container. Thus,
move or create your configuration files into it at will.
```
......@@ -39,17 +39,17 @@ nano config.ini
# set-up/write ini file for dune-copasi...
```
### Run `dune_copasi_md`
### Run the program
Then, you may use the latest stable container by pulling/runing it from our
[GitLab registry](https://gitlab.dune-project.org/copasi/dune-copasi/container_registry)
To run the `dune_copasi_md` executable from the container with a configuration
To run the `dune-copasi-md` executable from the container with a configuration
file `config.ini`, execute the following command on the terminal:
```bash
docker run -v $PWD:/dunecopasi \
registry.dune-project.org/copasi/dune-copasi/dune-copasi:latest \
dune_copasi_md config.ini
dune-copasi-md config.ini
```
The results of those computations will be written on current
......@@ -168,14 +168,28 @@ echo export PATH="/opt/dune/bin:$PATH" >> $HOME/.bashrc
For further info on dune module installation process, please check out
the [dune-project web page](https://www.dune-project.org/doc/installation/).
### Run `DuneCopasi`
### Run the program
Now, you should be able to call the program `dune_copasi_md` from your command
Now, you should be able to call the program `dune-copasi-md` from your command
line accompained with a configuration file:
```bash
dune_copasi_md config.ini
dune-copasi-md config.ini
```
To find out the appropiated contents on the configuration file, check out
the [Parameter Tree](param_tree.md) documentation.
## Using the C++ API
In order to use the C++ interface, you must have compiled and (optionally)
installed all the dune packages from source. Then, you will be able to import
and link the CMake targets for `dune-copasi` by simply calling the following
commands in CMake:
```cmake
# ...
find_package(dune-copasi IMPORTED)
target_link_libraries(my_app PRIVATE dune::dune-copasi)
# ...
```
@PACKAGE_INIT@
get_filename_component(dune_copasi_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(CMakeFindDependencyMacro)
if(NOT TARGET dune_copasi::dune_copasi)
include("${dune_copasi_CMAKE_DIR}/dune-copasi-targets.cmake")
endif()
......@@ -68,7 +68,6 @@ protected:
private:
AdaptivityPolicy _adapt_policy;
double _begin_time, _end_time, _current_time;
};
} // namespace Dune::Copasi
......
include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Global flag to cause add_library() to create shared libraries if ON" OFF)
option(DUNE_COPASI_COMPILE_3D "Compile 3D cases in libraries and executables" OFF)
# Common library
add_library(dune_copasi_lib STATIC ../dune/copasi/model/base.cc)
target_link_libraries(dune_copasi_lib PUBLIC ${DUNE_LIBS} TIFF::TIFF muparser::muparser)
target_include_directories(dune_copasi_lib INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
target_include_directories(dune-copasi
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
)
if (DUNE_COPASI_COMPILE_3D)
target_compile_definitions(dune_copasi_lib PUBLIC DUNE_COPASI_COMPILE_3D)
endif()
if(USE_FALLBACK_FILESYSTEM)
target_compile_definitions(dune_copasi_lib PUBLIC DUNE_COPASI_USE_FALLBACK_FILESYSTEM)
target_link_libraries(dune_copasi_lib PUBLIC ghc_filesystem)
elseif(Filesystem_FOUND)
target_link_libraries(dune_copasi_lib PUBLIC std::filesystem)
endif()
if(BUILD_SHARED_LIBS)
install(TARGETS dune_copasi_lib EXPORT dune_copasi)
endif()
# MultiDomain library
if(DUNE_COPASI_MD_EXECUTABLE)
add_library(dune_copasi_md_lib_fv dune_copasi_md_fv.cc)
target_link_libraries(dune_copasi_md_lib_fv PUBLIC dune_copasi_lib)
add_library(dune_copasi_md_lib_cg dune_copasi_md_cg.cc)
target_link_libraries(dune_copasi_md_lib_cg PUBLIC dune_copasi_lib)
add_library(dune_copasi_md_lib_fv_cg dune_copasi_md_fv_cg.cc)
target_link_libraries(dune_copasi_md_lib_fv_cg PUBLIC dune_copasi_lib)
add_library(dune_copasi_md_lib INTERFACE)
target_link_libraries(dune_copasi_md_lib INTERFACE
dune_copasi_md_lib_fv
dune_copasi_md_lib_cg
dune_copasi_md_lib_fv_cg
# SingleDomain library
add_library(dune-copasi-sd-lib
EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_sd_fv.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_sd_cg.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_sd_fv_cg.cc"
)
if(DUNE_COPASI_SD_LIBRARY)
set_target_properties(dune-copasi-sd-lib PROPERTIES EXCLUDE_FROM_ALL OFF)
target_link_libraries(dune-copasi PUBLIC dune-copasi-sd-lib)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_SD_LIBRARY)
install(TARGETS dune-copasi-sd-lib
EXPORT dune-copasi-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL
)
if(BUILD_SHARED_LIBS)
install(TARGETS
dune_copasi_md_lib_fv
dune_copasi_md_lib_cg
dune_copasi_md_lib_fv_cg
EXPORT dune_copasi
COMPONENT MultiDomain
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
endif()
# SingleDomain library
if(DUNE_COPASI_SD_EXECUTABLE)
add_library(dune_copasi_sd_lib_fv dune_copasi_sd_fv.cc)
target_link_libraries(dune_copasi_sd_lib_fv PUBLIC dune_copasi_lib)
add_library(dune_copasi_sd_lib_cg dune_copasi_sd_cg.cc)
target_link_libraries(dune_copasi_sd_lib_cg PUBLIC dune_copasi_lib)
add_library(dune_copasi_sd_lib_fv_cg dune_copasi_sd_fv_cg.cc)
target_link_libraries(dune_copasi_sd_lib_fv_cg PUBLIC dune_copasi_lib)
add_library(dune_copasi_sd_lib INTERFACE)
target_link_libraries(dune_copasi_sd_lib INTERFACE
dune_copasi_sd_lib_fv
dune_copasi_sd_lib_cg
dune_copasi_sd_lib_fv_cg
# MultiDomain library
add_library(dune-copasi-md-lib
EXCLUDE_FROM_ALL
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md_fv.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md_cg.cc"
"${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md_fv_cg.cc"
)
if(DUNE_COPASI_MD_LIBRARY)
set_target_properties(dune-copasi-md-lib PROPERTIES EXCLUDE_FROM_ALL OFF)
target_link_libraries(dune-copasi PUBLIC dune-copasi-md-lib)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_MD_LIBRARY)
install(TARGETS dune-copasi-md-lib
EXPORT dune-copasi-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
OPTIONAL
)
if(BUILD_SHARED_LIBS)
install(TARGETS
dune_copasi_sd_lib_fv
dune_copasi_sd_lib_cg
dune_copasi_sd_lib_fv_cg
COMPONENT SigleDomain
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT dune_copasi
)
endif()
endif()
include(GNUInstallDirs)
target_sources(dune-copasi
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/dune/copasi/model/base.cc"
)
# SingleDomain executable
add_executable(dune-copasi-sd EXCLUDE_FROM_ALL "${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_sd.cc")
target_link_libraries(dune-copasi-sd PRIVATE dune-copasi)
if(DUNE_COPASI_SD_EXECUTABLE)
add_executable(dune_copasi_sd dune_copasi_sd.cc)
target_link_libraries(dune_copasi_sd PRIVATE dune_copasi_sd_lib)
add_dependencies(dune_copasi dune_copasi_sd)
install(TARGETS dune_copasi_sd
EXPORT dune_copasi
COMPONENT SigleDomain
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
set_target_properties(dune-copasi-sd PROPERTIES EXCLUDE_FROM_ALL OFF)
install(TARGETS dune-copasi-sd
COMPONENT MultiDomain
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()
# MultiDomain executable
add_executable(dune-copasi-md EXCLUDE_FROM_ALL "${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md.cc")
target_link_libraries(dune-copasi-md PRIVATE dune-copasi)
if(DUNE_COPASI_MD_EXECUTABLE)
add_executable(dune_copasi_md dune_copasi_md.cc)
target_link_libraries(dune_copasi_md PRIVATE dune_copasi_md_lib)
add_dependencies(dune_copasi dune_copasi_md)
install(TARGETS dune_copasi_md
EXPORT dune_copasi
set_target_properties(dune-copasi-md PROPERTIES EXCLUDE_FROM_ALL OFF)
install(TARGETS dune-copasi-md
COMPONENT MultiDomain
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
endif()
File moved
......@@ -8,6 +8,9 @@
#include <dune/copasi/grid/multidomain_gmsh_reader.hh>
#include <dune/copasi/model/diffusion_reaction.hh>
#include <dune/copasi/model/multidomain_diffusion_reaction.hh>
#ifndef DUNE_COPASI_SD_LIBRARY
#include <dune/copasi/model/multidomain_diffusion_reaction.cc>
#endif
#include <dune/grid/multidomaingrid.hh>
......
......@@ -7,6 +7,9 @@
#include <dune/copasi/grid/mark_stripes.hh>
#include <dune/copasi/grid/multidomain_gmsh_reader.hh>
#include <dune/copasi/model/diffusion_reaction.hh>
#ifndef DUNE_COPASI_SD_LIBRARY
#include <dune/copasi/model/diffusion_reaction.cc>
#endif
#include <dune/grid/multidomaingrid.hh>
......
......@@ -31,46 +31,45 @@ add_custom_target(build_system_tests DEPENDS dune_copasi)
if(DUNE_COPASI_SD_EXECUTABLE)
# Some dune tests modify the EXCLUDE_FROM_ALL propertie of targets
# Therefore, we store them temporally and set them back after seting up the tests
get_target_property(TMP_SD_EFA dune_copasi_sd EXCLUDE_FROM_ALL)
add_executable(dune_copasi_sd_compare EXCLUDE_FROM_ALL dune_copasi_sd_compare.cc)
target_link_libraries(dune_copasi_sd_compare PRIVATE dune_copasi_sd_lib)
get_target_property(TMP_SD_EFA dune-copasi-sd EXCLUDE_FROM_ALL)
add_executable(dune-copasi-sd-compare EXCLUDE_FROM_ALL dune_copasi_sd_compare.cc)
target_link_libraries(dune-copasi-sd-compare PRIVATE dune-copasi)
add_dependencies(build_system_tests
dune_copasi_sd
dune_copasi_sd_compare)
dune-copasi-sd
dune-copasi-sd-compare)
if (dune-testtools_FOUND)
add_system_test_per_target(
TARGET dune_copasi_sd_compare
TARGET dune-copasi-sd-compare
INIFILE test_exp.mini)
add_system_test_per_target(
TARGET dune_copasi_sd_compare
TARGET dune-copasi-sd-compare
INIFILE test_initial.mini)
add_system_test_per_target(
TARGET dune_copasi_sd_compare
TARGET dune-copasi-sd-compare
INIFILE test_gauss.mini)
add_system_test_per_target(
TARGET dune_copasi_sd
TARGET dune-copasi-sd
SCRIPT dune_vtkcompare.py
INIFILE test_tiff.mini)
add_system_test_per_target(
TARGET dune_copasi_sd
TARGET dune-copasi-sd
INIFILE test_brusselator.mini)
add_system_test_per_target(
TARGET dune_copasi_sd
TARGET dune-copasi-sd
INIFILE test_no_writer.mini)
endif()
# Set back EXCLUDE_FROM_ALL target properties
set_target_properties(dune_copasi_sd PROPERTIES EXCLUDE_FROM_ALL ${TMP_SD_EFA})
set_target_properties(dune-copasi-sd PROPERTIES EXCLUDE_FROM_ALL ${TMP_SD_EFA})
endif()
......@@ -78,69 +77,69 @@ endif()
if(DUNE_COPASI_SD_EXECUTABLE)
# Some dune tests modify the EXCLUDE_FROM_ALL propertie of targets
# Therefore, we store them temporally and set them back after seting up the tests
get_target_property(TMP_MD_EFA dune_copasi_md EXCLUDE_FROM_ALL)
get_target_property(TMP_MD_EFA dune-copasi-md EXCLUDE_FROM_ALL)
add_executable(dune_copasi_md_compare EXCLUDE_FROM_ALL dune_copasi_md_compare.cc)
add_executable(dune_copasi_md_jacobian EXCLUDE_FROM_ALL test_jacobian.cc)
add_executable(dune-copasi-md-compare EXCLUDE_FROM_ALL dune_copasi_md_compare.cc)
add_executable(dune-copasi-md-jacobian EXCLUDE_FROM_ALL test_jacobian.cc)
target_link_libraries(dune_copasi_md_compare PRIVATE dune_copasi_md_lib)
target_link_libraries(dune_copasi_md_jacobian PRIVATE dune_copasi_md_lib)
target_link_libraries(dune-copasi-md-compare PRIVATE dune-copasi)
target_link_libraries(dune-copasi-md-jacobian PRIVATE dune-copasi)
add_dependencies(build_system_tests
dune_copasi_md_compare
dune_copasi_md_jacobian
dune-copasi-md-compare
dune-copasi-md-jacobian
)
if (dune-testtools_FOUND)
add_system_test_per_target(
TARGET dune_copasi_md_compare
TARGET dune-copasi-md-compare
INIFILE test_exp.mini)
add_system_test_per_target(
TARGET dune_copasi_md_compare
TARGET dune-copasi-md-compare
INIFILE test_initial.mini)
add_system_test_per_target(
TARGET dune_copasi_md_compare
TARGET dune-copasi-md-compare
INIFILE test_gauss.mini)
add_system_test_per_target(
TARGET dune_copasi_md_compare
TARGET dune-copasi-md-compare
INIFILE test_gauss_mixed_geometry.mini)
add_system_test_per_target(
TARGET dune_copasi_md
TARGET dune-copasi-md
SCRIPT dune_vtkcompare.py
INIFILE test_tiff.mini)
add_system_test_per_target(
TARGET dune_copasi_md
TARGET dune-copasi-md
SCRIPT dune_vtkcompare.py
INIFILE test_cell.mini)
add_system_test_per_target(
TARGET dune_copasi_md
TARGET dune-copasi-md
INIFILE test_no_writer.mini)
add_system_test_per_target(
TARGET dune_copasi_md_jacobian
TARGET dune-copasi-md-jacobian
INIFILE test_cell.mini)
set_property(TEST "dune_copasi_md_jacobian_test_cell" PROPERTY LABELS unit)
set_property(TEST "dune_copasi_md_jacobian_test_cell" PROPERTY LABELS unit)
set_property(TEST "dune-copasi-md-jacobian_test_cell" PROPERTY LABELS unit)
set_property(TEST "dune-copasi-md-jacobian_test_cell" PROPERTY LABELS unit)
add_system_test_per_target(
TARGET dune_copasi_md_jacobian
TARGET dune-copasi-md-jacobian
INIFILE test_NFkappaB.mini)
set_property(TEST "dune_copasi_md_jacobian_test_NFkappaB" PROPERTY LABELS unit)
set_property(TEST "dune_copasi_md_jacobian_test_NFkappaB" PROPERTY LABELS unit)
set_property(TEST "dune-copasi-md-jacobian_test_NFkappaB" PROPERTY LABELS unit)
set_property(TEST "dune-copasi-md-jacobian_test_NFkappaB" PROPERTY LABELS unit)
endif()
# Set back EXCLUDE_FROM_ALL target properties
set_target_properties(dune_copasi_md PROPERTIES EXCLUDE_FROM_ALL ${TMP_MD_EFA})
set_target_properties(dune-copasi-md PROPERTIES EXCLUDE_FROM_ALL ${TMP_MD_EFA})
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment