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

Use GHC 1.5.0

parent 81d3a49c
No related branches found
No related tags found
1 merge request!49Resolve "Finish installation and usage instruction on the documentation"
...@@ -15,11 +15,6 @@ list(APPEND CMAKE_MODULE_PATH ...@@ -15,11 +15,6 @@ list(APPEND CMAKE_MODULE_PATH
# include macros for dune projects # include macros for dune projects
include(DuneMacros) include(DuneMacros)
option(USE_FALLBACK_FILESYSTEM
"Use bundled std::filesystem alternative (enable this for macOS older than 10.15)"
OFF
)
option(DUNE_COPASI_SD_EXECUTABLE option(DUNE_COPASI_SD_EXECUTABLE
"Build SingleDomain executable by default" "Build SingleDomain executable by default"
OFF OFF
...@@ -47,8 +42,34 @@ option(DUNE_COPASI_COMPILE_3D ...@@ -47,8 +42,34 @@ option(DUNE_COPASI_COMPILE_3D
find_package(muparser REQUIRED) find_package(muparser REQUIRED)
find_package(TIFF REQUIRED) find_package(TIFF REQUIRED)
find_package(Filesystem) find_package(Filesystem)
# if Filesystem is not found, using a fallback is mandatory
include(CMakeDependentOption)
cmake_dependent_option(USE_FALLBACK_FILESYSTEM
"Use bundled std::filesystem alternative (enable this for macOS older than 10.15)" OFF
"Filesystem_FOUND" ON
)
if(USE_FALLBACK_FILESYSTEM) if(USE_FALLBACK_FILESYSTEM)
# let's use ghc_filesystem
find_package(ghc_filesystem) find_package(ghc_filesystem)
# ... library not installed, we provide a fallback
if (NOT ghc_filesystem_FOUND)
include(FetchContent)
message("-- Declaring GHC Filesystem")
FetchContent_Declare(
ghc_filesystem
GIT_REPOSITORY https://github.com/gulrak/filesystem
GIT_TAG v1.5.0
)
if(NOT ghc_filesystem_POPULATED)
message("-- Populating GHC Filesystem")
FetchContent_Populate(ghc_filesystem)
add_subdirectory("${ghc_filesystem_SOURCE_DIR}" "${ghc_filesystem_BINARY_DIR}")
endif()
endif()
endif() endif()
# start a dune project with information from dune.module # start a dune project with information from dune.module
...@@ -123,7 +144,7 @@ export(EXPORT dune-copasi-targets ...@@ -123,7 +144,7 @@ export(EXPORT dune-copasi-targets
NAMESPACE dune-copasi:: NAMESPACE dune-copasi::
) )
# set a read only alias for our main target # library is set up, define a read only 'dune::' alias for our main target
add_library(dune::copasi ALIAS dune-copasi) add_library(dune::copasi ALIAS dune-copasi)
# include tests as a sub project # include tests as a sub project
......
...@@ -48,56 +48,16 @@ if(DUNE_COPASI_MD_LIBRARY) ...@@ -48,56 +48,16 @@ if(DUNE_COPASI_MD_LIBRARY)
list(APPEND EXPORTED_DEVELOPMENT_TARGETS multidomain-lib) list(APPEND EXPORTED_DEVELOPMENT_TARGETS multidomain-lib)
endif() endif()
# Set up filesystem # Set up filesystem. Where do we get it from?
add_library(filesystem INTERFACE) if(USE_FALLBACK_FILESYSTEM)
list(APPEND EXPORTED_DEVELOPMENT_TARGETS filesystem) # and add ghc_filesystem to our filesystem target
target_link_libraries(dune-copasi PUBLIC ghcFilesystem::ghc_filesystem)
# where do we get it from? target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_USE_FALLBACK_FILESYSTEM)
if(USE_FALLBACK_FILESYSTEM AND ghc_filesystem_FOUND)
# ... easy, link to the fallback directly
target_link_libraries(filesystem INTERFACE ghcFilesystem::ghc_filesystem)
elseif(USE_FALLBACK_FILESYSTEM)
# ... library not installed, we provide a fallback
include(FetchContent)
message("-- Declaring GHC Filesystem")
FetchContent_Declare(
ghc_filesystem
GIT_REPOSITORY https://github.com/gulrak/filesystem
GIT_TAG v1.4.0
)
if(NOT ghc_filesystem_POPULATED)
message("-- Populating GHC Filesystem")
FetchContent_Populate(ghc_filesystem)
add_subdirectory("${ghc_filesystem_SOURCE_DIR}" "${ghc_filesystem_BINARY_DIR}")
file(GLOB GHC_HEADERS "${ghc_filesystem_SOURCE_DIR}/include/ghc/*.hpp")
install(FILES ${GHC_HEADERS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/ghc"
)
endif()
target_include_directories(filesystem INTERFACE
$<BUILD_INTERFACE:${ghc_filesystem_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(filesystem INTERFACE DUNE_COPASI_USE_FALLBACK_FILESYSTEM)
elseif(NOT Filesystem_FOUND)
# ... heuston we have a problem. It makes no sense to continue!
message(FATAL_ERROR
"Support for C++ 17 filesystem was not found. Try setting up a "
"fallback implementation by adding the flag USE_FALLBACK_FILESYSTEM=ON")
else() else()
# ... else we don't need a back up. Link agaist standard library # ... else we don't need a back up. Link agaist standard library
target_link_libraries(filesystem INTERFACE std::filesystem) target_link_libraries(dune-copasi PUBLIC std::filesystem)
endif() endif()
# main library consumes filesystem definitions
target_link_libraries(dune-copasi PUBLIC filesystem)
# install development targets # install development targets
install(TARGETS ${EXPORTED_DEVELOPMENT_TARGETS} install(TARGETS ${EXPORTED_DEVELOPMENT_TARGETS}
EXPORT dune-copasi-targets EXPORT dune-copasi-targets
......
...@@ -19,7 +19,6 @@ endif() ...@@ -19,7 +19,6 @@ endif()
set_property(TARGET singledomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-sd) set_property(TARGET singledomain-exec PROPERTY RUNTIME_OUTPUT_NAME dune-copasi-sd)
# MultiDomain executable # MultiDomain executable
add_executable(multidomain-exec EXCLUDE_FROM_ALL "${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md.cc") add_executable(multidomain-exec EXCLUDE_FROM_ALL "${CMAKE_CURRENT_SOURCE_DIR}/dune_copasi_md.cc")
target_link_libraries(multidomain-exec PRIVATE dune-copasi) target_link_libraries(multidomain-exec PRIVATE dune-copasi)
if(DUNE_COPASI_MD_EXECUTABLE) if(DUNE_COPASI_MD_EXECUTABLE)
......
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