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.

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