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.

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