diff --git a/CMakeLists.txt b/CMakeLists.txt index 082f0689a..4e395e25d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmak include(ExternalProject) include(RegisterSourceGroup) +include(imported) + ############################################################# ## diff --git a/resources/3rdparty/CMakeLists.txt b/resources/3rdparty/CMakeLists.txt index f5195c642..ce8b8da34 100644 --- a/resources/3rdparty/CMakeLists.txt +++ b/resources/3rdparty/CMakeLists.txt @@ -95,7 +95,8 @@ set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}") # Use the shipped version of ExprTK message (STATUS "Storm - Including ExprTk.") -include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk") +add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk") +list(APPEND STORM_LINK_LIBRARIES ExprTk) ############################################################# ## @@ -124,7 +125,8 @@ list(APPEND STORM_RESOURCES_HEADERS "${CMAKE_BINARY_DIR}/include/resources/3rdpa #use the shipped version of modernjson message (STATUS "Storm - Including ModernJSON.") -include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/") +add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/") +list(APPEND STORM_LINK_LIBRARIES ModernJSON) ############################################################# ## @@ -218,7 +220,7 @@ if(USE_CARL) message(STATUS "Storm - Use system version of carl.") 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}) + list(APPEND STORM_LINK_LIBRARIES lib_carl) else() message(STATUS "Storm - Using shipped version of carl.") set(CARL_BUILD_COMMAND make lib_carl) @@ -295,26 +297,6 @@ endif() -############################################################# -## -## GiNaC -## -############################################################# - -find_package(GiNaC QUIET) - -if(GINAC_FOUND) - set(STORM_HAVE_GINAC ON) - message(STATUS "Storm - Linking with GiNaC ${GINAC_VERSION_STRING}.") - # Right now only link with GiNaC for carl - #include_directories("${GINAC_INCLUDE_DIR}") - list(APPEND STORM_LINK_LIBRARIES ${GINAC_LIBRARIES}) -else() - set(STORM_HAVE_GINAC OFF) - #TODO: Check if CARL actually requires the use of GiNaC -endif() - - ############################################################# ## ## gmp diff --git a/resources/cmake/macros/export.cmake b/resources/cmake/macros/export.cmake index 1a064fe77..ea977b70c 100644 --- a/resources/cmake/macros/export.cmake +++ b/resources/cmake/macros/export.cmake @@ -16,7 +16,7 @@ endforeach() include(CMakePackageConfigHelpers) -set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src") +set(CONF_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/include/") message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}") configure_package_config_file( resources/cmake/stormConfig.cmake.in diff --git a/resources/cmake/macros/imported.cmake b/resources/cmake/macros/imported.cmake new file mode 100644 index 000000000..305d589f9 --- /dev/null +++ b/resources/cmake/macros/imported.cmake @@ -0,0 +1,59 @@ +# copied from CARL + + +macro(add_imported_library_interface name include) + add_library(${name} INTERFACE IMPORTED) + set_target_properties(${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}") +endmacro(add_imported_library_interface) + +macro(add_imported_library name type lib include) + # Workaround from https://cmake.org/Bug/view.php?id=15052 + file(MAKE_DIRECTORY "${include}") + if("${lib}" STREQUAL "") + if("${type}" STREQUAL "SHARED") + add_library(${name} INTERFACE IMPORTED) + set_target_properties(${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}") + endif() + else() + add_library(${name}_${type} ${type} IMPORTED) + set_target_properties(${name}_${type} PROPERTIES IMPORTED_LOCATION "${lib}") + set_target_properties(${name}_${type} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}") + endif() +endmacro(add_imported_library) + +macro(export_option name) + list(APPEND EXPORTED_OPTIONS "${name}") +endmacro(export_option) + +macro(export_target output TARGET) + get_target_property(TYPE ${TARGET} TYPE) + if(TYPE STREQUAL "SHARED_LIBRARY") + get_target_property(LOCATION ${TARGET} IMPORTED_LOCATION) + get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) + set(${output} "${${output}} +add_library(${TARGET} SHARED IMPORTED) +set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION \"${LOCATION}\") +set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\") +") + elseif(TYPE STREQUAL "STATIC_LIBRARY") + get_target_property(LOCATION ${TARGET} IMPORTED_LOCATION) + get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) + set(${output} "${${output}} +add_library(${TARGET} STATIC IMPORTED) +set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION \"${LOCATION}\") +set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\") +") + if(NOT "${ARGN}" STREQUAL "") + set(${output} "${${output}}set_target_properties(${TARGET} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES \"${ARGN}\") +") + endif() + elseif(TYPE STREQUAL "INTERFACE_LIBRARY") + get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) + set(${output} "${${output}} +add_library(${TARGET} INTERFACE IMPORTED) +set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\") +") + else() + message(STATUS "Unknown type ${TYPE}") + endif() +endmacro(export_target)