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.

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