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.

807 lines
31 KiB

  1. add_custom_target(resources)
  2. add_custom_target(test-resources)
  3. set(STORM_3RDPARTY_SOURCE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty)
  4. set(STORM_3RDPARTY_BINARY_DIR ${PROJECT_BINARY_DIR}/resources/3rdparty)
  5. set(STORM_3RDPARTY_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include/resources/3rdparty)
  6. #############################################################
  7. ##
  8. ## l3pp
  9. ##
  10. #############################################################
  11. # Do not take a branch, needs internet connection.
  12. ExternalProject_Add(
  13. l3pp_ext
  14. GIT_REPOSITORY https://github.com/hbruintjes/l3pp.git
  15. GIT_TAG e4f8d7fe6c328849aff34d2dfd6fd592c14070d5
  16. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/l3pp
  17. UPDATE_COMMAND ""
  18. CONFIGURE_COMMAND ""
  19. BUILD_COMMAND ""
  20. INSTALL_COMMAND ""
  21. LOG_INSTALL ON
  22. )
  23. ExternalProject_Get_Property(l3pp_ext source_dir)
  24. set(l3pp_INCLUDE "${source_dir}/")
  25. add_imported_library_interface(l3pp "${l3pp_INCLUDE}")
  26. list(APPEND STORM_DEP_TARGETS l3pp)
  27. add_dependencies(l3pp l3pp_ext)
  28. #############################################################
  29. ##
  30. ## gmm
  31. ##
  32. #############################################################
  33. add_imported_library_interface(gmm "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.2/include")
  34. list(APPEND STORM_DEP_TARGETS gmm)
  35. #############################################################
  36. ##
  37. ## Eigen
  38. ##
  39. #############################################################
  40. # Checkout Eigen version 3.3.7
  41. message (STATUS "Storm - Including Eigen 3.3.7.")
  42. ExternalProject_Add(
  43. eigen_src
  44. GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
  45. GIT_SHALLOW 1
  46. GIT_TAG 21ae2afd4edaa1b69782c67a54182d34efe43f9c
  47. SOURCE_DIR ${STORM_3RDPARTY_INCLUDE_DIR}/StormEigen
  48. PREFIX ${STORM_3RDPARTY_BINARY_DIR}/StormEigen-3.3.7
  49. PATCH_COMMAND git apply ${STORM_3RDPARTY_SOURCE_DIR}/patches/eigen.patch
  50. UPDATE_COMMAND ""
  51. CONFIGURE_COMMAND ""
  52. BUILD_COMMAND ""
  53. INSTALL_COMMAND ""
  54. LOG_INSTALL ON
  55. )
  56. add_imported_library_interface(StormEigen "${STORM_3RDPARTY_INCLUDE_DIR}/StormEigen")
  57. list(APPEND STORM_DEP_TARGETS StormEigen)
  58. add_dependencies(StormEigen eigen_src)
  59. #############################################################
  60. ##
  61. ## Boost
  62. ##
  63. #############################################################
  64. # Boost Option variables
  65. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  66. set(Boost_USE_MULTITHREADED ON)
  67. set(Boost_USE_STATIC_RUNTIME OFF)
  68. set(Boost_NO_BOOST_CMAKE ON)
  69. find_package(Boost 1.61.0 QUIET REQUIRED COMPONENTS filesystem system)
  70. if (NOT Boost_FOUND)
  71. if (Boost_VERSION)
  72. message(FATAL_ERROR "The required Boost version is 1.61.0 or newer, however, only ${Boost_VERSION} was found.")
  73. else ()
  74. message(FATAL_ERROR "Boost was not found.")
  75. endif ()
  76. endif ()
  77. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  78. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  79. endif ()
  80. set(CNTVAR 1)
  81. foreach(BOOSTLIB ${Boost_LIBRARIES})
  82. add_imported_library(target-boost-${CNTVAR} SHARED ${BOOSTLIB} ${Boost_INCLUDE_DIRS})
  83. list(APPEND STORM_DEP_TARGETS target-boost-${CNTVAR}_SHARED)
  84. MATH(EXPR CNTVAR "${CNTVAR}+1")
  85. endforeach()
  86. message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).")
  87. # set the information for the config header
  88. set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}")
  89. #############################################################
  90. ##
  91. ## ExprTk
  92. ##
  93. #############################################################
  94. # Use the shipped version of ExprTK
  95. message (STATUS "Storm - Including ExprTk.")
  96. add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  97. list(APPEND STORM_DEP_TARGETS ExprTk)
  98. #############################################################
  99. ##
  100. ## Sparsepp
  101. ##
  102. #############################################################
  103. # Use the shipped version of Sparsepp
  104. message (STATUS "Storm - Including Sparsepp.")
  105. set(SPARSEPP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp")
  106. file(GLOB SPARSEPP_HEADERS "${SPARSEPP_INCLUDE_DIR}/*.h")
  107. # Add the sparsepp headers to the headers that are copied to the include directory in the build directory.
  108. set(SPARSEPP_BINDIR_DIR ${STORM_3RDPARTY_INCLUDE_DIR}/sparsepp)
  109. include_directories("${SPARSEPP_BINDIR_DIR}")
  110. foreach(HEADER ${SPARSEPP_HEADERS})
  111. string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER})
  112. string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH})
  113. string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH})
  114. add_custom_command(
  115. OUTPUT ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  116. COMMAND ${CMAKE_COMMAND} -E make_directory ${SPARSEPP_BINDIR_DIR}/sparsepp
  117. COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  118. DEPENDS ${SPARSEPP_INCLUDE_DIR}/${HEADER_FILENAME}
  119. )
  120. list(APPEND SPARSEPP_BINDIR_HEADERS ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME})
  121. endforeach()
  122. #############################################################
  123. ##
  124. ## ModernJSON
  125. ##
  126. #############################################################
  127. #use the shipped version of modernjson
  128. message (STATUS "Storm - Including ModernJSON.")
  129. add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/")
  130. list(APPEND STORM_DEP_TARGETS ModernJSON)
  131. #############################################################
  132. ##
  133. ## Z3 (optional)
  134. ##
  135. #############################################################
  136. find_package(Z3 QUIET)
  137. # Z3 Defines
  138. set(STORM_HAVE_Z3 ${Z3_FOUND})
  139. if(Z3_FOUND)
  140. # Get the z3 version by compiling and running a simple program
  141. try_run(version_run_result version_compile_result "${STORM_3RDPARTY_BINARY_DIR}/z3/" "${PROJECT_SOURCE_DIR}/resources/3rdparty/z3/output_version.cpp" CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${Z3_INCLUDE_DIR}" LINK_LIBRARIES "${Z3_LIBRARIES}" RUN_OUTPUT_VARIABLE z3_version_output)
  142. if (version_compile_result AND version_run_result EQUAL 0)
  143. if (z3_version_output MATCHES "([0-9]*\\.[0-9]*\\.[0-9]*)")
  144. set(Z3_VERSION "${CMAKE_MATCH_1}")
  145. endif()
  146. endif()
  147. if(Z3_VERSION)
  148. # Split Z3 version into its components
  149. string(REPLACE "." ";" Z3_VERSION_LIST ${Z3_VERSION})
  150. list(GET Z3_VERSION_LIST 0 STORM_Z3_VERSION_MAJOR)
  151. list(GET Z3_VERSION_LIST 1 STORM_Z3_VERSION_MINOR)
  152. list(GET Z3_VERSION_LIST 2 STORM_Z3_VERSION_PATCH)
  153. # Check whether the version of z3 supports optimization
  154. if(NOT "${Z3_VERSION}" VERSION_LESS "4.5.0")
  155. set(STORM_HAVE_Z3_OPTIMIZE ON)
  156. message (STATUS "Storm - Linking with Z3 (version ${Z3_VERSION}). (Z3 version supports optimization)")
  157. else()
  158. message (STATUS "Storm - Linking with Z3 (version ${Z3_VERSION}). (Z3 version does not support optimization)")
  159. endif()
  160. if (NOT "${Z3_VERSION}" VERSION_LESS "4.7.1")
  161. set(STORM_Z3_API_USES_STANDARD_INTEGERS ON)
  162. endif()
  163. add_imported_library(Z3 SHARED ${Z3_LIBRARIES} ${Z3_INCLUDE_DIRS})
  164. list(APPEND STORM_DEP_TARGETS Z3_SHARED)
  165. else()
  166. message(WARNING "Storm - Could not obtain Z3 version. Building of Prism/JANI models will not be supported.")
  167. set(Z3_FOUND FALSE)
  168. endif()
  169. else()
  170. message (WARNING "Storm - Z3 not found. Building of Prism/JANI models will not be supported.")
  171. endif(Z3_FOUND)
  172. #############################################################
  173. ##
  174. ## glpk
  175. ##
  176. #############################################################
  177. include(${STORM_3RDPARTY_SOURCE_DIR}/include_glpk.cmake)
  178. #############################################################
  179. ##
  180. ## Gurobi (optional)
  181. ##
  182. #############################################################
  183. if (STORM_USE_GUROBI)
  184. find_package(GUROBI QUIET REQUIRED)
  185. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  186. if (GUROBI_FOUND)
  187. if (EXISTS ${GUROBI_LIBRARY})
  188. message (STATUS "Storm - Linking with Gurobi (${GUROBI_CXX_LIBRARY}).")
  189. add_imported_library(GUROBI SHARED ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS})
  190. list(APPEND STORM_DEP_TARGETS GUROBI_SHARED)
  191. else()
  192. # The FindGurobi.cmake script needs to be updated every now and then as the library file contains the version number...
  193. message(FATAL_ERROR "Gurobi Library ${GUROBI_LIBRARY} not found. If your Gurobi Version is higher then 9.0.0, please contact the Storm developers.")
  194. endif()
  195. else()
  196. # The FindGurobi.cmake script needs to be updated every now and then as the library file contains the version number ...
  197. message(FATAL_ERROR "Gurobi Library requested but was not found. Make sure that GUROBI_ROOT points to the correct directory (containing include/ and lib/ subdirectories). If your Gurobi Version is higher then 9.0.0, please contact the Storm developers.")
  198. endif()
  199. else()
  200. set(STORM_HAVE_GUROBI OFF)
  201. endif()
  202. #############################################################
  203. ##
  204. ## CUDD
  205. ##
  206. #############################################################
  207. include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake)
  208. #############################################################
  209. ##
  210. ## carl
  211. ##
  212. #############################################################
  213. set(STORM_HAVE_CARL OFF)
  214. set(CARL_MINVERSION "17.12")
  215. set(CARL_C14VERSION "14")
  216. if (NOT STORM_FORCE_SHIPPED_CARL)
  217. if (NOT "${STORM_CARL_DIR_HINT}" STREQUAL "")
  218. find_package(carl QUIET PATHS ${STORM_CARL_DIR_HINT} NO_DEFAULT_PATH)
  219. endif()
  220. if (NOT carl_FOUND)
  221. find_package(carl QUIET)
  222. endif()
  223. endif()
  224. set(STORM_SHIPPED_CARL OFF)
  225. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  226. get_target_property(carlLOCATION lib_carl LOCATION)
  227. if("${carlLOCATION}" STREQUAL "carlLOCATION-NOTFOUND")
  228. if(EXISTS ${STORM_3RDPARTY_BINARY_DIR}/carl)
  229. message(WARNING "Storm - Library for carl location is not found but the directory ${STORM_3RDPARTY_BINARY_DIR}/carl exists. Will (re-)try to build a shipped version of carl.")
  230. set(STORM_SHIPPED_CARL ON)
  231. else()
  232. message(FATAL_ERROR "Library location for carl is not found, did you build carl?")
  233. endif()
  234. elseif(EXISTS ${carlLOCATION})
  235. #empty on purpose
  236. else()
  237. if(EXISTS ${STORM_3RDPARTY_BINARY_DIR}/carl)
  238. message(WARNING "Storm - File ${carlLOCATION} does not exist but the directory ${STORM_3RDPARTY_BINARY_DIR}/carl exists. Will (re-)try to build a shipped version of carl.")
  239. set(STORM_SHIPPED_CARL ON)
  240. else()
  241. message(FATAL_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  242. endif()
  243. endif()
  244. if("${carl_VERSION_MAJOR}" STREQUAL "${CARL_C14VERSION}")
  245. message(STATUS "Storm - Found carl using master14 branch.")
  246. # empty on purpose. Maybe put a warning here?
  247. elseif("${carl_VERSION_MAJOR}.${carl_VERSION_MINOR}" VERSION_LESS "${CARL_MINVERSION}")
  248. message(FATAL_ERROR "Carl outdated, require ${CARL_MINVERSION}, have ${carl_VERSION}")
  249. endif()
  250. set(STORM_HAVE_CARL ON)
  251. message(STATUS "Storm - Use system version of carl.")
  252. message(STATUS "Storm - Linking with preinstalled carl ${carl_VERSION} (include: ${carl_INCLUDE_DIR}, library ${carl_LIBRARIES}, CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}, CARL_USE_GINAC: ${CARL_USE_GINAC}).")
  253. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  254. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  255. else()
  256. set(STORM_SHIPPED_CARL ON)
  257. endif()
  258. if (STORM_SHIPPED_CARL)
  259. # The first external project will be built at *configure stage*
  260. message(STATUS "Carl - Start of config process")
  261. file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
  262. execute_process(
  263. COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" "-DBoost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}" "-DBoost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}"
  264. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  265. OUTPUT_VARIABLE carlconfig_out
  266. RESULT_VARIABLE carlconfig_result)
  267. if(NOT carlconfig_result)
  268. message(STATUS "${carlconfig_out}")
  269. endif()
  270. execute_process(
  271. COMMAND ${CMAKE_COMMAND} --build . --target carl-config
  272. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  273. OUTPUT_VARIABLE carlconfig_out
  274. RESULT_VARIABLE carlconfig_result
  275. )
  276. if(NOT carlconfig_result)
  277. message(STATUS "${carlconfig_out}")
  278. endif()
  279. message(STATUS "Carl - End of config process")
  280. message(STATUS "Storm - Using shipped version of carl.")
  281. ExternalProject_Add(
  282. carl
  283. SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl
  284. CONFIGURE_COMMAND ""
  285. BUILD_IN_SOURCE 1
  286. BUILD_COMMAND make lib_carl
  287. INSTALL_COMMAND make install
  288. LOG_BUILD ON
  289. LOG_INSTALL ON
  290. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}
  291. )
  292. include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake)
  293. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  294. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  295. add_dependencies(resources carl)
  296. set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/")
  297. set(carl_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/")
  298. set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  299. set(STORM_HAVE_CARL ON)
  300. message(STATUS "Storm - Linking with shipped carl ${carl_VERSION} (include: ${carl_INCLUDE_DIR}, library ${carl_LIBRARIES}, CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}, CARL_USE_GINAC: ${CARL_USE_GINAC}).")
  301. # install the carl dynamic library if we built it
  302. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  303. endif()
  304. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  305. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  306. endif()
  307. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  308. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  309. endif()
  310. # The library that needs symbols must be first, then the library that resolves the symbol.
  311. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  312. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  313. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  314. endif()
  315. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  316. #############################################################
  317. ##
  318. ## SMT-RAT
  319. ##
  320. #############################################################
  321. set(STORM_HAVE_SMTRAT OFF)
  322. if(USE_SMTRAT)
  323. find_package(smtrat QUIET REQUIRED)
  324. if(smtrat_FOUND)
  325. set(STORM_HAVE_SMTRAT ON)
  326. message(STATUS "Storm - Linking with smtrat.")
  327. include_directories("${smtrat_INCLUDE_DIR}")
  328. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  329. else()
  330. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  331. endif()
  332. endif()
  333. #############################################################
  334. ##
  335. ## HyPro
  336. ##
  337. #############################################################
  338. set(STORM_HAVE_HYPRO OFF)
  339. if(USE_HYPRO)
  340. find_package(hypro QUIET REQUIRED)
  341. if(hypro_FOUND)
  342. set(STORM_HAVE_HYPRO ON)
  343. message(STATUS "Storm - Linking with hypro.")
  344. include_directories("${hypro_INCLUDE_DIR}")
  345. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  346. else()
  347. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  348. endif()
  349. endif()
  350. #############################################################
  351. ##
  352. ## gmp
  353. ##
  354. #############################################################
  355. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  356. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  357. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  358. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  359. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  360. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  361. #############################################################
  362. ##
  363. ## cln
  364. ##
  365. #############################################################
  366. if(STORM_USE_CLN_RF OR STORM_USE_CLN_EA)
  367. get_target_property(CLN_INCLUDE_DIR CLN_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  368. endif()
  369. #############################################################
  370. ##
  371. ## MathSAT (optional)
  372. ##
  373. #############################################################
  374. if ("${MSAT_ROOT}" STREQUAL "")
  375. set(ENABLE_MSAT OFF)
  376. else()
  377. set(ENABLE_MSAT ON)
  378. endif()
  379. # MathSAT Defines
  380. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  381. if (ENABLE_MSAT)
  382. message (STATUS "Storm - Linking with MathSAT.")
  383. if(${OPERATING_SYSTEM} MATCHES "Linux")
  384. find_library(MSAT_LIB mathsat PATHS "${MSAT_ROOT}/lib")
  385. add_imported_library(msat SHARED ${MSAT_LIB} "${MSAT_ROOT}/include")
  386. list(APPEND STORM_DEP_TARGETS msat_SHARED)
  387. else()
  388. # on macOS, the .dylib file has some hard coded path (Version 5.5.4).
  389. # we thus link statically
  390. find_library(MSAT_LIB NAMES libmathsat${STATIC_EXT} mathsat PATHS "${MSAT_ROOT}/lib")
  391. add_imported_library(msat STATIC ${MSAT_LIB} "${MSAT_ROOT}/include")
  392. list(APPEND STORM_DEP_TARGETS msat_STATIC)
  393. endif()
  394. endif(ENABLE_MSAT)
  395. #############################################################
  396. ##
  397. ## QVBS (Quantitative verification benchmark set)
  398. ##
  399. #############################################################
  400. set(STORM_HAVE_QVBS OFF)
  401. if (STORM_LOAD_QVBS)
  402. ExternalProject_Add(
  403. download_qvbs
  404. GIT_REPOSITORY https://github.com/ahartmanns/qcomp.git
  405. GIT_SHALLOW 1
  406. PREFIX ${PROJECT_BINARY_DIR}/qvbs
  407. UPDATE_COMMAND ""
  408. CONFIGURE_COMMAND ""
  409. BUILD_COMMAND ""
  410. INSTALL_COMMAND ""
  411. LOG_INSTALL ON
  412. )
  413. add_dependencies(resources download_qvbs)
  414. set(STORM_HAVE_QVBS ON)
  415. ExternalProject_Get_Property(download_qvbs source_dir)
  416. set(STORM_QVBS_ROOT "${source_dir}/benchmarks")
  417. elseif (NOT "${STORM_QVBS_ROOT}" STREQUAL "")
  418. if( EXISTS "${STORM_QVBS_ROOT}/index.json")
  419. set(STORM_HAVE_QVBS ON)
  420. else()
  421. message(FATAL_ERROR "No file 'index.json' in provided QVBS root directory ${STORM_QVBS_ROOT}")
  422. endif()
  423. endif()
  424. if (STORM_HAVE_QVBS)
  425. message (STATUS "Storm - Enabled inputs from QVBS located at ${STORM_QVBS_ROOT}")
  426. endif()
  427. #############################################################
  428. ##
  429. ## Xerces
  430. ##
  431. #############################################################
  432. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  433. #############################################################
  434. ##
  435. ## Sylvan
  436. ##
  437. #############################################################
  438. if(STORM_SHIPPED_CARL)
  439. set(sylvan_dep carl)
  440. else()
  441. set(sylvan_dep lib_carl)
  442. endif()
  443. if (STORM_DEBUG_SYLVAN)
  444. set(SYLVAN_BUILD_TYPE "Debug")
  445. else()
  446. set(SYLVAN_BUILD_TYPE "Release")
  447. endif()
  448. ExternalProject_Add(
  449. sylvan
  450. DOWNLOAD_COMMAND ""
  451. PREFIX "sylvan"
  452. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  453. CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DGMP_LOCATION=${GMP_LIB_LOCATION} -DGMP_INCLUDE=${GMP_INCLUDE_DIR} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DSYLVAN_BUILD_DOCS=OFF -DSYLVAN_BUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=${SYLVAN_BUILD_TYPE} -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DUSE_CARL=ON -Dcarl_DIR=${carl_DIR} -DSYLVAN_PORTABLE=${STORM_PORTABLE} -DBoost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS} -DBUILD_SHARED_LIBS=OFF -DSYLVAN_BUILD_TESTS=OFF
  454. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  455. BUILD_IN_SOURCE 0
  456. INSTALL_COMMAND ""
  457. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  458. LOG_CONFIGURE ON
  459. LOG_BUILD ON
  460. DEPENDS ${sylvan_dep}
  461. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  462. BUILD_ALWAYS 1
  463. )
  464. # BUILD ALWAYS ON due to: https://stackoverflow.com/questions/46708124/cmake-doesnt-rebuild-externalproject-on-changes
  465. ExternalProject_Get_Property(sylvan source_dir)
  466. ExternalProject_Get_Property(sylvan binary_dir)
  467. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  468. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  469. message(STATUS "Storm - Using shipped version of sylvan.")
  470. message(STATUS "Storm - Linking with sylvan.")
  471. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  472. add_dependencies(sylvan_STATIC sylvan)
  473. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  474. find_package(HWLOC QUIET REQUIRED)
  475. if(HWLOC_FOUND)
  476. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  477. add_imported_library(HWLOC STATIC ${HWLOC_LIBRARIES} "")
  478. list(APPEND STORM_DEP_TARGETS HWLOC_STATIC)
  479. else()
  480. if(${OPERATING_SYSTEM} MATCHES "Linux")
  481. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  482. endif()
  483. endif()
  484. #############################################################
  485. ##
  486. ## cpptemplate
  487. ##
  488. #############################################################
  489. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  490. list(APPEND STORM_DEP_TARGETS CppTemplate)
  491. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  492. #############################################################
  493. ##
  494. ## Google Test gtest
  495. ##
  496. #############################################################
  497. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.10.0)
  498. ExternalProject_Add(
  499. googletest
  500. #For downloads (may be useful later!)
  501. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  502. #TIMEOUT 10
  503. DOWNLOAD_COMMAND ""
  504. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.10.0"
  505. # Force the same output paths for debug and release builds so that
  506. # we know in which place the binaries end up when using the Xcode generator
  507. CMAKE_ARGS -Dgtest_force_shared_crt=ON -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=${GOOGLETEST_LIB_DIR} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=${GOOGLETEST_LIB_DIR}
  508. # Disable install step
  509. INSTALL_COMMAND ""
  510. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  511. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  512. # Wrap download, configure and build steps in a script to log output
  513. LOG_CONFIGURE ON
  514. LOG_BUILD ON
  515. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/lib/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/lib/libgtest_main${STATIC_EXT}
  516. )
  517. # Specify include dir
  518. ExternalProject_Get_Property(googletest source_dir)
  519. set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
  520. # Specify MainTest's link libraries
  521. ExternalProject_Get_Property(googletest binary_dir)
  522. set(GTEST_LIBRARIES ${binary_dir}/lib/libgtest${STATIC_EXT} ${binary_dir}/lib/libgtest_main${STATIC_EXT})
  523. add_dependencies(test-resources googletest)
  524. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  525. #############################################################
  526. ##
  527. ## Intel Threading Building Blocks (optional)
  528. ##
  529. #############################################################
  530. set(STORM_HAVE_INTELTBB OFF)
  531. if (STORM_USE_INTELTBB)
  532. find_package(TBB QUIET REQUIRED)
  533. if (TBB_FOUND)
  534. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  535. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  536. set(STORM_HAVE_INTELTBB ON)
  537. # Under Linux libtbb.so contains a linker script to libtbb.so.2 instead of a symlink.
  538. # This breaks CMake.
  539. # As a workaround we manually try to add the necessary suffix ".2" to the so file and hope for the best.
  540. if (LINUX)
  541. # Check if the library is a linker script which only links to the correct library
  542. # Read first bytes of file
  543. file(READ "${TBB_LIBRARY}" TMPTXT LIMIT 128)
  544. # Check if file starts with "INPUT (libtbb.so.2)"
  545. if("${TMPTXT}" MATCHES "INPUT \\(libtbb\\.so\\.(.*)\\)")
  546. # Manually set library by adding the suffix from the linker script.
  547. # CMAKE_MATCH_1 contains the parsed suffix.
  548. set(TBB_LIB_LINUX "${TBB_LIBRARY}.${CMAKE_MATCH_1}")
  549. set(TBB_MALLOC_LIB_LINUX "${TBB_MALLOC_LIBRARY}.${CMAKE_MATCH_1}")
  550. if (EXISTS "${TBB_LIB_LINUX}")
  551. set(TBB_LIBRARY ${TBB_LIB_LINUX})
  552. message(STATUS "Storm - Using Intel TBB library in manually set path ${TBB_LIBRARY}.")
  553. endif()
  554. if (EXISTS "${TBB_MALLOC_LIB_LINUX}")
  555. set(TBB_MALLOC_LIBRARY ${TBB_MALLOC_LIB_LINUX})
  556. message(STATUS "Storm - Using Intel TBB malloc library in manually set path ${TBB_MALLOC_LIBRARY}.")
  557. endif()
  558. endif()
  559. endif()
  560. add_imported_library(tbb SHARED ${TBB_LIBRARY} ${TBB_INCLUDE_DIRS})
  561. list(APPEND STORM_DEP_TARGETS tbb_SHARED)
  562. add_imported_library(tbb_malloc SHARED ${TBB_MALLOC_LIBRARY} ${TBB_INCLUDE_DIRS})
  563. list(APPEND STORM_DEP_TARGETS tbb_malloc_SHARED)
  564. else(TBB_FOUND)
  565. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  566. endif(TBB_FOUND)
  567. endif(STORM_USE_INTELTBB)
  568. #############################################################
  569. ##
  570. ## Threads
  571. ##
  572. #############################################################
  573. find_package(Threads QUIET REQUIRED)
  574. if (NOT Threads_FOUND)
  575. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  576. endif()
  577. include_directories(${THREADS_INCLUDE_DIRS})
  578. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  579. if (STORM_USE_COTIRE)
  580. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  581. endif(STORM_USE_COTIRE)
  582. #############################################################
  583. ##
  584. ## CUDA Library generation
  585. ##
  586. #############################################################
  587. if ("${CUDA_ROOT}" STREQUAL "")
  588. set(ENABLE_CUDA OFF)
  589. else()
  590. set(ENABLE_CUDA ON)
  591. endif()
  592. # CUDA Defines
  593. if (ENABLE_CUDA)
  594. set(STORM_CPP_CUDA_DEF "define")
  595. else()
  596. set(STORM_CPP_CUDA_DEF "undef")
  597. endif()
  598. # CUDA Defines
  599. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  600. if(ENABLE_CUDA)
  601. # Test for type alignment
  602. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  603. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  604. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  605. )
  606. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  607. message(FATAL_ERROR "Storm (CudaPlugin) - Could not test type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}")
  608. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  609. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  610. else()
  611. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  612. endif()
  613. # Test for Float 64bit Alignment
  614. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  615. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  616. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  617. )
  618. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  619. message(FATAL_ERROR "Storm (CudaPlugin) - Could not test float type alignment, there was an Error while compiling the file ${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp: ${OUTPUT_TEST_VAR}")
  620. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  621. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  622. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  623. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  624. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  625. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  626. else()
  627. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  628. endif()
  629. #
  630. # Make a version file containing the current version from git.
  631. #
  632. include(GetGitRevisionDescription)
  633. git_describe_checkout(STORM_GIT_VERSION_STRING)
  634. # Parse the git Tag into variables
  635. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  636. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  637. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  638. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  639. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  640. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  641. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  642. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  643. else()
  644. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  645. endif()
  646. message(STATUS "Storm (CudaPlugin) - Version information: ${STORM_CUDAPLUGIN_VERSION_MAJOR}.${STORM_CUDAPLUGIN_VERSION_MINOR}.${STORM_CUDAPLUGIN_VERSION_PATCH} (${STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CUDAPLUGIN_VERSION_HASH} (Dirty: ${STORM_CUDAPLUGIN_VERSION_DIRTY})")
  647. # Configure a header file to pass some of the CMake settings to the source code
  648. configure_file (
  649. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  650. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  651. )
  652. #create library
  653. find_package(CUDA REQUIRED)
  654. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  655. find_package(Cusp REQUIRED)
  656. find_package(Thrust REQUIRED)
  657. set(STORM_CUDA_LIB_NAME "storm-cuda")
  658. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  659. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  660. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  661. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  662. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  663. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  664. #############################################################
  665. ##
  666. ## CUSP
  667. ##
  668. #############################################################
  669. if(CUSP_FOUND)
  670. include_directories(${CUSP_INCLUDE_DIR})
  671. cuda_include_directories(${CUSP_INCLUDE_DIR})
  672. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  673. else()
  674. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  675. endif()
  676. #############################################################
  677. ##
  678. ## Thrust
  679. ##
  680. #############################################################
  681. if(THRUST_FOUND)
  682. include_directories(${THRUST_INCLUDE_DIR})
  683. cuda_include_directories(${THRUST_INCLUDE_DIR})
  684. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  685. else()
  686. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  687. endif()
  688. include_directories(${CUDA_INCLUDE_DIRS})
  689. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  690. cuda_add_library(${STORM_CUDA_LIB_NAME}
  691. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  692. )
  693. message (STATUS "Storm - Linking with CUDA.")
  694. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  695. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  696. endif()
  697. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})