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.

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