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.

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