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.

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