You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

524 lines
21 KiB

  1. cmake_minimum_required (VERSION 3.2)
  2. cmake_policy(VERSION 3.2)
  3. # When searching for packages, we would like to first search in prefixes specified by <PackageName>_ROOT.
  4. # However, this behavior is only supported since CMake 3.12.
  5. if(POLICY CMP0074)
  6. cmake_policy(SET CMP0074 NEW)
  7. endif()
  8. # Set project name
  9. project (storm CXX C)
  10. # Add base folder for better inclusion paths
  11. include_directories("${PROJECT_SOURCE_DIR}/src")
  12. include_directories("${PROJECT_SOURCE_DIR}/src/storm")
  13. # Add the resources/cmake folder to Module Search Path for FindTBB.cmake
  14. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmake/find_modules" "${PROJECT_SOURCE_DIR}/resources/cmake/macros")
  15. include(ExternalProject)
  16. include(RegisterSourceGroup)
  17. include(imported)
  18. include(CheckCXXSourceCompiles)
  19. include(CheckCSourceCompiles)
  20. #############################################################
  21. ##
  22. ## CMake options of Storm
  23. ##
  24. #############################################################
  25. option(STORM_DEVELOPER "Sets whether the development mode is used." OFF)
  26. option(STORM_ALLWARNINGS "Compile with even more warnings" OFF)
  27. option(STORM_USE_LTO "Sets whether link-time optimizations are enabled." ON)
  28. MARK_AS_ADVANCED(STORM_USE_LTO)
  29. option(STORM_USE_THIN_LTO "Sets whether thin link-time optimizations are enabled (faster compile times than normal LTO)." OFF)
  30. MARK_AS_ADVANCED(STORM_USE_THIN_LTO)
  31. option(STORM_PORTABLE "Sets whether a build needs to be portable." OFF)
  32. MARK_AS_ADVANCED(STORM_PORTABLE)
  33. # Force POPCNT is helpful for portable code targetting platforms with SSE4.2 operation support.
  34. option(STORM_FORCE_POPCNT "Sets whether the popcnt instruction is forced to be used (advanced)." OFF)
  35. MARK_AS_ADVANCED(STORM_FORCE_POPCNT)
  36. option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." OFF)
  37. option(STORM_USE_INTELTBB "Sets whether the Intel TBB libraries should be used." OFF)
  38. option(STORM_USE_GUROBI "Sets whether Gurobi should be used." OFF)
  39. set(STORM_CARL_DIR_HINT "" CACHE STRING "A hint where the preferred CArL version can be found. If CArL cannot be found there, it is searched in the OS's default paths.")
  40. option(STORM_FORCE_SHIPPED_CARL "Sets whether the shipped version of carl is to be used no matter whether carl is found or not." OFF)
  41. MARK_AS_ADVANCED(STORM_FORCE_SHIPPED_CARL)
  42. option(USE_SMTRAT "Sets whether SMT-RAT should be included." OFF)
  43. option(USE_HYPRO "Sets whether HyPro should be included." OFF)
  44. option(XML_SUPPORT "Sets whether xml based format parsing should be included." ON)
  45. option(FORCE_COLOR "Force color output" OFF)
  46. mark_as_advanced(FORCE_COLOR)
  47. option(STORM_COMPILE_WITH_CCACHE "Compile using CCache [if found]" ON)
  48. mark_as_advanced(STORM_COMPILE_WITH_CCACHE)
  49. option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF)
  50. option(STORM_USE_CLN_EA "Sets whether CLN instead of GMP numbers should be used for exact arithmetic." OFF)
  51. export_option(STORM_USE_CLN_EA)
  52. option(STORM_USE_CLN_RF "Sets whether CLN instead of GMP numbers should be used for rational functions." ON)
  53. export_option(STORM_USE_CLN_RF)
  54. option(BUILD_SHARED_LIBS "Build the Storm library dynamically" OFF)
  55. option(STORM_DEBUG_CUDD "Build CUDD in debug mode." OFF)
  56. MARK_AS_ADVANCED(STORM_DEBUG_CUDD)
  57. option(STORM_EXCLUDE_TESTS_FROM_ALL "If set, tests will not be compiled by default" OFF )
  58. export_option(STORM_EXCLUDE_TESTS_FROM_ALL)
  59. MARK_AS_ADVANCED(STORM_EXCLUDE_TESTS_FROM_ALL)
  60. set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).")
  61. set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).")
  62. set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).")
  63. set(CUDA_ROOT "" CACHE STRING "The hint to the root directory of CUDA (optional).")
  64. set(MSAT_ROOT "" CACHE STRING "The hint to the root directory of MathSAT (optional).")
  65. option(STORM_LOAD_QVBS "Sets whether the Quantitative Verification Benchmark Set (QVBS) should be downloaded." OFF)
  66. set(STORM_QVBS_ROOT "" CACHE STRING "The root directory of the Quantitative Verification Benchmark Set (QVBS) in case it should not be downloaded (optional).")
  67. MARK_AS_ADVANCED(STORM_QVBS_ROOT)
  68. set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.")
  69. set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.")
  70. set(USE_XERCESC ${XML_SUPPORT})
  71. mark_as_advanced(USE_XERCESC)
  72. # Set some CMAKE Variables as advanced
  73. mark_as_advanced(CMAKE_OSX_ARCHITECTURES)
  74. mark_as_advanced(CMAKE_OSX_SYSROOT)
  75. mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET)
  76. # Offer the user the choice of overriding the installation directories
  77. set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" )
  78. set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries")
  79. #set(SYSCONFIG_INSTALL_DIR etc/carl/ CACHE PATH "Installation for system configuration files)
  80. set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables")
  81. # Install dir for cmake files (info for other libraries that include Storm)
  82. set(DEF_INSTALL_CMAKE_DIR "lib/CMake/storm")
  83. set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
  84. # Add CMake install prefix
  85. foreach(p LIB BIN INCLUDE CMAKE)
  86. set(var ${p}_INSTALL_DIR)
  87. if(NOT IS_ABSOLUTE "${${var}}")
  88. set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
  89. endif()
  90. endforeach()
  91. message(STATUS "Storm - CMake install dir: ${CMAKE_INSTALL_DIR}")
  92. # If the STORM_DEVELOPER option was turned on, by default we target a debug version, otherwise a release version.
  93. if (STORM_DEVELOPER)
  94. if (NOT CMAKE_BUILD_TYPE)
  95. set(CMAKE_BUILD_TYPE "DEBUG")
  96. endif()
  97. add_definitions(-DSTORM_DEV)
  98. else()
  99. set(STORM_LOG_DISABLE_DEBUG ON)
  100. if (NOT CMAKE_BUILD_TYPE)
  101. set(CMAKE_BUILD_TYPE "RELEASE")
  102. endif()
  103. endif()
  104. message(STATUS "Storm - Building ${CMAKE_BUILD_TYPE} version.")
  105. if(STORM_COMPILE_WITH_CCACHE)
  106. find_program(CCACHE_FOUND ccache)
  107. mark_as_advanced(CCACHE_FOUND)
  108. if(CCACHE_FOUND)
  109. message(STATUS "Storm - Using ccache")
  110. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  111. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  112. else()
  113. message(STATUS "Storm - Could not find ccache.")
  114. endif()
  115. else()
  116. message(STATUS "Storm - Disabled use of ccache.")
  117. endif()
  118. # Directory for test resources.
  119. set(STORM_TEST_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/resources/examples/testfiles")
  120. # Auto-detect operating system.
  121. set(MACOSX 0)
  122. set(LINUX 0)
  123. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  124. # Mac OS
  125. set(OPERATING_SYSTEM "Mac OS")
  126. set(MACOSX 1)
  127. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  128. # Linux
  129. set(OPERATING_SYSTEM "Linux")
  130. set(LINUX 1)
  131. elseif(WIN32)
  132. # Assuming Windows.
  133. set(OPERATING_SYSTEM "Windows")
  134. else()
  135. message(WARNING "We are unsure about your operating system.")
  136. set(OPERATING_SYSTEM "Linux")
  137. set(LINUX 1)
  138. ENDIF()
  139. message(STATUS "Storm - Detected operating system ${OPERATING_SYSTEM}.")
  140. set(DYNAMIC_EXT ".so")
  141. set(STATIC_EXT ".a")
  142. set(LIB_PREFIX "lib")
  143. if(MACOSX)
  144. set(DYNAMIC_EXT ".dylib")
  145. set(STATIC_EXT ".a")
  146. set(LIB_PREFIX "lib")
  147. elseif (WIN32)
  148. set(DYNAMIC_EXT ".dll")
  149. set(STATIC_EXT ".lib")
  150. set(LIB_PREFIX "")
  151. endif()
  152. message(STATUS "Storm - Assuming extension for shared libraries: ${DYNAMIC_EXT}")
  153. message(STATUS "Storm - Assuming extension for static libraries: ${STATIC_EXT}")
  154. if(BUILD_SHARED_LIBS)
  155. set(LIB_EXT ${DYNAMIC_EXT})
  156. message(STATUS "Storm - Build dynamic libraries.")
  157. else()
  158. set(LIB_EXT ${STATIC_EXT})
  159. message(STATUS "Storm - Build static libraries.")
  160. endif()
  161. #############################################################
  162. ##
  163. ## Compiler detection and initial configuration
  164. ##
  165. #############################################################
  166. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  167. # using Clang
  168. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
  169. message(FATAL_ERROR "Clang version must be at least 3.2.")
  170. endif()
  171. set(STORM_COMPILER_CLANG ON)
  172. set(CLANG ON)
  173. set(STORM_COMPILER_ID "clang")
  174. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
  175. # using AppleClang
  176. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
  177. message(FATAL_ERROR "AppleClang version must be at least 7.3.")
  178. elseif ((CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 11.0.0) OR (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0.0))
  179. message(WARNING "Disabling stack checks for AppleClang version 11.0.0 or higher.")
  180. # Stack checks are known to produce errors with the following Clang versions:
  181. # 11.0.0: Runtime errors (stack_not_16_byte_aligned_error) when invoking storm in release mode
  182. # 11.0.3 and 12.0.0: Catching exceptions thrown within PRISM parser does not work (The exception just falls through)
  183. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-check")
  184. endif()
  185. set(STORM_COMPILER_APPLECLANG ON)
  186. set(CLANG ON)
  187. set(STORM_COMPILER_ID "AppleClang")
  188. set(CMAKE_MACOSX_RPATH ON)
  189. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  190. set(GCC ON)
  191. # using GCC
  192. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  193. message(FATAL_ERROR "gcc version must be at least 5.0.")
  194. endif()
  195. set(STORM_COMPILER_GCC ON)
  196. set(STORM_COMPILER_ID "gcc")
  197. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
  198. message(FATAL_ERROR "Intel compiler is currently not supported.")
  199. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  200. message(FATAL_ERROR "Visual Studio compiler is currently not supported.")
  201. endif()
  202. set(STORM_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
  203. if(CCACHE_FOUND)
  204. set(STORM_COMPILER_ID "${STORM_COMPILER_ID} (ccache)")
  205. endif()
  206. #############################################################
  207. ##
  208. ## Compiler independent settings
  209. ##
  210. #############################################################
  211. if (STORM_FORCE_POPCNT)
  212. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  213. endif()
  214. # TODO: remove forcing the old version of optional as soon as the related Spirit bug is fixed:
  215. # https://svn.boost.org/trac/boost/ticket/12349
  216. # Fix thanks to: https://github.com/freeorion/freeorion/issues/777
  217. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL)
  218. #############################################################
  219. ##
  220. ## Compiler specific settings
  221. ##
  222. #############################################################
  223. if (STORM_COMPILER_CLANG OR STORM_COMPILER_APPLECLANG)
  224. if(FORCE_COLOR)
  225. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  226. endif()
  227. if (LINUX)
  228. set(CLANG_STDLIB libstdc++)
  229. else()
  230. set(CLANG_STDLIB libc++)
  231. endif()
  232. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -ftemplate-depth=1024")
  233. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
  234. if(LINUX)
  235. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  236. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
  237. elseif(MACOSX)
  238. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic")
  239. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-export_dynamic")
  240. endif()
  241. elseif (STORM_COMPILER_GCC)
  242. if(FORCE_COLOR)
  243. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
  244. endif()
  245. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  246. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprefetch-loop-arrays")
  247. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  248. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
  249. endif ()
  250. if (STORM_USE_THIN_LTO)
  251. if (STORM_COMPILER_CLANG OR STORM_COMPILER_APPLECLANG)
  252. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=thin")
  253. message(STATUS "Storm - Enabling link-time optimizations using ThinLTO.")
  254. else()
  255. message(FATAL_ERROR "Storm - ThinLTO only supported for Clang. Use regular LTO instead.")
  256. endif()
  257. elseif (STORM_USE_LTO)
  258. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
  259. # Fix for problems that occurred when using LTO on gcc. This should be removed when it
  260. # is not needed anymore as it makes the already long link-step potentially longer.
  261. if (STORM_COMPILER_GCC)
  262. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto-partition=none")
  263. endif()
  264. message(STATUS "Storm - Enabling link-time optimizations.")
  265. else()
  266. message(STATUS "Storm - Disabling link-time optimizations.")
  267. endif()
  268. # In release mode, we turn on even more optimizations if we do not have to provide a portable binary.
  269. if (NOT STORM_PORTABLE)
  270. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
  271. endif ()
  272. if (STORM_DEVELOPER)
  273. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  274. if (STORM_ALLWARNINGS)
  275. if (CLANG)
  276. # Enable strictly every warning and then disable selected ones.
  277. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
  278. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic")
  279. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
  280. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-id-macro")
  281. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-newline-eof")
  282. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation")
  283. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables")
  284. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
  285. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
  286. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
  287. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default")
  288. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded")
  289. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal")
  290. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef")
  291. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-variable-declarations")
  292. endif ()
  293. else ()
  294. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
  295. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
  296. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
  297. endif ()
  298. else()
  299. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
  300. endif()
  301. # Test compiler by compiling small program.
  302. CHECK_C_SOURCE_COMPILES("
  303. #include <stdio.h>
  304. int main() {
  305. const char* text = \"A Storm is coming.\";
  306. return 0;
  307. }"
  308. COMPILER_C_WORKS
  309. )
  310. CHECK_CXX_SOURCE_COMPILES("
  311. #include <string>
  312. int main() {
  313. const std::string text = \"A Storm is coming.\";
  314. return 0;
  315. }"
  316. COMPILER_CXX_WORKS
  317. )
  318. if ((NOT COMPILER_CXX_WORKS) OR (NOT COMPILER_C_WORKS))
  319. if (MACOSX)
  320. message(FATAL_ERROR "The C/C++ compiler is not configured correctly.\nTry running 'xcode-select --install'.")
  321. else()
  322. message(FATAL_ERROR "The C/C++ compiler is not configured correctly.")
  323. endif()
  324. endif()
  325. #############################################################
  326. ##
  327. ## RPATH settings
  328. ##
  329. #############################################################
  330. # don't skip the full RPATH for the build tree
  331. SET(CMAKE_SKIP_BUILD_RPATH FALSE)
  332. # when building, don't use the install RPATH already (but only when installing)
  333. SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  334. # the RPATH to be used when installing
  335. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  336. # don't add the automatically determined parts of the RPATH
  337. # which point to directories outside the build tree to the install RPATH
  338. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  339. #############################################################
  340. ##
  341. ## Generator specific settings
  342. ##
  343. #############################################################
  344. if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
  345. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
  346. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  347. endif()
  348. # Display information about build configuration.
  349. message(STATUS "Storm - Using compiler configuration ${STORM_COMPILER_ID} ${STORM_COMPILER_VERSION}.")
  350. if (STORM_DEVELOPER)
  351. message(STATUS "Storm - CXX Flags: ${CMAKE_CXX_FLAGS}")
  352. message(STATUS "Storm - CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
  353. message(STATUS "Storm - CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
  354. message(STATUS "Storm - Build type: ${CMAKE_BUILD_TYPE}")
  355. endif()
  356. #############################################################
  357. #############################################################
  358. ##
  359. ## Inclusion of required libraries
  360. ##
  361. #############################################################
  362. #############################################################
  363. #############################################################
  364. ##
  365. ## Include the targets for non-system resources
  366. ##
  367. #############################################################
  368. # In 3rdparty, targets are being defined that can be used
  369. # in the the system does not have a library
  370. include(resources/3rdparty/CMakeLists.txt)
  371. # Include Doxygen
  372. include(resources/doxygen/CMakeLists.txt)
  373. #############################################################
  374. ##
  375. ## CMake-generated Config File for Storm
  376. ##
  377. #############################################################
  378. # try to obtain the current version from git.
  379. include(GetGitRevisionDescription)
  380. get_git_head_revision(STORM_VERSION_REFSPEC STORM_VERSION_GIT_HASH)
  381. git_describe(STORM_GIT_VERSION_STRING)
  382. # parse the git tag into variables
  383. # start with major.minor.patch
  384. string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" STORM_VERSION_MATCH "${STORM_GIT_VERSION_STRING}")
  385. set(STORM_VERSION_MAJOR "${CMAKE_MATCH_1}")
  386. set(STORM_VERSION_MINOR "${CMAKE_MATCH_2}")
  387. set(STORM_VERSION_PATCH "${CMAKE_MATCH_3}")
  388. set(STORM_GIT_VERSION_REST "${CMAKE_MATCH_4}")
  389. # parse rest of the form (-label)-commitsahead-hash(-appendix)
  390. string(REGEX MATCH "^(\\-([a-z][a-z0-9\\.]+))?\\-([0-9]+)\\-([a-z0-9]+)(\\-.*)?$" STORM_VERSION_REST_MATCH "${STORM_GIT_VERSION_REST}")
  391. set(STORM_VERSION_LABEL "${CMAKE_MATCH_2}") # might be empty
  392. set(STORM_VERSION_COMMITS_AHEAD "${CMAKE_MATCH_3}")
  393. set(STORM_VERSION_TAG_HASH "${CMAKE_MATCH_4}") # is not used
  394. set(STORM_VERSION_APPENDIX "${CMAKE_MATCH_5}") # might be empty
  395. # check whether the git version lookup failed
  396. if (STORM_GIT_VERSION_STRING MATCHES "NOTFOUND")
  397. set(STORM_VERSION_SOURCE "VersionSource::Static")
  398. set(STORM_VERSION_COMMITS_AHEAD 0)
  399. set(STORM_VERSION_DIRTY DirtyState::Unknown)
  400. include(version.cmake)
  401. message(WARNING "Storm - Git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.")
  402. else()
  403. set(STORM_VERSION_SOURCE "VersionSource::Git")
  404. if ("${STORM_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  405. set(STORM_VERSION_DIRTY "DirtyState::Dirty")
  406. else()
  407. set(STORM_VERSION_DIRTY "DirtyState::Clean")
  408. endif()
  409. endif()
  410. # check whether there is a label ('alpha', 'pre', etc.)
  411. if ("${STORM_VERSION_LABEL}" STREQUAL "")
  412. set(STORM_VERSION_LABEL_STRING "")
  413. else()
  414. set(STORM_VERSION_LABEL_STRING "-${STORM_VERSION_LABEL}")
  415. endif()
  416. # check for development version with commits ahead of latest tag
  417. if(STORM_VERSION_COMMITS_AHEAD)
  418. set(STORM_VERSION_DEV "true")
  419. set(STORM_VERSION_DEV_STRING " (dev)")
  420. if ("${STORM_VERSION_LABEL}" STREQUAL "")
  421. # increase patch number to indicate newer version
  422. MATH(EXPR STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}+1")
  423. else()
  424. set(STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}")
  425. endif()
  426. else()
  427. set(STORM_VERSION_COMMITS_AHEAD 0)
  428. set(STORM_VERSION_DEV "false")
  429. set(STORM_VERSION_DEV_STRING "")
  430. set(STORM_VERSION_DEV_PATCH ${STORM_VERSION_PATCH})
  431. endif()
  432. # set final Storm version
  433. set(STORM_VERSION "${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_DEV_PATCH}")
  434. set(STORM_VERSION_STRING "${STORM_VERSION}${STORM_VERSION_LABEL_STRING}${STORM_VERSION_DEV_STRING}")
  435. message(STATUS "Storm - Version is ${STORM_VERSION_STRING} (version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}${STORM_VERSION_LABEL_STRING} + ${STORM_VERSION_COMMITS_AHEAD} commits), building from git: ${STORM_VERSION_GIT_HASH} (dirty: ${STORM_VERSION_DIRTY}).")
  436. # Configure a header file to pass some of the CMake settings to the source code
  437. configure_file (
  438. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  439. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  440. )
  441. # Add the binary dir include directory for storm-config.h
  442. include_directories("${PROJECT_BINARY_DIR}/include")
  443. include(CTest)
  444. # Compiles all tests
  445. add_custom_target(tests)
  446. # Compiles and runs all tests
  447. add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
  448. set(CMAKE_CTEST_COMMAND_VERBOSE ${CMAKE_CTEST_COMMAND} -V)
  449. add_custom_target(check-verbose COMMAND ${CMAKE_CTEST_COMMAND_VERBOSE})
  450. add_dependencies(check tests)
  451. add_dependencies(check-verbose tests)
  452. set(STORM_TARGETS "")
  453. add_subdirectory(src)
  454. export_option(STORM_HAVE_XERCES)
  455. include(export)
  456. install(FILES ${CMAKE_BINARY_DIR}/stormConfig.install.cmake DESTINATION ${CMAKE_INSTALL_DIR} RENAME stormConfig.cmake)
  457. install(FILES ${CMAKE_BINARY_DIR}/stormConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_DIR})
  458. install(EXPORT storm_Targets FILE stormTargets.cmake DESTINATION ${CMAKE_INSTALL_DIR})
  459. include(StormCPackConfig.cmake)