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.

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