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

Clean up cmake config and packaging

parent fba59fb7
No related branches found
No related tags found
1 merge request!49Resolve "Finish installation and usage instruction on the documentation"
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(dune-copasi CXX) project(dune-copasi CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
"${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
string(REPLACE ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR
"${PROJECT_BINARY_DIR}")
endif()
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
#find dune-common and set the module path #find dune-common and set the module path
...@@ -28,7 +22,7 @@ option(DUNE_COPASI_SD_EXECUTABLE ...@@ -28,7 +22,7 @@ option(DUNE_COPASI_SD_EXECUTABLE
"Build SingleDomain executable by default" "Build SingleDomain executable by default"
OFF OFF
) )
option(DUNE_COPASI_SD_LIBRARY option(DUNE_COPASI_SD_LIBRARY
"Include precompiled SingleDomain objects in dune-copasi library (optional)" "Include precompiled SingleDomain objects in dune-copasi library (optional)"
${DUNE_COPASI_SD_EXECUTABLE} ${DUNE_COPASI_SD_EXECUTABLE}
) )
...@@ -42,7 +36,7 @@ option(DUNE_COPASI_MD_LIBRARY ...@@ -42,7 +36,7 @@ option(DUNE_COPASI_MD_LIBRARY
${DUNE_COPASI_MD_EXECUTABLE} ${DUNE_COPASI_MD_EXECUTABLE}
) )
option(DUNE_COPASI_COMPILE_3D option(DUNE_COPASI_COMPILE_3D
"Compile 3D cases in libraries and executables" "Compile 3D cases in libraries and executables"
OFF OFF
) )
...@@ -80,7 +74,6 @@ add_subdirectory(doc) ...@@ -80,7 +74,6 @@ add_subdirectory(doc)
add_subdirectory(cmake/modules) add_subdirectory(cmake/modules)
# finalize the dune project: Generate and install config.h, cmake target and version file # finalize the dune project: Generate and install config.h, cmake target and version file
include(SetupDuneCopasiConfig)
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)
...@@ -129,8 +122,11 @@ export(EXPORT dune-copasi-targets ...@@ -129,8 +122,11 @@ export(EXPORT dune-copasi-targets
NAMESPACE dune-copasi:: NAMESPACE dune-copasi::
) )
# set a read only alias for our main target
add_library(dune::copasi ALIAS dune-copasi)
# include tests as a sub project # include tests as a sub project
add_library(dune-copasi::dune-copasi ALIAS dune-copasi)
add_subdirectory(test) add_subdirectory(test)
# add definitions for packaging
include(SetupDuneCopasiCPack) include(SetupDuneCopasiCPack)
\ No newline at end of file
# 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(DUNE_CUSTOM_PKG_CONFIG_SECTION
"
include(CMakeFindDependencyMacro)
find_dependency(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH \${dune-common_MODULE_PATH} \${dune-copasi_MODULE_PATH})
include(DuneMacros)
include(CheckCXXFeatures)
include(DuneCxaDemangle)
include(DuneMPI)
set(DUNE_PYTHON_VIRTUALENV_SETUP ${DUNE_PYTHON_VIRTUALENV_SETUP})
set(ProjectName dune-copasi)
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)
# get dune-copasi dependencies
find_dependency(muparser)
find_dependency(TIFF)
find_dependency(Filesystem)
if(${USE_FALLBACK_FILESYSTEM})
find_package(ghc_filesystem)
endif()
#import the target
get_filename_component(_dir \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)
include(\"\${_dir}/dune-copasi-targets.cmake\")
")
function(swap_args ARG1 ARG2)
set(_tmp ${ARG1})
set(ARG1 ${ARG2})
set(ARG2 ${_tmp})
unset(_tmp)
endfunction()
if(NOT dune-copasi_FOUND)
# Whether this module is installed or not
set(dune-copasi_INSTALLED @MODULE_INSTALLED@)
# Settings specific to the module
@dune-copasi_INIT@
# Package initialization
@PACKAGE_INIT@
#report other information
set_and_check(dune-copasi_PREFIX "${PACKAGE_PREFIX_DIR}")
set_and_check(dune-copasi_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set(dune-copasi_DEPENDS "@dune-copasi_DEPENDS@")
set(dune-copasi_SUGGESTS "@dune-copasi_SUGGESTS@")
set(dune-copasi_MODULE_PATH "@PACKAGE_DUNE_INSTALL_MODULEDIR@")
set(DUNE_PYTHON_VIRTUALENV_SETUP ${DUNE_PYTHON_VIRTUALENV_SETUP})
include(CMakeFindDependencyMacro)
# setup basic dune dependecy
find_dependency(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH "@dune-common_MODULE_PATH@" "@dune-copasi_MODULE_PATH@")
include(DuneMacros)
# setup other dune dependecies
swap_args(ProjectName _ProjectName)
dune_create_dependency_tree()
dune_process_dependency_macros()
swap_args(ProjectName _ProjectName)
# setup other dependencies
find_dependency(muparser)
find_dependency(TIFF)
find_dependency(Filesystem)
if(@USE_FALLBACK_FILESYSTEM@)
find_package(ghc_filesystem)
endif()
# import targets
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${_dir}/dune-copasi-targets.cmake")
add_library(dune::copasi ALIAS dune-copasi::dune-copasi)
endif()
\ No newline at end of file
...@@ -7,7 +7,7 @@ cmake_dependent_option(BUILD_TESTS ...@@ -7,7 +7,7 @@ cmake_dependent_option(BUILD_TESTS
"Enable tests" OFF "Enable tests" OFF
"CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" ON) "CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" ON)
if(NOT TARGET dune-copasi::dune-copasi) if(NOT TARGET dune::copasi)
find_package(dune-copasi REQUIRED IMPORTED COMPONENTS Libraries Development Runtime) find_package(dune-copasi REQUIRED IMPORTED COMPONENTS Libraries Development Runtime)
endif() endif()
...@@ -42,33 +42,33 @@ dune_symlink_to_source_files(FILES "data" DESTINATION "." ) ...@@ -42,33 +42,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::dune-copasi LINK_LIBRARIES 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::dune-copasi LINK_LIBRARIES 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::dune-copasi LINK_LIBRARIES 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::dune-copasi LINK_LIBRARIES 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::dune-copasi LINK_LIBRARIES 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::dune-copasi) target_link_libraries(dune-copasi-sd-compare PRIVATE 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)
...@@ -107,8 +107,8 @@ endif() ...@@ -107,8 +107,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::dune-copasi) target_link_libraries(dune-copasi-md-compare PRIVATE dune::copasi)
target_link_libraries(dune-copasi-md-jacobian PRIVATE dune-copasi::dune-copasi) target_link_libraries(dune-copasi-md-jacobian PRIVATE 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