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.

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