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.

671 lines
25 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. else()
  133. message (WARNING "Storm - Z3 not found. Building of Prism/JANI models will not be supported.")
  134. endif(Z3_FOUND)
  135. #############################################################
  136. ##
  137. ## glpk
  138. ##
  139. #############################################################
  140. include(${STORM_3RDPARTY_SOURCE_DIR}/include_glpk.cmake)
  141. #############################################################
  142. ##
  143. ## Gurobi (optional)
  144. ##
  145. #############################################################
  146. if (STORM_USE_GUROBI)
  147. find_package(Gurobi QUIET REQUIRED)
  148. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  149. if (GUROBI_FOUND)
  150. message (STATUS "Storm - Linking with Gurobi.")
  151. add_imported_library(Gurobi SHARED ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS})
  152. list(APPEND STORM_DEP_TARGETS Gurobi_SHARED)
  153. endif()
  154. else()
  155. set(STORM_HAVE_GUROBI OFF)
  156. endif()
  157. #############################################################
  158. ##
  159. ## CUDD
  160. ##
  161. #############################################################
  162. include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake)
  163. #############################################################
  164. ##
  165. ## carl
  166. ##
  167. #############################################################
  168. set(STORM_HAVE_CARL OFF)
  169. set(CARL_MINYEAR 17)
  170. set(CARL_MINMONTH 06)
  171. set(CARL_MINPATCH 0)
  172. if(USE_CARL)
  173. if (NOT STORM_FORCE_SHIPPED_CARL)
  174. find_package(carl QUIET)
  175. endif()
  176. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  177. get_target_property(carlLOCATION lib_carl LOCATION)
  178. if(${carlLOCATION} STREQUAL "carlLOCATION-NOTFOUND")
  179. message(SEND_ERROR "Library location for carl is not found, did you build carl?")
  180. elseif(EXISTS ${carlLOCATION})
  181. #empty on purpose
  182. else()
  183. message(SEND_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  184. endif()
  185. if(${carl_MINORYEARVERSION} LESS ${CARL_MINYEAR})
  186. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  187. elseif(${carl_MINORYEARVERSION} EQUAL ${CARL_MINYEAR})
  188. if(${carl_MINORMONTHVERSION} LESS ${CARL_MINMONTH})
  189. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  190. elseif(${carl_MINORMONTHVERSION} EQUAL ${CARL_MINMONTH})
  191. if(${carl_MAINTENANCEVERSION} LESS ${CARL_MINPATCH})
  192. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  193. endif()
  194. endif()
  195. endif()
  196. set(STORM_SHIPPED_CARL OFF)
  197. set(STORM_HAVE_CARL ON)
  198. message(STATUS "Storm - Use system version of carl.")
  199. 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}).")
  200. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  201. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  202. else()
  203. set(STORM_SHIPPED_CARL ON)
  204. # The first external project will be built at *configure stage*
  205. message("START CARL CONFIG PROCESS")
  206. file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
  207. execute_process(
  208. 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}"
  209. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  210. OUTPUT_VARIABLE carlconfig_out
  211. RESULT_VARIABLE carlconfig_result)
  212. if(NOT carlconfig_result)
  213. message("${carlconfig_out}")
  214. endif()
  215. execute_process(
  216. COMMAND ${CMAKE_COMMAND} --build . --target carl-config
  217. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  218. OUTPUT_VARIABLE carlconfig_out
  219. RESULT_VARIABLE carlconfig_result
  220. )
  221. if(NOT carlconfig_result)
  222. message("${carlconfig_out}")
  223. endif()
  224. message("END CARL CONFIG PROCESS")
  225. message(STATUS "Storm - Using shipped version of carl.")
  226. ExternalProject_Add(
  227. carl
  228. SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl
  229. CONFIGURE_COMMAND ""
  230. BUILD_IN_SOURCE 1
  231. BUILD_COMMAND make lib_carl
  232. INSTALL_COMMAND make install
  233. LOG_BUILD ON
  234. LOG_INSTALL ON
  235. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}
  236. )
  237. include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake)
  238. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  239. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  240. add_dependencies(resources carl)
  241. set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/")
  242. set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  243. set(STORM_HAVE_CARL ON)
  244. 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}).")
  245. # install the carl dynamic library if we build it
  246. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  247. endif()
  248. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  249. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  250. endif()
  251. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  252. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  253. endif()
  254. #The library that needs symbols must be first, then the library that resolves the symbol.
  255. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  256. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  257. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  258. endif()
  259. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  260. endif()
  261. #############################################################
  262. ##
  263. ## SMT-RAT
  264. ##
  265. #############################################################
  266. set(STORM_HAVE_SMTRAT OFF)
  267. if(USE_SMTRAT)
  268. find_package(smtrat QUIET REQUIRED)
  269. if(smtrat_FOUND)
  270. set(STORM_HAVE_SMTRAT ON)
  271. message(STATUS "Storm - Linking with smtrat.")
  272. include_directories("${smtrat_INCLUDE_DIR}")
  273. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  274. else()
  275. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  276. endif()
  277. endif()
  278. #############################################################
  279. ##
  280. ## HyPro
  281. ##
  282. #############################################################
  283. set(STORM_HAVE_HYPRO OFF)
  284. if(USE_HYPRO)
  285. find_package(hypro QUIET REQUIRED)
  286. if(hypro_FOUND)
  287. set(STORM_HAVE_HYPRO ON)
  288. message(STATUS "Storm - Linking with hypro.")
  289. include_directories("${hypro_INCLUDE_DIR}")
  290. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  291. else()
  292. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  293. endif()
  294. endif()
  295. #############################################################
  296. ##
  297. ## gmp
  298. ##
  299. #############################################################
  300. #
  301. #find_package(GMP QUIET REQUIRED)
  302. #
  303. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  304. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  305. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  306. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  307. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  308. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  309. #message(STATUS "Storm - Linking with gmp.")
  310. #include_directories("${GMP_INCLUDE_DIR}")
  311. #list(APPEND STORM_LINK_LIBRARIES ${GMP_LIBRARY})
  312. #############################################################
  313. ##
  314. ## MathSAT (optional)
  315. ##
  316. #############################################################
  317. if ("${MSAT_ROOT}" STREQUAL "")
  318. set(ENABLE_MSAT OFF)
  319. else()
  320. set(ENABLE_MSAT ON)
  321. endif()
  322. # MathSAT Defines
  323. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  324. if (ENABLE_MSAT)
  325. message (STATUS "Storm - Linking with MathSAT.")
  326. link_directories("${MSAT_ROOT}/lib")
  327. include_directories("${MSAT_ROOT}/include")
  328. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  329. endif(ENABLE_MSAT)
  330. #############################################################
  331. ##
  332. ## Xerces
  333. ##
  334. #############################################################
  335. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  336. #############################################################
  337. ##
  338. ## Sylvan
  339. ##
  340. #############################################################
  341. if(STORM_SHIPPED_CARL)
  342. set(sylvan_dep carl)
  343. else()
  344. set(sylvan_dep lib_carl)
  345. endif()
  346. ExternalProject_Add(
  347. sylvan
  348. DOWNLOAD_COMMAND ""
  349. PREFIX "sylvan"
  350. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  351. 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
  352. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  353. BUILD_IN_SOURCE 0
  354. INSTALL_COMMAND ""
  355. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  356. LOG_CONFIGURE ON
  357. LOG_BUILD ON
  358. DEPENDS ${sylvan_dep}
  359. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  360. )
  361. ExternalProject_Get_Property(sylvan source_dir)
  362. ExternalProject_Get_Property(sylvan binary_dir)
  363. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  364. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  365. message(STATUS "Storm - Using shipped version of sylvan.")
  366. message(STATUS "Storm - Linking with sylvan.")
  367. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  368. add_dependencies(sylvan_STATIC sylvan)
  369. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  370. find_package(Hwloc QUIET REQUIRED)
  371. if(HWLOC_FOUND)
  372. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  373. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  374. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  375. else()
  376. if(${OPERATING_SYSTEM} MATCHES "Linux")
  377. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  378. endif()
  379. endif()
  380. #############################################################
  381. ##
  382. ## cpptemplate
  383. ##
  384. #############################################################
  385. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  386. list(APPEND STORM_DEP_TARGETS CppTemplate)
  387. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  388. #############################################################
  389. ##
  390. ## Google Test gtest
  391. ##
  392. #############################################################
  393. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  394. ExternalProject_Add(
  395. googletest
  396. #For downloads (may be useful later!)
  397. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  398. #TIMEOUT 10
  399. DOWNLOAD_COMMAND ""
  400. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  401. # Force the same output paths for debug and release builds so that
  402. # we know in which place the binaries end up when using the Xcode generator
  403. 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}
  404. # Disable install step
  405. INSTALL_COMMAND ""
  406. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  407. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  408. # Wrap download, configure and build steps in a script to log output
  409. LOG_CONFIGURE ON
  410. LOG_BUILD ON
  411. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  412. )
  413. # Specify include dir
  414. ExternalProject_Get_Property(googletest source_dir)
  415. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  416. # Specify MainTest's link libraries
  417. ExternalProject_Get_Property(googletest binary_dir)
  418. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  419. add_dependencies(test-resources googletest)
  420. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  421. #############################################################
  422. ##
  423. ## Intel Threading Building Blocks (optional)
  424. ##
  425. #############################################################
  426. set(STORM_HAVE_INTELTBB OFF)
  427. if (STORM_USE_INTELTBB)
  428. find_package(TBB QUIET REQUIRED)
  429. if (TBB_FOUND)
  430. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  431. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  432. set(STORM_HAVE_INTELTBB ON)
  433. link_directories(${TBB_LIBRARY_DIRS})
  434. include_directories(${TBB_INCLUDE_DIRS})
  435. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  436. else(TBB_FOUND)
  437. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  438. endif(TBB_FOUND)
  439. endif(STORM_USE_INTELTBB)
  440. #############################################################
  441. ##
  442. ## Threads
  443. ##
  444. #############################################################
  445. find_package(Threads QUIET REQUIRED)
  446. if (NOT Threads_FOUND)
  447. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  448. endif()
  449. include_directories(${THREADS_INCLUDE_DIRS})
  450. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  451. if (STORM_USE_COTIRE)
  452. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  453. endif(STORM_USE_COTIRE)
  454. #############################################################
  455. ##
  456. ## CUDA Library generation
  457. ##
  458. #############################################################
  459. if ("${CUDA_ROOT}" STREQUAL "")
  460. set(ENABLE_CUDA OFF)
  461. else()
  462. set(ENABLE_CUDA ON)
  463. endif()
  464. # CUDA Defines
  465. if (ENABLE_CUDA)
  466. set(STORM_CPP_CUDA_DEF "define")
  467. else()
  468. set(STORM_CPP_CUDA_DEF "undef")
  469. endif()
  470. # CUDA Defines
  471. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  472. if(ENABLE_CUDA)
  473. # Test for type alignment
  474. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  475. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  476. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  477. )
  478. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  479. 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}")
  480. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  481. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  482. else()
  483. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  484. endif()
  485. # Test for Float 64bit Alignment
  486. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  487. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  488. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  489. )
  490. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  491. 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}")
  492. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  493. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  494. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  495. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  496. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  497. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  498. else()
  499. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  500. endif()
  501. #
  502. # Make a version file containing the current version from git.
  503. #
  504. include(GetGitRevisionDescription)
  505. git_describe_checkout(STORM_GIT_VERSION_STRING)
  506. # Parse the git Tag into variables
  507. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  508. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  509. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  510. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  511. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  512. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  513. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  514. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  515. else()
  516. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  517. endif()
  518. 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})")
  519. # Configure a header file to pass some of the CMake settings to the source code
  520. configure_file (
  521. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  522. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  523. )
  524. #create library
  525. find_package(CUDA REQUIRED)
  526. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  527. find_package(Cusp REQUIRED)
  528. find_package(Thrust REQUIRED)
  529. set(STORM_CUDA_LIB_NAME "storm-cuda")
  530. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  531. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  532. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  533. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  534. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  535. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  536. #############################################################
  537. ##
  538. ## CUSP
  539. ##
  540. #############################################################
  541. if(CUSP_FOUND)
  542. include_directories(${CUSP_INCLUDE_DIR})
  543. cuda_include_directories(${CUSP_INCLUDE_DIR})
  544. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  545. else()
  546. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  547. endif()
  548. #############################################################
  549. ##
  550. ## Thrust
  551. ##
  552. #############################################################
  553. if(THRUST_FOUND)
  554. include_directories(${THRUST_INCLUDE_DIR})
  555. cuda_include_directories(${THRUST_INCLUDE_DIR})
  556. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  557. else()
  558. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  559. endif()
  560. include_directories(${CUDA_INCLUDE_DIRS})
  561. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  562. cuda_add_library(${STORM_CUDA_LIB_NAME}
  563. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  564. )
  565. message (STATUS "Storm - Linking with CUDA.")
  566. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  567. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  568. endif()
  569. 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)