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.

648 lines
24 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. #############################################################
  27. ##
  28. ## gmm
  29. ##
  30. #############################################################
  31. add_imported_library_interface(gmm "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include")
  32. list(APPEND STORM_DEP_TARGETS gmm)
  33. #############################################################
  34. ##
  35. ## Eigen
  36. ##
  37. #############################################################
  38. add_imported_library_interface(StormEigen33 "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1")
  39. list(APPEND STORM_DEP_TARGETS StormEigen33)
  40. #############################################################
  41. ##
  42. ## Boost
  43. ##
  44. #############################################################
  45. # Boost Option variables
  46. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  47. set(Boost_USE_MULTITHREADED ON)
  48. set(Boost_USE_STATIC_RUNTIME OFF)
  49. find_package(Boost 1.61.0 QUIET REQUIRED COMPONENTS filesystem system)
  50. if (NOT Boost_FOUND)
  51. if (Boost_VERSION)
  52. message(FATAL_ERROR "The required Boost version is 1.61.0 or newer, however, only ${Boost_VERSION} was found.")
  53. else ()
  54. message(FATAL_ERROR "Boost was not found.")
  55. endif ()
  56. endif ()
  57. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  58. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  59. endif ()
  60. set(CNTVAR 1)
  61. foreach(BOOSTLIB ${Boost_LIBRARIES})
  62. add_imported_library(target-boost-${CNTVAR} SHARED ${BOOSTLIB} ${Boost_INCLUDE_DIRS})
  63. list(APPEND STORM_DEP_TARGETS target-boost-${CNTVAR}_SHARED)
  64. MATH(EXPR CNTVAR "${CNTVAR}+1")
  65. endforeach()
  66. message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).")
  67. # set the information for the config header
  68. set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}")
  69. #############################################################
  70. ##
  71. ## ExprTk
  72. ##
  73. #############################################################
  74. # Use the shipped version of ExprTK
  75. message (STATUS "Storm - Including ExprTk.")
  76. add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  77. list(APPEND STORM_DEP_TARGETS ExprTk)
  78. #############################################################
  79. ##
  80. ## Sparsepp
  81. ##
  82. #############################################################
  83. # Use the shipped version of Sparsepp
  84. message (STATUS "Storm - Including Sparsepp.")
  85. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp")
  86. # Add sparsepp.h to the headers that are copied to the include directory in thebuild directory.
  87. add_custom_command(
  88. OUTPUT ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h
  89. COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp
  90. COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp.h ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h
  91. DEPENDS ${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp.h
  92. )
  93. list(APPEND STORM_RESOURCES_HEADERS "${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h")
  94. #############################################################
  95. ##
  96. ## ModernJSON
  97. ##
  98. #############################################################
  99. #use the shipped version of modernjson
  100. message (STATUS "Storm - Including ModernJSON.")
  101. add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/")
  102. list(APPEND STORM_DEP_TARGETS ModernJSON)
  103. #############################################################
  104. ##
  105. ## Z3 (optional)
  106. ##
  107. #############################################################
  108. find_package(Z3 QUIET)
  109. # Z3 Defines
  110. set(STORM_HAVE_Z3 ${Z3_FOUND})
  111. if(Z3_FOUND)
  112. # Check whether the version of z3 supports optimization
  113. if (Z3_EXEC)
  114. execute_process (COMMAND ${Z3_EXEC} -version
  115. OUTPUT_VARIABLE z3_version_output
  116. ERROR_QUIET
  117. OUTPUT_STRIP_TRAILING_WHITESPACE)
  118. if (z3_version_output MATCHES "([0-9]*\\.[0-9]*\\.[0-9]*)")
  119. set(Z3_VERSION "${CMAKE_MATCH_1}")
  120. if(NOT "${Z3_VERSION}" VERSION_LESS "4.5.0")
  121. set(STORM_HAVE_Z3_OPTIMIZE ON)
  122. endif()
  123. endif()
  124. endif()
  125. if(STORM_HAVE_Z3_OPTIMIZE)
  126. message (STATUS "Storm - Linking with Z3. (Z3 version supports optimization)")
  127. else()
  128. message (STATUS "Storm - Linking with Z3. (Z3 version does not support optimization)")
  129. endif()
  130. add_imported_library(z3 SHARED ${Z3_LIBRARIES} ${Z3_INCLUDE_DIRS})
  131. list(APPEND STORM_DEP_TARGETS z3_SHARED)
  132. endif(Z3_FOUND)
  133. #############################################################
  134. ##
  135. ## glpk
  136. ##
  137. #############################################################
  138. include(${STORM_3RDPARTY_SOURCE_DIR}/include_glpk.cmake)
  139. #############################################################
  140. ##
  141. ## Gurobi (optional)
  142. ##
  143. #############################################################
  144. if (STORM_USE_GUROBI)
  145. find_package(Gurobi QUIET REQUIRED)
  146. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  147. if (GUROBI_FOUND)
  148. message (STATUS "Storm - Linking with Gurobi.")
  149. add_imported_library(Gurobi "" ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS})
  150. list(APPEND STORM_DEP_TARGETS Gurobi)
  151. endif()
  152. else()
  153. set(STORM_HAVE_GUROBI OFF)
  154. endif()
  155. #############################################################
  156. ##
  157. ## CUDD
  158. ##
  159. #############################################################
  160. include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake)
  161. #############################################################
  162. ##
  163. ## carl
  164. ##
  165. #############################################################
  166. set(STORM_HAVE_CARL OFF)
  167. if(USE_CARL)
  168. if (NOT STORM_FORCE_SHIPPED_CARL)
  169. find_package(carl QUIET)
  170. endif()
  171. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  172. get_target_property(carlLOCATION lib_carl LOCATION)
  173. if(${carlLOCATION} STREQUAL "carlLOCATION-NOTFOUND")
  174. message(SEND_ERROR "Library location for carl is not found, did you build carl?")
  175. elseif(EXISTS ${carlLOCATION})
  176. #empty on purpose
  177. else()
  178. message(SEND_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  179. endif()
  180. set(STORM_SHIPPED_CARL OFF)
  181. set(STORM_HAVE_CARL ON)
  182. message(STATUS "Storm - Use system version of carl.")
  183. message(STATUS "Storm - Linking with carl ${carl_VERSION} (CARL_USE_CLN_NUMBERS: ${CARL_USE_CLN_NUMBERS}, CARL_USE_GINAC: ${CARL_USE_GINAC}).")
  184. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  185. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  186. else()
  187. set(STORM_SHIPPED_CARL ON)
  188. # The first external project will be built at *configure stage*
  189. message("START CARL CONFIG PROCESS")
  190. file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
  191. execute_process(
  192. COMMAND ${CMAKE_COMMAND} ${STORM_3RDPARTY_SOURCE_DIR}/carl "-DSTORM_3RDPARTY_BINARY_DIR=${STORM_3RDPARTY_BINARY_DIR}" "-DUSE_CLN_NUMBERS=ON" "-DUSE_GINAC=ON" "-DBoost_LIBRARY_DIRS=${Boost_LIBRARY_DIRS}" "-DBoost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}" "-DTHREAD_SAFE=ON"
  193. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  194. OUTPUT_VARIABLE carlconfig_out
  195. RESULT_VARIABLE carlconfig_result)
  196. if(NOT carlconfig_result)
  197. message("${carlconfig_out}")
  198. endif()
  199. execute_process(
  200. COMMAND ${CMAKE_COMMAND} --build . --target carl-config
  201. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  202. OUTPUT_VARIABLE carlconfig_out
  203. RESULT_VARIABLE carlconfig_result
  204. )
  205. if(NOT carlconfig_result)
  206. message("${carlconfig_out}")
  207. endif()
  208. message("END CARL CONFIG PROCESS")
  209. message(STATUS "Storm - Using shipped version of carl.")
  210. ExternalProject_Add(
  211. carl
  212. SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl
  213. CONFIGURE_COMMAND ""
  214. BUILD_IN_SOURCE 1
  215. BUILD_COMMAND make lib_carl
  216. INSTALL_COMMAND make install
  217. LOG_BUILD ON
  218. LOG_INSTALL ON
  219. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}
  220. )
  221. include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake)
  222. message("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. add_dependencies(resources carl)
  226. set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/")
  227. set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  228. set(STORM_HAVE_CARL ON)
  229. # install the carl dynamic library if we build it
  230. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.1.0.0${DYNAMIC_EXT} DESTINATION lib)
  231. endif()
  232. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  233. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  234. endif()
  235. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  236. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  237. endif()
  238. #The library that needs symbols must be first, then the library that resolves the symbol.
  239. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  240. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  241. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  242. endif()
  243. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  244. endif()
  245. #############################################################
  246. ##
  247. ## SMT-RAT
  248. ##
  249. #############################################################
  250. set(STORM_HAVE_SMTRAT OFF)
  251. if(USE_SMTRAT)
  252. find_package(smtrat QUIET REQUIRED)
  253. if(smtrat_FOUND)
  254. set(STORM_HAVE_SMTRAT ON)
  255. message(STATUS "Storm - Linking with smtrat.")
  256. include_directories("${smtrat_INCLUDE_DIR}")
  257. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  258. else()
  259. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  260. endif()
  261. endif()
  262. #############################################################
  263. ##
  264. ## HyPro
  265. ##
  266. #############################################################
  267. set(STORM_HAVE_HYPRO OFF)
  268. if(USE_HYPRO)
  269. find_package(hypro QUIET REQUIRED)
  270. if(hypro_FOUND)
  271. set(STORM_HAVE_HYPRO ON)
  272. message(STATUS "Storm - Linking with hypro.")
  273. include_directories("${hypro_INCLUDE_DIR}")
  274. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  275. else()
  276. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  277. endif()
  278. endif()
  279. #############################################################
  280. ##
  281. ## gmp
  282. ##
  283. #############################################################
  284. #
  285. #find_package(GMP QUIET REQUIRED)
  286. #
  287. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  288. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  289. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  290. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  291. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  292. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  293. #message(STATUS "Storm - Linking with gmp.")
  294. #include_directories("${GMP_INCLUDE_DIR}")
  295. #list(APPEND STORM_LINK_LIBRARIES ${GMP_LIBRARY})
  296. #############################################################
  297. ##
  298. ## MathSAT (optional)
  299. ##
  300. #############################################################
  301. if ("${MSAT_ROOT}" STREQUAL "")
  302. set(ENABLE_MSAT OFF)
  303. else()
  304. set(ENABLE_MSAT ON)
  305. endif()
  306. # MathSAT Defines
  307. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  308. if (ENABLE_MSAT)
  309. message (STATUS "Storm - Linking with MathSAT.")
  310. link_directories("${MSAT_ROOT}/lib")
  311. include_directories("${MSAT_ROOT}/include")
  312. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  313. endif(ENABLE_MSAT)
  314. #############################################################
  315. ##
  316. ## Xerces
  317. ##
  318. #############################################################
  319. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  320. #############################################################
  321. ##
  322. ## Sylvan
  323. ##
  324. #############################################################
  325. ExternalProject_Add(
  326. sylvan
  327. DOWNLOAD_COMMAND ""
  328. PREFIX "sylvan"
  329. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  330. 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=Release -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DUSE_CARL=ON -Dcarl_INCLUDE_DIR=${carl_INCLUDE_DIR} -DSYLVAN_PORTABLE=${STORM_PORTABLE} -Dcarl_LIBRARIES=${carl_LIBRARIES} -DBUILD_SHARED_LIBS=OFF -DSYLVAN_BUILD_TESTS=OFF
  331. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  332. BUILD_IN_SOURCE 0
  333. INSTALL_COMMAND ""
  334. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  335. LOG_CONFIGURE ON
  336. LOG_BUILD ON
  337. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  338. )
  339. ExternalProject_Get_Property(sylvan source_dir)
  340. ExternalProject_Get_Property(sylvan binary_dir)
  341. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  342. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  343. message(STATUS "Storm - Using shipped version of sylvan.")
  344. message(STATUS "Storm - Linking with sylvan.")
  345. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  346. add_dependencies(sylvan_STATIC sylvan)
  347. if(STORM_SHIPPED_CARL)
  348. add_dependencies(sylvan carl)
  349. endif()
  350. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  351. find_package(Hwloc QUIET REQUIRED)
  352. if(HWLOC_FOUND)
  353. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  354. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  355. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  356. else()
  357. if(${OPERATING_SYSTEM} MATCHES "Linux")
  358. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  359. endif()
  360. endif()
  361. #############################################################
  362. ##
  363. ## cpptemplate
  364. ##
  365. #############################################################
  366. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  367. list(APPEND STORM_DEP_TARGETS CppTemplate)
  368. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  369. #############################################################
  370. ##
  371. ## Google Test gtest
  372. ##
  373. #############################################################
  374. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  375. ExternalProject_Add(
  376. googletest
  377. #For downloads (may be useful later!)
  378. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  379. #TIMEOUT 10
  380. DOWNLOAD_COMMAND ""
  381. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  382. # Force the same output paths for debug and release builds so that
  383. # we know in which place the binaries end up when using the Xcode generator
  384. 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}
  385. # Disable install step
  386. INSTALL_COMMAND ""
  387. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  388. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  389. # Wrap download, configure and build steps in a script to log output
  390. LOG_CONFIGURE ON
  391. LOG_BUILD ON
  392. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  393. )
  394. # Specify include dir
  395. ExternalProject_Get_Property(googletest source_dir)
  396. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  397. # Specify MainTest's link libraries
  398. ExternalProject_Get_Property(googletest binary_dir)
  399. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  400. add_dependencies(test-resources googletest)
  401. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  402. #############################################################
  403. ##
  404. ## Intel Threading Building Blocks (optional)
  405. ##
  406. #############################################################
  407. set(STORM_HAVE_INTELTBB OFF)
  408. if (STORM_USE_INTELTBB)
  409. find_package(TBB QUIET REQUIRED)
  410. if (TBB_FOUND)
  411. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  412. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  413. set(STORM_HAVE_INTELTBB ON)
  414. link_directories(${TBB_LIBRARY_DIRS})
  415. include_directories(${TBB_INCLUDE_DIRS})
  416. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  417. else(TBB_FOUND)
  418. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  419. endif(TBB_FOUND)
  420. endif(STORM_USE_INTELTBB)
  421. #############################################################
  422. ##
  423. ## Threads
  424. ##
  425. #############################################################
  426. find_package(Threads QUIET REQUIRED)
  427. if (NOT Threads_FOUND)
  428. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  429. endif()
  430. include_directories(${THREADS_INCLUDE_DIRS})
  431. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  432. if (STORM_USE_COTIRE)
  433. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  434. endif(STORM_USE_COTIRE)
  435. #############################################################
  436. ##
  437. ## CUDA Library generation
  438. ##
  439. #############################################################
  440. if ("${CUDA_ROOT}" STREQUAL "")
  441. set(ENABLE_CUDA OFF)
  442. else()
  443. set(ENABLE_CUDA ON)
  444. endif()
  445. # CUDA Defines
  446. if (ENABLE_CUDA)
  447. set(STORM_CPP_CUDA_DEF "define")
  448. else()
  449. set(STORM_CPP_CUDA_DEF "undef")
  450. endif()
  451. # CUDA Defines
  452. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  453. if(ENABLE_CUDA)
  454. # Test for type alignment
  455. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  456. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  457. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  458. )
  459. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  460. 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}")
  461. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  462. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  463. else()
  464. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  465. endif()
  466. # Test for Float 64bit Alignment
  467. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  468. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  469. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  470. )
  471. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  472. 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}")
  473. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  474. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  475. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  476. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  477. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  478. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  479. else()
  480. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  481. endif()
  482. #
  483. # Make a version file containing the current version from git.
  484. #
  485. include(GetGitRevisionDescription)
  486. git_describe_checkout(STORM_GIT_VERSION_STRING)
  487. # Parse the git Tag into variables
  488. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  489. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  490. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  491. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  492. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  493. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  494. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  495. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  496. else()
  497. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  498. endif()
  499. 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})")
  500. # Configure a header file to pass some of the CMake settings to the source code
  501. configure_file (
  502. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  503. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  504. )
  505. #create library
  506. find_package(CUDA REQUIRED)
  507. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  508. find_package(Cusp REQUIRED)
  509. find_package(Thrust REQUIRED)
  510. set(STORM_CUDA_LIB_NAME "storm-cuda")
  511. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  512. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  513. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  514. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  515. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  516. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  517. #############################################################
  518. ##
  519. ## CUSP
  520. ##
  521. #############################################################
  522. if(CUSP_FOUND)
  523. include_directories(${CUSP_INCLUDE_DIR})
  524. cuda_include_directories(${CUSP_INCLUDE_DIR})
  525. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  526. else()
  527. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  528. endif()
  529. #############################################################
  530. ##
  531. ## Thrust
  532. ##
  533. #############################################################
  534. if(THRUST_FOUND)
  535. include_directories(${THRUST_INCLUDE_DIR})
  536. cuda_include_directories(${THRUST_INCLUDE_DIR})
  537. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  538. else()
  539. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  540. endif()
  541. include_directories(${CUDA_INCLUDE_DIRS})
  542. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  543. cuda_add_library(${STORM_CUDA_LIB_NAME}
  544. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  545. )
  546. message (STATUS "Storm - Linking with CUDA.")
  547. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  548. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  549. endif()
  550. add_custom_target(copy_resources_headers DEPENDS ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp/sparsepp.h)