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.

499 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. # using GCC
  165. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  166. message(FATAL_ERROR "gcc version must be at least 5.0.")
  167. endif()
  168. set(STORM_COMPILER_GCC ON)
  169. set(STORM_COMPILER_ID "gcc")
  170. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
  171. message(FATAL_ERROR "Intel compiler is currently not supported.")
  172. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  173. message(FATAL_ERROR "Visual Studio compiler is currently not supported.")
  174. endif()
  175. set(STORM_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
  176. if(CCACHE_FOUND)
  177. set(STORM_COMPILER_ID "${STORM_COMPILER_ID} (ccache)")
  178. endif()
  179. #############################################################
  180. ##
  181. ## Compiler independent settings
  182. ##
  183. #############################################################
  184. if (STORM_FORCE_POPCNT)
  185. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  186. endif()
  187. # TODO: remove forcing the old version of optional as soon as the related Spirit bug is fixed:
  188. # https://svn.boost.org/trac/boost/ticket/12349
  189. # Fix thanks to: https://github.com/freeorion/freeorion/issues/777
  190. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE -DBOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL)
  191. #############################################################
  192. ##
  193. ## Compiler specific settings
  194. ##
  195. #############################################################
  196. if (STORM_COMPILER_CLANG OR STORM_COMPILER_APPLECLANG)
  197. if(FORCE_COLOR)
  198. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  199. endif()
  200. if (LINUX)
  201. set(CLANG_STDLIB libstdc++)
  202. else()
  203. set(CLANG_STDLIB libc++)
  204. endif()
  205. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -ftemplate-depth=1024")
  206. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -fno-finite-math-only")
  207. if(LINUX)
  208. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  209. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
  210. elseif(MACOSX)
  211. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export_dynamic")
  212. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-export_dynamic")
  213. endif()
  214. elseif (STORM_COMPILER_GCC)
  215. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  216. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fprefetch-loop-arrays -ffast-math -fno-finite-math-only")
  217. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
  218. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
  219. endif ()
  220. if (STORM_USE_LTO)
  221. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto")
  222. # Fix for problems that occurred when using LTO on gcc. This should be removed when it
  223. # is not needed anymore as it makes the the already long link-step potentially longer.
  224. if (STORM_COMPILER_GCC)
  225. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto-partition=none")
  226. endif()
  227. message(STATUS "Storm - Enabling link-time optimizations.")
  228. else()
  229. message(STATUS "Storm - Disabling link-time optimizations.")
  230. endif()
  231. # In release mode, we turn on even more optimizations if we do not have to provide a portable binary.
  232. if (NOT STORM_PORTABLE)
  233. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
  234. endif ()
  235. if (STORM_DEVELOPER)
  236. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  237. if (STORM_ALLWARNINGS)
  238. if (CLANG)
  239. # Enable strictly every warning and then disable selected ones.
  240. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
  241. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic")
  242. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
  243. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-id-macro")
  244. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-newline-eof")
  245. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation")
  246. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables")
  247. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
  248. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
  249. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
  250. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default")
  251. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded")
  252. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal")
  253. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef")
  254. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-variable-declarations")
  255. endif ()
  256. else ()
  257. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
  258. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
  259. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
  260. endif ()
  261. else()
  262. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
  263. endif()
  264. # Test compiler by compiling small program.
  265. CHECK_C_SOURCE_COMPILES("
  266. #include <stdio.h>
  267. int main() {
  268. const char* text = \"A Storm is coming.\";
  269. return 0;
  270. }"
  271. COMPILER_C_WORKS
  272. )
  273. CHECK_CXX_SOURCE_COMPILES("
  274. #include <string>
  275. int main() {
  276. const std::string text = \"A Storm is coming.\";
  277. return 0;
  278. }"
  279. COMPILER_CXX_WORKS
  280. )
  281. if ((NOT COMPILER_CXX_WORKS) OR (NOT COMPILER_C_WORKS))
  282. if (MACOSX)
  283. message(FATAL_ERROR "The C/C++ compiler is not configured correctly.\nTry running 'xcode-select --install'.")
  284. else()
  285. message(FATAL_ERROR "The C/C++ compiler is not configured correctly.")
  286. endif()
  287. endif()
  288. #############################################################
  289. ##
  290. ## RPATH settings
  291. ##
  292. #############################################################
  293. # don't skip the full RPATH for the build tree
  294. SET(CMAKE_SKIP_BUILD_RPATH FALSE)
  295. # when building, don't use the install RPATH already (but only when installing)
  296. SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  297. # the RPATH to be used when installing
  298. SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
  299. # don't add the automatically determined parts of the RPATH
  300. # which point to directories outside the build tree to the install RPATH
  301. SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  302. #############################################################
  303. ##
  304. ## Generator specific settings
  305. ##
  306. #############################################################
  307. if ("${CMAKE_GENERATOR}" STREQUAL "Xcode")
  308. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
  309. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  310. endif()
  311. # Display information about build configuration.
  312. message(STATUS "Storm - Using compiler configuration ${STORM_COMPILER_ID} ${STORM_COMPILER_VERSION}.")
  313. if (STORM_DEVELOPER)
  314. message(STATUS "Storm - CXX Flags: ${CMAKE_CXX_FLAGS}")
  315. message(STATUS "Storm - CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
  316. message(STATUS "Storm - CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
  317. message(STATUS "Storm - Build type: ${CMAKE_BUILD_TYPE}")
  318. endif()
  319. #############################################################
  320. #############################################################
  321. ##
  322. ## Inclusion of required libraries
  323. ##
  324. #############################################################
  325. #############################################################
  326. #############################################################
  327. ##
  328. ## Include the targets for non-system resources
  329. ##
  330. #############################################################
  331. # In 3rdparty, targets are being defined that can be used
  332. # in the the system does not have a library
  333. include(resources/3rdparty/CMakeLists.txt)
  334. #############################################################
  335. ##
  336. ## Doxygen
  337. ##
  338. #############################################################
  339. find_package(Doxygen)
  340. # Add a target to generate API documentation with Doxygen
  341. if(DOXYGEN_FOUND)
  342. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  343. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  344. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/resources/doxygen/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  345. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  346. endif(DOXYGEN_FOUND)
  347. #############################################################
  348. ##
  349. ## CMake-generated Config File for Storm
  350. ##
  351. #############################################################
  352. # try to obtain the current version from git.
  353. include(GetGitRevisionDescription)
  354. get_git_head_revision(STORM_VERSION_REFSPEC STORM_VERSION_GIT_HASH)
  355. git_describe_checkout(STORM_GIT_VERSION_STRING)
  356. # parse the git tag into variables
  357. # start with major.minor.patch
  358. string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)$" STORM_VERSION_MATCH "${STORM_GIT_VERSION_STRING}")
  359. set(STORM_VERSION_MAJOR "${CMAKE_MATCH_1}")
  360. set(STORM_VERSION_MINOR "${CMAKE_MATCH_2}")
  361. set(STORM_VERSION_PATCH "${CMAKE_MATCH_3}")
  362. set(STORM_GIT_VERSION_REST "${CMAKE_MATCH_4}")
  363. # parse rest of the form (-label)-commitsahead-hash-appendix
  364. string(REGEX MATCH "^(\\-([a-z][a-z0-9\\.]+))?\\-([0-9]+)\\-([a-z0-9]+)(\\-.*)?$" STORM_VERSION_REST_MATCH "${STORM_GIT_VERSION_REST}")
  365. set(STORM_VERSION_LABEL "${CMAKE_MATCH_2}") # might be empty
  366. set(STORM_VERSION_COMMITS_AHEAD "${CMAKE_MATCH_3}")
  367. set(STORM_VERSION_TAG_HASH "${CMAKE_MATCH_4}")
  368. set(STORM_VERSION_APPENDIX "${CMAKE_MATCH_5}") # might be empty
  369. # now check whether the git version lookup failed
  370. if (STORM_VERSION_MAJOR MATCHES "NOTFOUND")
  371. include(version.cmake)
  372. set(STORM_VERSION_LABEL "")
  373. set(STORM_VERSION_COMMITS_AHEAD 0)
  374. set(STORM_VERSION_GIT_HASH "")
  375. set(STORM_VERSION_DIRTY boost::none)
  376. message(WARNING "Storm - git version information not available, statically assuming version ${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_PATCH}.")
  377. else()
  378. if ("${STORM_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  379. set(STORM_VERSION_DIRTY "true")
  380. else()
  381. set(STORM_VERSION_DIRTY "false")
  382. endif()
  383. endif()
  384. # check whether there is a label ('alpha', 'pre', etc.)
  385. if ("${STORM_VERSION_LABEL}" STREQUAL "")
  386. set(STORM_VERSION_LABEL_STRING "")
  387. else()
  388. set(STORM_VERSION_LABEL_STRING "-${STORM_VERSION_LABEL}")
  389. endif()
  390. # check for development version with commits ahead of latest tag
  391. set(STORM_VERSION_DEV "false")
  392. set(STORM_VERSION_DEV_STRING "")
  393. if(STORM_VERSION_COMMITS_AHEAD)
  394. if ("${STORM_VERSION_LABEL}" STREQUAL "")
  395. # increase patch number to indicate newer version
  396. MATH(EXPR STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}+1")
  397. else()
  398. set(STORM_VERSION_DEV_PATCH "${STORM_VERSION_PATCH}")
  399. endif()
  400. set(STORM_VERSION_DEV "true")
  401. set(STORM_VERSION_DEV_STRING " (dev)")
  402. else()
  403. set(STORM_VERSION_DEV_PATCH ${STORM_VERSION_PATCH})
  404. endif()
  405. # set final Storm version
  406. set(STORM_VERSION "${STORM_VERSION_MAJOR}.${STORM_VERSION_MINOR}.${STORM_VERSION_DEV_PATCH}")
  407. set(STORM_VERSION_STRING "${STORM_VERSION}${STORM_VERSION_LABEL_STRING}${STORM_VERSION_DEV_STRING}")
  408. 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}).")
  409. # Configure a header file to pass some of the CMake settings to the source code
  410. configure_file (
  411. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  412. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  413. )
  414. # Configure a source file to pass the Storm version to the source code
  415. configure_file (
  416. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  417. "${PROJECT_SOURCE_DIR}/src/storm/utility/storm-version.cpp"
  418. )
  419. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/storm/utility/storm-version.cpp")
  420. # Add the binary dir include directory for storm-config.h
  421. include_directories("${PROJECT_BINARY_DIR}/include")
  422. include(CTest)
  423. # Compiles all tests
  424. add_custom_target(tests)
  425. # Compiles and runs all tests
  426. add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
  427. set(CMAKE_CTEST_COMMAND_VERBOSE ${CMAKE_CTEST_COMMAND} -V)
  428. add_custom_target(check-verbose COMMAND ${CMAKE_CTEST_COMMAND_VERBOSE})
  429. add_dependencies(check tests)
  430. add_dependencies(check-verbose tests)
  431. set(STORM_TARGETS "")
  432. add_subdirectory(src)
  433. include(export)
  434. include(StormCPackConfig.cmake)