From 0260eaa7bebe51cef1700ed721b5a1a02ec41508 Mon Sep 17 00:00:00 2001 From: sjunges Date: Sun, 27 Nov 2016 22:54:46 +0100 Subject: [PATCH] towards exporting targets for storm to be included in other projects --- CMakeLists.txt | 14 ++++++++++++++ resources/3rdparty/CMakeLists.txt | 4 +++- resources/cmake/macros/export.cmake | 26 ++++++++++++++++++++++++++ resources/cmake/stormConfig.cmake.in | 18 ++++++++++++++++++ src/storm/CMakeLists.txt | 1 + 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 resources/cmake/macros/export.cmake create mode 100644 resources/cmake/stormConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index e512bc945..082f0689a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,22 @@ mark_as_advanced(CMAKE_OSX_ARCHITECTURES) mark_as_advanced(CMAKE_OSX_SYSROOT) mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET) +# Offer the user the choice of overriding the installation directories +set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" ) +set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries") +#set(SYSCONFIG_INSTALL_DIR etc/carl/ CACHE PATH "Installation for system configuration files) +set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables") + + # By default, we build a release version. if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RELEASE") endif() +# Install dir for cmake files (info for other libraries that include storm) +set(DEF_INSTALL_CMAKE_DIR "lib/CMake/storm") +set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files") + +message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}") # If the STORM_DEVELOPER option was turned on, we target a debug version. if (STORM_DEVELOPER) @@ -354,4 +366,6 @@ endif() add_subdirectory(src) +include(export) + include(StormCPackConfig.cmake) diff --git a/resources/3rdparty/CMakeLists.txt b/resources/3rdparty/CMakeLists.txt index 8d414ea64..f5195c642 100644 --- a/resources/3rdparty/CMakeLists.txt +++ b/resources/3rdparty/CMakeLists.txt @@ -216,7 +216,7 @@ if(USE_CARL) if(carl_FOUND) set(STORM_HAVE_CARL ON) message(STATUS "Storm - Use system version of carl.") - message(STATUS "Storm - Linking with carl ${carl_VERSION_STRING}.") + message(STATUS "Storm - Linking with carl ${carl_VERSION} (CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}).") include_directories("${carl_INCLUDE_DIR}") list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES}) else() @@ -240,6 +240,8 @@ if(USE_CARL) LOG_BUILD ON BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT} ) + include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake) + message("CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}") add_dependencies(resources carl) set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include") diff --git a/resources/cmake/macros/export.cmake b/resources/cmake/macros/export.cmake new file mode 100644 index 000000000..1a064fe77 --- /dev/null +++ b/resources/cmake/macros/export.cmake @@ -0,0 +1,26 @@ + +# Add all targets to the build-tree export set +export(TARGETS ${STORM_TARGETS} FILE "${PROJECT_BINARY_DIR}/stormTargets.cmake") + +message(STATUS "Registered with cmake") +# Export the package for use from the build-tree +# (this registers the build-tree with a global CMake-registry) +export(PACKAGE storm) + +set(DEP_TARGETS "") + +set(EXP_OPTIONS "") +foreach(option ${EXPORTED_OPTIONS}) + set(EXP_OPTIONS "${EXP_OPTIONS}\nset(${option} \"${${option}}\")") +endforeach() + +include(CMakePackageConfigHelpers) + +set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src") +message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}") +configure_package_config_file( + resources/cmake/stormConfig.cmake.in + ${PROJECT_BINARY_DIR}/stormConfig.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_DIR} + PATH_VARS INCLUDE_INSTALL_DIR #SYSCONFIG_INSTALL_DIR +) diff --git a/resources/cmake/stormConfig.cmake.in b/resources/cmake/stormConfig.cmake.in new file mode 100644 index 000000000..890571311 --- /dev/null +++ b/resources/cmake/stormConfig.cmake.in @@ -0,0 +1,18 @@ +set(storm_VERSION @storm_VERSION@) + + +@DEP_TARGETS@ + +@EXP_OPTIONS@ + +# Our library dependencies (contains definitions for IMPORTED targets) +if(NOT TARGET storm) + include("${PROJECT_BINARY_DIR}/stormTargets.cmake") +endif() + +@PACKAGE_INIT@ + +set(storm_INCLUDE_DIR "@CONF_INCLUDE_DIRS@") + +set(storm_LIBRARIES storm) +check_required_components(storm) diff --git a/src/storm/CMakeLists.txt b/src/storm/CMakeLists.txt index f0d64ab0c..44bac6429 100644 --- a/src/storm/CMakeLists.txt +++ b/src/storm/CMakeLists.txt @@ -40,6 +40,7 @@ add_library(storm SHARED ${STORM_LIB_SOURCES} ${STORM_LIB_HEADERS}) set_target_properties(storm PROPERTIES DEFINE_SYMBOL "") add_dependencies(storm resources) target_link_libraries(storm ${STORM_LINK_LIBRARIES}) +append(STORM_TARGETS storm CACHE STRING INTERNAL FORCE) # Create storm. add_executable(storm-main ${STORM_MAIN_SOURCES} ${STORM_MAIN_HEADERS})