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.

811 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. if(MACOSX)
  303. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  304. else()
  305. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}.${carl_VERSION} DESTINATION lib)
  306. endif()
  307. endif()
  308. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  309. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  310. endif()
  311. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  312. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  313. endif()
  314. # The library that needs symbols must be first, then the library that resolves the symbol.
  315. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  316. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  317. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  318. endif()
  319. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  320. #############################################################
  321. ##
  322. ## SMT-RAT
  323. ##
  324. #############################################################
  325. set(STORM_HAVE_SMTRAT OFF)
  326. if(USE_SMTRAT)
  327. find_package(smtrat QUIET REQUIRED)
  328. if(smtrat_FOUND)
  329. set(STORM_HAVE_SMTRAT ON)
  330. message(STATUS "Storm - Linking with smtrat.")
  331. include_directories("${smtrat_INCLUDE_DIR}")
  332. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  333. else()
  334. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  335. endif()
  336. endif()
  337. #############################################################
  338. ##
  339. ## HyPro
  340. ##
  341. #############################################################
  342. set(STORM_HAVE_HYPRO OFF)
  343. if(USE_HYPRO)
  344. find_package(hypro QUIET REQUIRED)
  345. if(hypro_FOUND)
  346. set(STORM_HAVE_HYPRO ON)
  347. message(STATUS "Storm - Linking with hypro.")
  348. include_directories("${hypro_INCLUDE_DIR}")
  349. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  350. else()
  351. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  352. endif()
  353. endif()
  354. #############################################################
  355. ##
  356. ## gmp
  357. ##
  358. #############################################################
  359. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  360. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  361. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  362. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  363. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  364. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  365. #############################################################
  366. ##
  367. ## cln
  368. ##
  369. #############################################################
  370. if(STORM_USE_CLN_RF OR STORM_USE_CLN_EA)
  371. get_target_property(CLN_INCLUDE_DIR CLN_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  372. endif()
  373. #############################################################
  374. ##
  375. ## MathSAT (optional)
  376. ##
  377. #############################################################
  378. if ("${MSAT_ROOT}" STREQUAL "")
  379. set(ENABLE_MSAT OFF)
  380. else()
  381. set(ENABLE_MSAT ON)
  382. endif()
  383. # MathSAT Defines
  384. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  385. if (ENABLE_MSAT)
  386. message (STATUS "Storm - Linking with MathSAT.")
  387. if(${OPERATING_SYSTEM} MATCHES "Linux")
  388. find_library(MSAT_LIB mathsat PATHS "${MSAT_ROOT}/lib")
  389. add_imported_library(msat SHARED ${MSAT_LIB} "${MSAT_ROOT}/include")
  390. list(APPEND STORM_DEP_TARGETS msat_SHARED)
  391. else()
  392. # on macOS, the .dylib file has some hard coded path (Version 5.5.4).
  393. # we thus link statically
  394. find_library(MSAT_LIB NAMES libmathsat${STATIC_EXT} mathsat PATHS "${MSAT_ROOT}/lib")
  395. add_imported_library(msat STATIC ${MSAT_LIB} "${MSAT_ROOT}/include")
  396. list(APPEND STORM_DEP_TARGETS msat_STATIC)
  397. endif()
  398. endif(ENABLE_MSAT)
  399. #############################################################
  400. ##
  401. ## QVBS (Quantitative verification benchmark set)
  402. ##
  403. #############################################################
  404. set(STORM_HAVE_QVBS OFF)
  405. if (STORM_LOAD_QVBS)
  406. ExternalProject_Add(
  407. download_qvbs
  408. GIT_REPOSITORY https://github.com/ahartmanns/qcomp.git
  409. GIT_SHALLOW 1
  410. PREFIX ${PROJECT_BINARY_DIR}/qvbs
  411. UPDATE_COMMAND ""
  412. CONFIGURE_COMMAND ""
  413. BUILD_COMMAND ""
  414. INSTALL_COMMAND ""
  415. LOG_INSTALL ON
  416. )
  417. add_dependencies(resources download_qvbs)
  418. set(STORM_HAVE_QVBS ON)
  419. ExternalProject_Get_Property(download_qvbs source_dir)
  420. set(STORM_QVBS_ROOT "${source_dir}/benchmarks")
  421. elseif (NOT "${STORM_QVBS_ROOT}" STREQUAL "")
  422. if( EXISTS "${STORM_QVBS_ROOT}/index.json")
  423. set(STORM_HAVE_QVBS ON)
  424. else()
  425. message(FATAL_ERROR "No file 'index.json' in provided QVBS root directory ${STORM_QVBS_ROOT}")
  426. endif()
  427. endif()
  428. if (STORM_HAVE_QVBS)
  429. message (STATUS "Storm - Enabled inputs from QVBS located at ${STORM_QVBS_ROOT}")
  430. endif()
  431. #############################################################
  432. ##
  433. ## Xerces
  434. ##
  435. #############################################################
  436. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  437. #############################################################
  438. ##
  439. ## Sylvan
  440. ##
  441. #############################################################
  442. if(STORM_SHIPPED_CARL)
  443. set(sylvan_dep carl)
  444. else()
  445. set(sylvan_dep lib_carl)
  446. endif()
  447. if (STORM_DEBUG_SYLVAN)
  448. set(SYLVAN_BUILD_TYPE "Debug")
  449. else()
  450. set(SYLVAN_BUILD_TYPE "Release")
  451. endif()
  452. ExternalProject_Add(
  453. sylvan
  454. DOWNLOAD_COMMAND ""
  455. PREFIX "sylvan"
  456. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  457. 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
  458. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  459. BUILD_IN_SOURCE 0
  460. INSTALL_COMMAND ""
  461. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  462. LOG_CONFIGURE ON
  463. LOG_BUILD ON
  464. DEPENDS ${sylvan_dep}
  465. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  466. BUILD_ALWAYS 1
  467. )
  468. # BUILD ALWAYS ON due to: https://stackoverflow.com/questions/46708124/cmake-doesnt-rebuild-externalproject-on-changes
  469. ExternalProject_Get_Property(sylvan source_dir)
  470. ExternalProject_Get_Property(sylvan binary_dir)
  471. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  472. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  473. message(STATUS "Storm - Using shipped version of sylvan.")
  474. message(STATUS "Storm - Linking with sylvan.")
  475. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  476. add_dependencies(sylvan_STATIC sylvan)
  477. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  478. find_package(HWLOC QUIET REQUIRED)
  479. if(HWLOC_FOUND)
  480. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  481. add_imported_library(HWLOC STATIC ${HWLOC_LIBRARIES} "")
  482. list(APPEND STORM_DEP_TARGETS HWLOC_STATIC)
  483. else()
  484. if(${OPERATING_SYSTEM} MATCHES "Linux")
  485. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  486. endif()
  487. endif()
  488. #############################################################
  489. ##
  490. ## cpptemplate
  491. ##
  492. #############################################################
  493. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  494. list(APPEND STORM_DEP_TARGETS CppTemplate)
  495. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  496. #############################################################
  497. ##
  498. ## Google Test gtest
  499. ##
  500. #############################################################
  501. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.10.0)
  502. ExternalProject_Add(
  503. googletest
  504. #For downloads (may be useful later!)
  505. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  506. #TIMEOUT 10
  507. DOWNLOAD_COMMAND ""
  508. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.10.0"
  509. # Force the same output paths for debug and release builds so that
  510. # we know in which place the binaries end up when using the Xcode generator
  511. 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}
  512. # Disable install step
  513. INSTALL_COMMAND ""
  514. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  515. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  516. # Wrap download, configure and build steps in a script to log output
  517. LOG_CONFIGURE ON
  518. LOG_BUILD ON
  519. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/lib/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/lib/libgtest_main${STATIC_EXT}
  520. )
  521. # Specify include dir
  522. ExternalProject_Get_Property(googletest source_dir)
  523. set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
  524. # Specify MainTest's link libraries
  525. ExternalProject_Get_Property(googletest binary_dir)
  526. set(GTEST_LIBRARIES ${binary_dir}/lib/libgtest${STATIC_EXT} ${binary_dir}/lib/libgtest_main${STATIC_EXT})
  527. add_dependencies(test-resources googletest)
  528. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  529. #############################################################
  530. ##
  531. ## Intel Threading Building Blocks (optional)
  532. ##
  533. #############################################################
  534. set(STORM_HAVE_INTELTBB OFF)
  535. if (STORM_USE_INTELTBB)
  536. find_package(TBB QUIET REQUIRED)
  537. if (TBB_FOUND)
  538. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  539. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  540. set(STORM_HAVE_INTELTBB ON)
  541. # Under Linux libtbb.so contains a linker script to libtbb.so.2 instead of a symlink.
  542. # This breaks CMake.
  543. # As a workaround we manually try to add the necessary suffix ".2" to the so file and hope for the best.
  544. if (LINUX)
  545. # Check if the library is a linker script which only links to the correct library
  546. # Read first bytes of file
  547. file(READ "${TBB_LIBRARY}" TMPTXT LIMIT 128)
  548. # Check if file starts with "INPUT (libtbb.so.2)"
  549. if("${TMPTXT}" MATCHES "INPUT \\(libtbb\\.so\\.(.*)\\)")
  550. # Manually set library by adding the suffix from the linker script.
  551. # CMAKE_MATCH_1 contains the parsed suffix.
  552. set(TBB_LIB_LINUX "${TBB_LIBRARY}.${CMAKE_MATCH_1}")
  553. set(TBB_MALLOC_LIB_LINUX "${TBB_MALLOC_LIBRARY}.${CMAKE_MATCH_1}")
  554. if (EXISTS "${TBB_LIB_LINUX}")
  555. set(TBB_LIBRARY ${TBB_LIB_LINUX})
  556. message(STATUS "Storm - Using Intel TBB library in manually set path ${TBB_LIBRARY}.")
  557. endif()
  558. if (EXISTS "${TBB_MALLOC_LIB_LINUX}")
  559. set(TBB_MALLOC_LIBRARY ${TBB_MALLOC_LIB_LINUX})
  560. message(STATUS "Storm - Using Intel TBB malloc library in manually set path ${TBB_MALLOC_LIBRARY}.")
  561. endif()
  562. endif()
  563. endif()
  564. add_imported_library(tbb SHARED ${TBB_LIBRARY} ${TBB_INCLUDE_DIRS})
  565. list(APPEND STORM_DEP_TARGETS tbb_SHARED)
  566. add_imported_library(tbb_malloc SHARED ${TBB_MALLOC_LIBRARY} ${TBB_INCLUDE_DIRS})
  567. list(APPEND STORM_DEP_TARGETS tbb_malloc_SHARED)
  568. else(TBB_FOUND)
  569. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  570. endif(TBB_FOUND)
  571. endif(STORM_USE_INTELTBB)
  572. #############################################################
  573. ##
  574. ## Threads
  575. ##
  576. #############################################################
  577. find_package(Threads QUIET REQUIRED)
  578. if (NOT Threads_FOUND)
  579. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  580. endif()
  581. include_directories(${THREADS_INCLUDE_DIRS})
  582. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  583. if (STORM_USE_COTIRE)
  584. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  585. endif(STORM_USE_COTIRE)
  586. #############################################################
  587. ##
  588. ## CUDA Library generation
  589. ##
  590. #############################################################
  591. if ("${CUDA_ROOT}" STREQUAL "")
  592. set(ENABLE_CUDA OFF)
  593. else()
  594. set(ENABLE_CUDA ON)
  595. endif()
  596. # CUDA Defines
  597. if (ENABLE_CUDA)
  598. set(STORM_CPP_CUDA_DEF "define")
  599. else()
  600. set(STORM_CPP_CUDA_DEF "undef")
  601. endif()
  602. # CUDA Defines
  603. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  604. if(ENABLE_CUDA)
  605. # Test for type alignment
  606. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  607. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  608. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  609. )
  610. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  611. 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}")
  612. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  613. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  614. else()
  615. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  616. endif()
  617. # Test for Float 64bit Alignment
  618. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  619. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  620. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  621. )
  622. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  623. 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}")
  624. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  625. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  626. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  627. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  628. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  629. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  630. else()
  631. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  632. endif()
  633. #
  634. # Make a version file containing the current version from git.
  635. #
  636. include(GetGitRevisionDescription)
  637. git_describe_checkout(STORM_GIT_VERSION_STRING)
  638. # Parse the git Tag into variables
  639. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  640. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  641. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  642. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  643. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  644. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  645. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  646. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  647. else()
  648. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  649. endif()
  650. 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})")
  651. # Configure a header file to pass some of the CMake settings to the source code
  652. configure_file (
  653. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  654. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  655. )
  656. #create library
  657. find_package(CUDA REQUIRED)
  658. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  659. find_package(Cusp REQUIRED)
  660. find_package(Thrust REQUIRED)
  661. set(STORM_CUDA_LIB_NAME "storm-cuda")
  662. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  663. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  664. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  665. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  666. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  667. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  668. #############################################################
  669. ##
  670. ## CUSP
  671. ##
  672. #############################################################
  673. if(CUSP_FOUND)
  674. include_directories(${CUSP_INCLUDE_DIR})
  675. cuda_include_directories(${CUSP_INCLUDE_DIR})
  676. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  677. else()
  678. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  679. endif()
  680. #############################################################
  681. ##
  682. ## Thrust
  683. ##
  684. #############################################################
  685. if(THRUST_FOUND)
  686. include_directories(${THRUST_INCLUDE_DIR})
  687. cuda_include_directories(${THRUST_INCLUDE_DIR})
  688. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  689. else()
  690. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  691. endif()
  692. include_directories(${CUDA_INCLUDE_DIRS})
  693. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  694. cuda_add_library(${STORM_CUDA_LIB_NAME}
  695. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  696. )
  697. message (STATUS "Storm - Linking with CUDA.")
  698. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  699. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  700. endif()
  701. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})