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.

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