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

Import cmake module path & prepend DUNE_ to fallback option

parent 3b20c9ba
No related branches found
No related tags found
1 merge request!49Resolve "Finish installation and usage instruction on the documentation"
Pipeline #33621 failed
...@@ -97,7 +97,7 @@ SETUP_dune_common_PATCHES+=" ${PWD}/cmake-patch.txt" ...@@ -97,7 +97,7 @@ SETUP_dune_common_PATCHES+=" ${PWD}/cmake-patch.txt"
# hardcoded **ordered** dependencies # hardcoded **ordered** dependencies
MODULES="common logging uggrid geometry grid localfunctions istl typetree functions pdelab multidomaingrid" MODULES="common logging uggrid geometry grid localfunctions istl typetree functions pdelab multidomaingrid"
if [[ "$SETUP_DUNE_TESTTOOLS" =~ ^(ON|on|1|yes|true|TRUE)$ ]]; then if [[ "$SETUP_DUNE_TESTTOOLS" =~ ^(ON|on|1|yes|YES|true|TRUE)$ ]]; then
MODULES+=" testtools" MODULES+=" testtools"
fi fi
...@@ -201,11 +201,11 @@ for module in $MODULES; do ...@@ -201,11 +201,11 @@ for module in $MODULES; do
# configure, build, and install module # configure, build, and install module
$DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module all $DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module all
$SUDOCMD $DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module bexec cmake --build . --target install $SUDOCMD $DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module bexec cmake --build . --target install
# we want to know where the build dir is located # we want to know where the build dir is located
# since it could be ant complex path, we write the path from dunecontrol into a file # since it could be ant complex path, we write the path from dunecontrol into a file
$DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module bexec "echo \$PWD > /tmp/setup-dune/module_builddir" $DUNECONTROL --opts=${DUNE_OPTIONS_FILE} --only=dune-$module bexec "echo \$PWD > /tmp/setup-dune/module_builddir"
# remove build and sources # remove build and sources
BUILD_PATH=$(cat /tmp/setup-dune/module_builddir) BUILD_PATH=$(cat /tmp/setup-dune/module_builddir)
rm -rf $BUILD_PATH rm -rf $BUILD_PATH
......
...@@ -27,7 +27,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" ...@@ -27,7 +27,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
onfailure() { onfailure() {
FAILURE_TYPE="$?" FAILURE_TYPE="$?"
# do not exit this function even on case of failures # do not exit this function even on case of failures
set +e set +e
......
...@@ -7,10 +7,8 @@ jobs: ...@@ -7,10 +7,8 @@ jobs:
name: Linux name: Linux
runs-on: ubuntu-16.04 runs-on: ubuntu-16.04
env: env:
CMAKE_INSTALL_PREFIX: '/opt/smelibs' CMAKE_INSTALL_PREFIX: '/opt/dune'
DUNE_COPASI_USE_STATIC_DEPS: 'ON' DUNE_COPASI_USE_STATIC_DEPS: 'ON'
USE_FALLBACK_FILESYSTEM: 'OFF'
BUILD_TESTING: 'ON'
TERM: 'xterm-256color' TERM: 'xterm-256color'
defaults: defaults:
run: run:
...@@ -38,10 +36,8 @@ jobs: ...@@ -38,10 +36,8 @@ jobs:
name: MacOS name: MacOS
runs-on: macos-10.15 runs-on: macos-10.15
env: env:
CMAKE_INSTALL_PREFIX: '/opt/smelibs' CMAKE_INSTALL_PREFIX: '/opt/dune'
DUNE_COPASI_USE_STATIC_DEPS: 'ON' DUNE_COPASI_USE_STATIC_DEPS: 'ON'
USE_FALLBACK_FILESYSTEM: 'ON'
BUILD_TESTING: 'ON'
MACOSX_DEPLOYMENT_TARGET: '10.14' MACOSX_DEPLOYMENT_TARGET: '10.14'
TERM: 'xterm-256color' TERM: 'xterm-256color'
defaults: defaults:
...@@ -65,11 +61,8 @@ jobs: ...@@ -65,11 +61,8 @@ jobs:
name: Windows 64-bit name: Windows 64-bit
runs-on: windows-2019 runs-on: windows-2019
env: env:
CMAKE_INSTALL_PREFIX: '/c/smelibs' CMAKE_INSTALL_PREFIX: '/c/dune'
DUNE_COPASI_USE_STATIC_DEPS: 'ON' DUNE_COPASI_USE_STATIC_DEPS: 'ON'
USE_FALLBACK_FILESYSTEM: 'OFF'
BUILD_TESTING: 'ON'
CMAKE_BUILD_TYPE: Release
defaults: defaults:
run: run:
shell: msys2 {0} shell: msys2 {0}
...@@ -96,11 +89,8 @@ jobs: ...@@ -96,11 +89,8 @@ jobs:
name: Windows 32-bit name: Windows 32-bit
runs-on: windows-2019 runs-on: windows-2019
env: env:
CMAKE_INSTALL_PREFIX: '/c/smelibs' CMAKE_INSTALL_PREFIX: '/c/dune'
DUNE_COPASI_USE_STATIC_DEPS: 'ON' DUNE_COPASI_USE_STATIC_DEPS: 'ON'
USE_FALLBACK_FILESYSTEM: 'OFF'
BUILD_TESTING: 'ON'
CMAKE_BUILD_TYPE: Release
defaults: defaults:
run: run:
shell: msys2 {0} shell: msys2 {0}
......
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(dune-copasi CXX) project(dune-copasi CXX)
include(GNUInstallDirs)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
if(POLICY CMP0087) if(POLICY CMP0087)
cmake_policy(SET CMP0087 OLD) cmake_policy(SET CMP0087 OLD)
...@@ -28,9 +30,6 @@ option(DUNE_COPASI_COMPILE_3D ...@@ -28,9 +30,6 @@ option(DUNE_COPASI_COMPILE_3D
OFF OFF
) )
# make sure to find our own cmake modules
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
# find dune dependencies # find dune dependencies
find_package(dune-common REQUIRED) find_package(dune-common REQUIRED)
...@@ -41,23 +40,26 @@ include(DuneMacros) ...@@ -41,23 +40,26 @@ include(DuneMacros)
# start a dune project with information from dune.module, and find dune dependencies # start a dune project with information from dune.module, and find dune dependencies
dune_project() dune_project()
# make sure to find and install our own cmake modules
add_subdirectory(cmake/modules)
# find specific dune-copasi dependencies # find specific dune-copasi dependencies
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, otherwise, optional # if standard C++ filesystem is not found, using a fallback is mandatory
include(CMakeDependentOption) include(CMakeDependentOption)
cmake_dependent_option(USE_FALLBACK_FILESYSTEM cmake_dependent_option(DUNE_USE_FALLBACK_FILESYSTEM
"Use bundled std::filesystem alternative (enable this for macOS older than 10.15)" OFF "Use bundled std::filesystem alternative (enable this for macOS older than 10.15)" OFF
"Filesystem_FOUND" ON "Filesystem_FOUND" ON
) )
if(USE_FALLBACK_FILESYSTEM) if(DUNE_USE_FALLBACK_FILESYSTEM)
# let's use ghc_filesystem # let's use ghc_filesystem
find_package(ghc_filesystem) find_package(ghc_filesystem)
# ... library not installed, we provide a fallback # ... library not installed, we provide it from git
if (NOT ghc_filesystem_FOUND) if (NOT ghc_filesystem_FOUND)
include(FetchContent) include(FetchContent)
message("-- Declaring GHC Filesystem") message("-- Declaring GHC Filesystem")
...@@ -96,8 +98,8 @@ add_subdirectory(doc) ...@@ -96,8 +98,8 @@ add_subdirectory(doc)
finalize_dune_project(GENERATE_CONFIG_H_CMAKE) finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
target_compile_definitions(dune-copasi INTERFACE HAVE_DUNE_COPASI_CONFIG_H) target_compile_definitions(dune-copasi INTERFACE HAVE_DUNE_COPASI_CONFIG_H)
# main library is completely set up, define a read only 'dune::' alias for our main target # main library is completely set up, define a read only alias for our main target
add_library(dune::copasi ALIAS dune-copasi) add_library(dune-copasi::dune-copasi ALIAS dune-copasi)
# install generated config in build and install directories # install generated config in build and install directories
file(COPY "${CMAKE_CURRENT_BINARY_DIR}/config.h" file(COPY "${CMAKE_CURRENT_BINARY_DIR}/config.h"
......
...@@ -9,7 +9,6 @@ FROM ${SETUP_BASE_IMAGE} AS setup-env ...@@ -9,7 +9,6 @@ FROM ${SETUP_BASE_IMAGE} AS setup-env
ARG TOOLCHAIN=clang-6-17 ARG TOOLCHAIN=clang-6-17
ENV DUNE_OPTIONS_FILE=/duneci/dune.opts
ENV PATH=/duneci/install/bin:$PATH ENV PATH=/duneci/install/bin:$PATH
ENV TERM=xterm-256color ENV TERM=xterm-256color
ENV CMAKE_INSTALL_PREFIX=/duneci/install ENV CMAKE_INSTALL_PREFIX=/duneci/install
...@@ -21,7 +20,6 @@ COPY --chown=duneci ./.ci /duneci/modules/dune-copasi/.ci ...@@ -21,7 +20,6 @@ COPY --chown=duneci ./.ci /duneci/modules/dune-copasi/.ci
RUN ln -s /duneci/toolchains/${TOOLCHAIN} /duneci/toolchain \ RUN ln -s /duneci/toolchains/${TOOLCHAIN} /duneci/toolchain \
&& export PATH=/duneci/install/bin:$PATH && export PATH=/duneci/install/bin:$PATH
RUN echo 'CMAKE_FLAGS+=" -DDUNE_COPASI_SD_EXECUTABLE=ON"' >> /duneci/cmake-flags/dune-copasi.opts
WORKDIR /duneci/modules WORKDIR /duneci/modules
RUN mkdir -p /duneci/modules/dune-copasi/.ci RUN mkdir -p /duneci/modules/dune-copasi/.ci
RUN ./dune-copasi/.ci/setup_dune /duneci/dune.opts RUN ./dune-copasi/.ci/setup_dune /duneci/dune.opts
...@@ -29,7 +27,6 @@ RUN ./dune-copasi/.ci/setup_dune /duneci/dune.opts ...@@ -29,7 +27,6 @@ RUN ./dune-copasi/.ci/setup_dune /duneci/dune.opts
# build and install dune-copasi from the setup-env # build and install dune-copasi from the setup-env
FROM ${BUILD_BASE_IMAGE} AS build-env FROM ${BUILD_BASE_IMAGE} AS build-env
ENV DUNE_OPTIONS_FILE=/duneci/dune.opts
ENV PATH=/duneci/install/bin:$PATH ENV PATH=/duneci/install/bin:$PATH
ENV TERM=xterm-256color ENV TERM=xterm-256color
ENV CMAKE_INSTALL_PREFIX=/duneci/install ENV CMAKE_INSTALL_PREFIX=/duneci/install
......
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
install(FILES install(FILES
FindFilesystem.cmake FindFilesystem.cmake
Findmuparser.cmake Findmuparser.cmake
DESTINATION ${DUNE_INSTALL_MODULEDIR}) DESTINATION ${DUNE_INSTALL_MODULEDIR})
\ No newline at end of file
...@@ -68,7 +68,4 @@ if(NOT dune-copasi_FOUND) ...@@ -68,7 +68,4 @@ if(NOT dune-copasi_FOUND)
# import targets # import targets
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_dir}/dune-copasi-targets.cmake") include("${_dir}/dune-copasi-targets.cmake")
# export short alias
add_library(dune::copasi ALIAS dune-copasi::dune-copasi)
endif() endif()
\ No newline at end of file
#ifndef DUNE_COPASI_FILESYSTEM_HH #ifndef DUNE_COPASI_FILESYSTEM_HH
#define DUNE_COPASI_FILESYSTEM_HH #define DUNE_COPASI_FILESYSTEM_HH
#ifdef DUNE_COPASI_USE_FALLBACK_FILESYSTEM #ifdef DUNE_USE_FALLBACK_FILESYSTEM
#include <ghc/filesystem.hpp> #include <ghc/filesystem.hpp>
namespace fs { namespace fs {
......
include(GNUInstallDirs)
# add dune dependencies to main target # add dune dependencies to main target
dune_target_enable_all_packages(dune-copasi) dune_target_enable_all_packages(dune-copasi)
...@@ -14,7 +12,7 @@ endif() ...@@ -14,7 +12,7 @@ endif()
if(USE_FALLBACK_FILESYSTEM) if(USE_FALLBACK_FILESYSTEM)
# and add ghc_filesystem to our filesystem target # and add ghc_filesystem to our filesystem target
target_link_libraries(dune-copasi PUBLIC ghcFilesystem::ghc_filesystem) target_link_libraries(dune-copasi PUBLIC ghcFilesystem::ghc_filesystem)
target_compile_definitions(dune-copasi PUBLIC DUNE_COPASI_USE_FALLBACK_FILESYSTEM) target_compile_definitions(dune-copasi PUBLIC DUNE_USE_FALLBACK_FILESYSTEM)
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(dune-copasi PUBLIC std::filesystem) target_link_libraries(dune-copasi PUBLIC std::filesystem)
......
include(GNUInstallDirs)
# add source files to main library # add source files to main library
target_sources(dune-copasi target_sources(dune-copasi
PRIVATE PRIVATE
......
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(dune-copasi-tests CXX) project(dune-copasi-tests CXX)
if(NOT TARGET dune::copasi) if(NOT TARGET dune-copasi::dune-copasi)
find_package(dune-copasi REQUIRED IMPORTED COMPONENTS Libraries Development Runtime) find_package(dune-copasi REQUIRED IMPORTED COMPONENTS Libraries Development Runtime)
endif() endif()
...@@ -36,33 +36,33 @@ dune_symlink_to_source_files(FILES "data" DESTINATION "." ) ...@@ -36,33 +36,33 @@ dune_symlink_to_source_files(FILES "data" DESTINATION "." )
dune_add_test(NAME test_dynamic_power_local_finite_element dune_add_test(NAME test_dynamic_power_local_finite_element
SOURCES test_dynamic_power_local_finite_element.cc SOURCES test_dynamic_power_local_finite_element.cc
LINK_LIBRARIES dune::copasi LINK_LIBRARIES dune-copasi::dune-copasi
LABELS unit) LABELS unit)
dune_add_test(NAME test_concepts_pdelab dune_add_test(NAME test_concepts_pdelab
SOURCES test_concepts_pdelab.cc SOURCES test_concepts_pdelab.cc
LINK_LIBRARIES dune::copasi LINK_LIBRARIES dune-copasi::dune-copasi
LABELS unit) LABELS unit)
dune_add_test(NAME test_concepts_grid dune_add_test(NAME test_concepts_grid
SOURCES test_concepts_grid.cc SOURCES test_concepts_grid.cc
LINK_LIBRARIES dune::copasi LINK_LIBRARIES dune-copasi::dune-copasi
LABELS unit) LABELS unit)
dune_add_test(NAME test_concepts_typetree dune_add_test(NAME test_concepts_typetree
SOURCES test_concepts_typetree.cc SOURCES test_concepts_typetree.cc
LINK_LIBRARIES dune::copasi LINK_LIBRARIES dune-copasi::dune-copasi
LABELS unit) LABELS unit)
dune_add_test(NAME test_tiff_grayscale dune_add_test(NAME test_tiff_grayscale
SOURCES test_tiff_grayscale.cc SOURCES test_tiff_grayscale.cc
LINK_LIBRARIES dune::copasi LINK_LIBRARIES dune-copasi::dune-copasi
LABELS unit) LABELS unit)
# # SingleDomain tests # # SingleDomain tests
add_executable(dune-copasi-sd-compare EXCLUDE_FROM_ALL dune_copasi_sd_compare.cc) add_executable(dune-copasi-sd-compare EXCLUDE_FROM_ALL dune_copasi_sd_compare.cc)
target_link_libraries(dune-copasi-sd-compare PRIVATE dune::copasi) target_link_libraries(dune-copasi-sd-compare PRIVATE dune-copasi::dune-copasi)
add_custom_target(build_system_tests) add_custom_target(build_system_tests)
add_dependencies(build_system_tests dune-copasi-sd-compare) add_dependencies(build_system_tests dune-copasi-sd-compare)
...@@ -101,8 +101,8 @@ endif() ...@@ -101,8 +101,8 @@ endif()
add_executable(dune-copasi-md-compare EXCLUDE_FROM_ALL dune_copasi_md_compare.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) add_executable(dune-copasi-md-jacobian EXCLUDE_FROM_ALL test_jacobian.cc)
target_link_libraries(dune-copasi-md-compare PRIVATE dune::copasi) target_link_libraries(dune-copasi-md-compare PRIVATE dune-copasi::dune-copasi)
target_link_libraries(dune-copasi-md-jacobian PRIVATE dune::copasi) target_link_libraries(dune-copasi-md-jacobian PRIVATE dune-copasi::dune-copasi)
add_dependencies(build_system_tests add_dependencies(build_system_tests
dune-copasi-md-compare dune-copasi-md-compare
......
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