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.

505 lines
19 KiB

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