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.

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