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.

547 lines
22 KiB

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