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

Fix target cyclic dependency when requiring shared libraries

parent 90a852a9
No related branches found
No related tags found
1 merge request!54Fix target cyclic dependency when requiring shared libraries
Pipeline #33770 passed
...@@ -64,6 +64,7 @@ Types of changes ...@@ -64,6 +64,7 @@ Types of changes
- Final timestep reduction to reach `end_time` failed in adaptive stepper !43 - Final timestep reduction to reach `end_time` failed in adaptive stepper !43
- Infinite loop when final adaptive step failed !45 - Infinite loop when final adaptive step failed !45
- Binary executables are now installed !49 - Binary executables are now installed !49
- Support for shared libraries !54
## [0.3.0] ([git-diff][0.3.0-diff]) - 2020-10-07 ## [0.3.0] ([git-diff][0.3.0-diff]) - 2020-10-07
### Added ### Added
......
...@@ -30,6 +30,8 @@ option(DUNE_COPASI_COMPILE_3D ...@@ -30,6 +30,8 @@ option(DUNE_COPASI_COMPILE_3D
OFF OFF
) )
########## Setup dependencies ##########
# find dune dependencies # find dune dependencies
find_package(dune-common REQUIRED) find_package(dune-common REQUIRED)
...@@ -78,10 +80,37 @@ if(DUNE_USE_FALLBACK_FILESYSTEM) ...@@ -78,10 +80,37 @@ if(DUNE_USE_FALLBACK_FILESYSTEM)
endif() endif()
endif() endif()
# create main target ########## Setup dependency target ##########
# create a target to gather all dependencies
add_library(dune-copasi-deps INTERFACE)
target_link_libraries(dune-copasi-deps INTERFACE ${DUNE_LIBS} TIFF::TIFF PkgConfig::muparser)
# add missing definition from muparser pkg-config file
if(NOT ${BUILD_SHARED_LIBS})
target_compile_definitions(dune-copasi-deps INTERFACE MUPARSER_STATIC)
endif()
# Set up filesystem. Where do we get it from?
if(DUNE_USE_FALLBACK_FILESYSTEM)
# and add ghc_filesystem to our filesystem target
target_link_libraries(dune-copasi-deps INTERFACE ghcFilesystem::ghc_filesystem)
target_compile_definitions(dune-copasi-deps INTERFACE DUNE_USE_FALLBACK_FILESYSTEM)
else()
# ... else we don't need a back up. Link agaist standard library
target_link_libraries(dune-copasi-deps INTERFACE std::filesystem)
endif()
########## Create main liabrary ##########
# create main library
add_library(dune-copasi) add_library(dune-copasi)
set_target_properties(dune-copasi PROPERTIES LIBRARY_OUTPUT_NAME dunecopasi) set_target_properties(dune-copasi PROPERTIES LIBRARY_OUTPUT_NAME dunecopasi)
set_target_properties(dune-copasi PROPERTIES ARCHIVE_OUTPUT_NAME dunecopasi) set_target_properties(dune-copasi PROPERTIES ARCHIVE_OUTPUT_NAME dunecopasi)
target_link_libraries(dune-copasi PUBLIC dune-copasi-deps)
dune_target_enable_all_packages(dune-copasi)
########## Include other scripts ##########
# include header files # include header files
add_subdirectory(dune) add_subdirectory(dune)
...@@ -123,7 +152,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dune/copasi/FC.h" ...@@ -123,7 +152,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dune/copasi/FC.h"
) )
# taget configuration for downstream projects # taget configuration for downstream projects
install(TARGETS dune-copasi install(TARGETS dune-copasi-deps dune-copasi
EXPORT dune-copasi-targets EXPORT dune-copasi-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Libraries COMPONENT Libraries
......
...@@ -4,12 +4,36 @@ title: Application Programming Interface ...@@ -4,12 +4,36 @@ title: Application Programming Interface
sidebar_label: API sidebar_label: API
--- ---
The C++ classes are documented in the source code and may be visualized with
[Doxygen](https://www.doxygen.nl/index.html). To locally have the doxygen html
documentation, build `dune-copasi` [manually](install_use.md) and use the
`make doc` target in the build directory.
:::caution Work In Progress :::caution Work In Progress
Make the Doxygen documentation available online.
::: :::
### Doxygen Documentation
The C++ classes are documented in the C++ source code and may be visualized with
[Doxygen](https://www.doxygen.nl/index.html). To locally have the doxygen html
documentation, build `dune-copasi` [manually](install_use.md) and use the
`make doc` target in the build directory. For this, you need to have `doxygen` on your syste,
### Preprocessor Definitions
There are two sources of preprocessor definitions:
* **CMake targets**: These are transsitively passed together with the `dune-copas::dune-copasi` target.
These are stored on the `INTERFACE_COMPILE_DEFINITIONS` property of the target.
```bash title="CMakeLists.txt"
get_target_property(definitons dune-copasi::dune-copasi INTERFACE_COMPILE_DEFINITIONS)
message("dune-copasi cmake compile definitions: '${definitions}'")
```
* **Config header**: We inherit a config header from the dune build system. It's installed under
`include/dune/copasi/config.h` on the cmake install prefix (e.g. `/opt/dune/`).
The following is a list of useful definitions:
| Definition | Usage |
| ---------| -------------- |
| `DUNE_COPASI_SD_LIBRARY` | Inspect if the precompiled instantiations for single domain models are present. If so, you may skip inclusion of `dune/copasi/model/multidomain_diffusion_reaction.cc` template defintions.
| `DUNE_COPASI_MD_LIBRARY` | Inspect if the precompiled instantiations for multiple domain models are present. If so If so, you may skip inclusion of `dune/copasi/model/diffusion_reaction.cc` template defintions.
| `HAVE_DUNE_COPASI_CONFIG_H` | Whether the `dune/copasi/config.h` header must be included
| `DUNE_USE_FALLBACK_FILESYSTEM` | Whether `dune-copasi` is using [`ghc::filesystem`](https://github.com/gulrak/filesystem)
...@@ -94,7 +94,7 @@ module.exports = { ...@@ -94,7 +94,7 @@ module.exports = {
footer: { footer: {
style: 'dark', style: 'dark',
links: [], links: [],
copyright: `${copyright} | ${impressum} | ${datenschutz} | ${disclaimer}`, //copyright: `${copyright} | ${impressum} | ${datenschutz} | ${disclaimer}`,
}, },
}, },
presets: [ presets: [
......
# add dune dependencies to main target # SingleDomain objects
dune_target_enable_all_packages(dune-copasi)
# add dependencies
target_link_libraries(dune-copasi PUBLIC ${DUNE_LIBS} TIFF::TIFF PkgConfig::muparser)
if(NOT ${BUILD_SHARED_LIBS})
target_compile_definitions(dune-copasi PUBLIC MUPARSER_STATIC)
endif()
if(DUNE_COPASI_COMPILE_3D)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_COMPILE_3D)
endif()
# Set up filesystem. Where do we get it from?
if(DUNE_USE_FALLBACK_FILESYSTEM)
# and add ghc_filesystem to our filesystem target
target_link_libraries(dune-copasi PUBLIC ghcFilesystem::ghc_filesystem)
target_compile_definitions(dune-copasi PUBLIC DUNE_USE_FALLBACK_FILESYSTEM)
else()
# ... else we don't need a back up. Link agaist standard library
target_link_libraries(dune-copasi PUBLIC std::filesystem)
endif()
# define, link and install auxiliary develpment targets for dune-copasi
unset(AUX_DEVELOPMENT_TARGETS)
# SingleDomain library
add_library(singledomain-lib add_library(singledomain-lib
OBJECT
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
dune_copasi_sd_fv.cc dune_copasi_sd_fv.cc
dune_copasi_sd_cg.cc dune_copasi_sd_cg.cc
dune_copasi_sd_fv_cg.cc dune_copasi_sd_fv_cg.cc
) )
target_link_directories(singledomain-lib PRIVATE target_link_directories(singledomain-lib PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> target_link_libraries(singledomain-lib PRIVATE dune-copasi-deps)
)
target_link_libraries(singledomain-lib PRIVATE dune-copasi)
set_target_properties(singledomain-lib PROPERTIES LIBRARY_OUTPUT_NAME dunecopasisd)
set_target_properties(singledomain-lib PROPERTIES ARCHIVE_OUTPUT_NAME dunecopasisd)
if(DUNE_COPASI_SD_LIBRARY) if(DUNE_COPASI_SD_LIBRARY)
set_target_properties(singledomain-lib PROPERTIES EXCLUDE_FROM_ALL OFF) set_target_properties(singledomain-lib PROPERTIES EXCLUDE_FROM_ALL OFF)
target_link_libraries(dune-copasi INTERFACE singledomain-lib) target_sources(dune-copasi PRIVATE $<TARGET_OBJECTS:singledomain-lib>)
target_compile_definitions(dune-copasi INTERFACE DUNE_COPASI_SD_LIBRARY) target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_MD_LIBRARY)
list(APPEND AUX_DEVELOPMENT_TARGETS singledomain-lib)
endif() endif()
# MultiDomain library # MultiDomain objects
add_library(multidomain-lib add_library(multidomain-lib
OBJECT
EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL
dune_copasi_md_fv.cc dune_copasi_md_fv.cc
dune_copasi_md_cg.cc dune_copasi_md_cg.cc
dune_copasi_md_fv_cg.cc dune_copasi_md_fv_cg.cc
) )
target_link_directories(multidomain-lib PRIVATE target_link_directories(multidomain-lib PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> target_link_libraries(multidomain-lib PRIVATE dune-copasi-deps)
)
target_link_libraries(multidomain-lib PRIVATE dune-copasi)
set_target_properties(multidomain-lib PROPERTIES LIBRARY_OUTPUT_NAME dunecopasimd)
set_target_properties(multidomain-lib PROPERTIES ARCHIVE_OUTPUT_NAME dunecopasimd)
if(DUNE_COPASI_MD_LIBRARY) if(DUNE_COPASI_MD_LIBRARY)
set_target_properties(multidomain-lib PROPERTIES EXCLUDE_FROM_ALL OFF) set_target_properties(multidomain-lib PROPERTIES EXCLUDE_FROM_ALL OFF)
target_link_libraries(dune-copasi INTERFACE multidomain-lib) target_sources(dune-copasi PRIVATE $<TARGET_OBJECTS:multidomain-lib>)
target_compile_definitions(dune-copasi INTERFACE DUNE_COPASI_MD_LIBRARY) target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_SD_LIBRARY)
list(APPEND AUX_DEVELOPMENT_TARGETS multidomain-lib) endif()
endif() \ No newline at end of file
# install development targets
install(TARGETS ${AUX_DEVELOPMENT_TARGETS}
EXPORT dune-copasi-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Libraries
NAMELINK_COMPONENT Development
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT Development
)
# add source files to main library # add source files to main library
target_sources(dune-copasi target_sources(dune-copasi PRIVATE dune/copasi/model/base.cc)
PRIVATE
dune/copasi/model/base.cc
)
# set up single-domain executable # set up single-domain executable
add_executable(singledomain-exec EXCLUDE_FROM_ALL dune_copasi_sd.cc) add_executable(singledomain-exec EXCLUDE_FROM_ALL dune_copasi_sd.cc)
target_link_libraries(singledomain-exec PRIVATE dune-copasi) target_link_libraries(singledomain-exec PRIVATE dune-copasi)
set_property(TARGET singledomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-sd)
if(DUNE_COPASI_COMPILE_3D)
target_compile_definitions(singledomain-exec PUBLIC DUNE_COPASI_COMPILE_3D)
endif()
if(DUNE_COPASI_SD_EXECUTABLE) if(DUNE_COPASI_SD_EXECUTABLE)
set_target_properties(singledomain-exec PROPERTIES EXCLUDE_FROM_ALL OFF) set_target_properties(singledomain-exec PROPERTIES EXCLUDE_FROM_ALL OFF)
install(TARGETS singledomain-exec install(TARGETS singledomain-exec
...@@ -15,11 +16,14 @@ if(DUNE_COPASI_SD_EXECUTABLE) ...@@ -15,11 +16,14 @@ if(DUNE_COPASI_SD_EXECUTABLE)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
endif() endif()
set_property(TARGET singledomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-sd)
# set up multi-domain executable # set up multi-domain executable
add_executable(multidomain-exec EXCLUDE_FROM_ALL dune_copasi_md.cc) add_executable(multidomain-exec EXCLUDE_FROM_ALL dune_copasi_md.cc)
target_link_libraries(multidomain-exec PRIVATE dune-copasi) target_link_libraries(multidomain-exec PRIVATE dune-copasi)
set_property(TARGET multidomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-md)
if(DUNE_COPASI_COMPILE_3D)
target_compile_definitions(multidomain-exec PUBLIC DUNE_COPASI_COMPILE_3D)
endif()
if(DUNE_COPASI_MD_EXECUTABLE) if(DUNE_COPASI_MD_EXECUTABLE)
set_target_properties(multidomain-exec PROPERTIES EXCLUDE_FROM_ALL OFF) set_target_properties(multidomain-exec PROPERTIES EXCLUDE_FROM_ALL OFF)
install(TARGETS multidomain-exec install(TARGETS multidomain-exec
...@@ -28,4 +32,4 @@ if(DUNE_COPASI_MD_EXECUTABLE) ...@@ -28,4 +32,4 @@ if(DUNE_COPASI_MD_EXECUTABLE)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
endif() endif()
set_property(TARGET multidomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-md)
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