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.

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