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.

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