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.

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