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.

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