From cbd525b40b55c4d4ea0285851fce4a679eb9bafb Mon Sep 17 00:00:00 2001 From: dehnert Date: Fri, 18 Nov 2016 15:52:16 +0100 Subject: [PATCH] Cmake adaptions here and there --- CMakeLists.txt | 8 ++--- resources/3rdparty/include_cpptemplate.cmake | 1 - resources/3rdparty/include_xerces.cmake | 29 ++++++++++--------- .../cmake/macros/RegisterSourceGroup.cmake | 1 - src/storm/CMakeLists.txt | 21 ++++++++++---- src/storm/utility/storm-version.h | 13 ++++----- storm-version.cpp.in | 9 ++++-- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93e7d62a9..d439782d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,8 @@ set(CUDA_ROOT "" CACHE STRING "The hint to the root directory of CUDA (optional) set(MSAT_ROOT "" CACHE STRING "The hint to the root directory of MathSAT (optional).") set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.") set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.") -set(USE_XERCES ${XML_SUPPORT}) -mark_as_advanced(USE_XERCES) +set(USE_XERCESC ${XML_SUPPORT}) +mark_as_advanced(USE_XERCESC) # Set some CMAKE Variables as advanced mark_as_advanced(CMAKE_OSX_ARCHITECTURES) @@ -146,7 +146,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CLANG ON) set(STORM_COMPILER_ID "clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - # using GCC + # using AppleClang if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3) message(FATAL_ERROR "AppleClang version must be at least 7.3.") endif() @@ -333,7 +333,7 @@ configure_file ( "${PROJECT_BINARY_DIR}/include/storm-config.h" ) -# Configure a header file to pass the storm version to the source code +# Configure a source file to pass the storm version to the source code configure_file ( "${PROJECT_SOURCE_DIR}/storm-version.cpp.in" "${PROJECT_SOURCE_DIR}/src/storm/utility/storm-version.cpp" diff --git a/resources/3rdparty/include_cpptemplate.cmake b/resources/3rdparty/include_cpptemplate.cmake index 5492523b5..51426e755 100644 --- a/resources/3rdparty/include_cpptemplate.cmake +++ b/resources/3rdparty/include_cpptemplate.cmake @@ -12,7 +12,6 @@ ExternalProject_Add( PREFIX ${STORM_3RDPARTY_BINARY_DIR}/cpptemplate CONFIGURE_COMMAND "" BUILD_COMMAND ${CMAKE_CXX_COMPILER} -c ${CMAKE_CXX_FLAGS_AS_LIST} ${CMAKE_CXX_FLAGS_RELEASE_AS_LIST} -fPIC -I${Boost_INCLUDE_DIRS} ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp -o ${CPPTEMPLATE_LIB_DIR}/cpptemplate${STATIC_EXT} - BUILD_ALWAYS 1 INSTALL_COMMAND "" BUILD_IN_SOURCE 0 LOG_BUILD ON diff --git a/resources/3rdparty/include_xerces.cmake b/resources/3rdparty/include_xerces.cmake index 565f8e414..4db0dff57 100644 --- a/resources/3rdparty/include_xerces.cmake +++ b/resources/3rdparty/include_xerces.cmake @@ -1,31 +1,32 @@ -if(USE_XERCES) +if(USE_XERCESC) + set(XERCESC_FIND_QUIETLY ON) find_package(Xerces QUIET REQUIRED) - if(XERCES_FOUND) + if(XERCESC_FOUND) message(STATUS "Storm - Use system version of xerces.") else() message(STATUS "Storm - Use shipped version of xerces.") - set(XERCES_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2/lib) + set(XERCESC_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2/lib) ExternalProject_Add( xercesc SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2 - CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 --libdir=${XERCES_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=-O3 CXXFLAGS=-O3 + CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/xercesc-3.1.2/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 --libdir=${XERCESC_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} CFLAGS=-O3 CXXFLAGS=-O3 PREFIX ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2 BUILD_COMMAND make BUILD_IN_SOURCE 0 LOG_CONFIGURE ON LOG_BUILD ON LOG_INSTALL ON - BUILD_BYPRODUCTS ${XERCES_LIB_DIR}/libxerces-c${DYNAMIC_EXT} ${XERCES_LIB_DIR}/libxerces-c${STATIC_EXT} + BUILD_BYPRODUCTS ${XERCESC_LIB_DIR}/libxerces-c${DYNAMIC_EXT} ${XERCESC_LIB_DIR}/libxerces-c${STATIC_EXT} ) - set(XERCES_ROOT ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2) - set(XERCESC_INCLUDE ${XERCES_ROOT}/include) - set(XERCES_LIBRARY_PATH ${XERCES_LIB_DIR}) + set(XERCESC_ROOT ${STORM_3RDPARTY_BINARY_DIR}/xercesc-3.1.2) + set(XERCESC_INCLUDE ${XERCESC_ROOT}/include) + set(XERCESC_LIBRARY_PATH ${XERCESC_LIB_DIR}) if(BUILD_STATIC) - set(XERCESC_LIBRARIES ${XERCES_LIBRARY_PATH}/libxerces-c${STATIC_EXT}) + set(XERCESC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${STATIC_EXT}) else() - set(XERCESC_LIBRARIES ${XERCES_LIBRARY_PATH}/libxerces-c${DYNAMIC_EXT}) + set(XERCESC_LIBRARIES ${XERCESC_LIBRARY_PATH}/libxerces-c${DYNAMIC_EXT}) endif() add_dependencies(resources xercesc) @@ -37,11 +38,11 @@ if(USE_XERCES) if(APPLE) FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation ) FIND_LIBRARY(CORESERVICES_LIBRARY CoreServices ) - mark_as_advanced(COREFOUNDATION_LIBRARY) - mark_as_advanced(CORESERVICES_LIBRARY) + mark_as_advanced(COREFOUNDATION_LIBRARY) + mark_as_advanced(CORESERVICES_LIBRARY) endif() find_package(CURL) list(APPEND STORM_LINK_LIBRARIES ${XERCESC_LIBRARIES} ${COREFOUNDATION_LIBRARY} ${CORESERVICES_LIBRARY} ${CURL_LIBRARIES}) else() - message (WARNING "StoRM - Building without Xerces disables parsing XML formats (for GSPNs)") -endif(USE_XERCES) + message (WARNING "Storm - Building without Xerces disables parsing XML formats (for GSPNs)") +endif(USE_XERCESC) diff --git a/resources/cmake/macros/RegisterSourceGroup.cmake b/resources/cmake/macros/RegisterSourceGroup.cmake index 592395293..c36a9a3eb 100644 --- a/resources/cmake/macros/RegisterSourceGroup.cmake +++ b/resources/cmake/macros/RegisterSourceGroup.cmake @@ -9,7 +9,6 @@ macro(register_source_groups_from_filestructure list_of_files remove_prefix) #string(REGEX REPLACE "/storm?/" "" GROUP ${GROUP}) #STRING(SUBSTRING "${GROUP}" 1 -1 GROUP) string(REPLACE "/" "\\" GROUP "${GROUP}") - message(${GROUP}: ${FILE}) # group into "Source Files" and "Header Files" # if ("${FILE}" MATCHES ".*\\.cpp") diff --git a/src/storm/CMakeLists.txt b/src/storm/CMakeLists.txt index 091595619..9062e60ce 100644 --- a/src/storm/CMakeLists.txt +++ b/src/storm/CMakeLists.txt @@ -59,8 +59,19 @@ add_executable(storm-gspn-main ${STORM_GSPN_MAIN_SOURCES} ${STORM_MAIN_HEADERS}) target_link_libraries(storm-gspn-main storm) # Adding headers for xcode set_target_properties(storm-gspn-main PROPERTIES OUTPUT_NAME "storm-gspn") -INSTALL(TARGETS storm-main - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib -) +# Install headers to include directory. +foreach(HEADER ${STORM_LIB_HEADERS}) + string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER}) + string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH}) + string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH}) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME} + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY} + COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME} + DEPENDS ${HEADER} + ) + list(APPEND STORM_OUTPUT_HEADERS "${CMAKE_BINARY_DIR}/include/${RELATIVE_DIRECTORY}${HEADER_FILENAME}") +endforeach() +add_custom_target(copy_headers DEPENDS ${STORM_OUTPUT_HEADERS} ${STORM_LIB_HEADERS}) +add_dependencies(storm copy_headers) + diff --git a/src/storm/utility/storm-version.h b/src/storm/utility/storm-version.h index 025b680cd..1cfaca76b 100644 --- a/src/storm/utility/storm-version.h +++ b/src/storm/utility/storm-version.h @@ -32,12 +32,12 @@ namespace storm /// The system version which has compiled Storm. const static std::string systemVersion; - /// The build type that was used to build Storm. - const static std::string buildType; - /// The compiler version that was used to build Storm. const static std::string cxxCompiler; - + + /// The flags that were used to build Storm. + const static std::string cxxFlags; + static std::string shortVersionString() { std::stringstream sstream; sstream << "Storm " << versionMajor << "." << versionMinor << "." << versionPatch; @@ -46,7 +46,7 @@ namespace storm static std::string longVersionString() { std::stringstream sstream; - sstream << "Version: " << versionMajor << "." << versionMinor << "." << versionPatch; + sstream << "version: " << versionMajor << "." << versionMinor << "." << versionPatch; if (commitsAhead != 0) { sstream << " (+" << commitsAhead << " commits)"; } @@ -60,8 +60,7 @@ namespace storm static std::string buildInfo() { std::stringstream sstream; - sstream << "Compiled on " << systemName << " " << systemVersion << ","; - sstream << "using " << cxxCompiler << " with " << buildType << " flags."; + sstream << "Compiled on " << systemName << " " << systemVersion << " using " << cxxCompiler << " with flags '" << cxxFlags << "'"; return sstream.str(); } }; diff --git a/storm-version.cpp.in b/storm-version.cpp.in index 51215787d..71625a18d 100644 --- a/storm-version.cpp.in +++ b/storm-version.cpp.in @@ -13,8 +13,11 @@ namespace storm { const unsigned StormVersion::dirty = @STORM_CPP_VERSION_DIRTY@; const std::string StormVersion::systemName = "@CMAKE_SYSTEM_NAME@"; const std::string StormVersion::systemVersion = "@CMAKE_SYSTEM_VERSION@"; - const std::string StormVersion::buildType = "@CMAKE_BUILD_TYPE@"; - const std::string StormVersion::cxxCompiler = "@STORM_COMPILED_BY@ @CMAKE_CXX_COMPILER_VERSION@"; - + const std::string StormVersion::cxxCompiler = "@STORM_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"; +#ifdef NDEBUG + const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_RELEASE@"; +#else + const std::string StormVersion::cxxFlags = "@CMAKE_CXX_FLAGS@" " " "@CMAKE_CXX_FLAGS_DEBUG@"; +#endif } }