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.

675 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_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/")
  246. set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  247. set(STORM_HAVE_CARL ON)
  248. 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}).")
  249. # install the carl dynamic library if we built it
  250. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  251. endif()
  252. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  253. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  254. endif()
  255. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  256. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  257. endif()
  258. # The library that needs symbols must be first, then the library that resolves the symbol.
  259. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  260. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  261. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  262. endif()
  263. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  264. #############################################################
  265. ##
  266. ## SMT-RAT
  267. ##
  268. #############################################################
  269. set(STORM_HAVE_SMTRAT OFF)
  270. if(USE_SMTRAT)
  271. find_package(smtrat QUIET REQUIRED)
  272. if(smtrat_FOUND)
  273. set(STORM_HAVE_SMTRAT ON)
  274. message(STATUS "Storm - Linking with smtrat.")
  275. include_directories("${smtrat_INCLUDE_DIR}")
  276. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  277. else()
  278. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  279. endif()
  280. endif()
  281. #############################################################
  282. ##
  283. ## HyPro
  284. ##
  285. #############################################################
  286. set(STORM_HAVE_HYPRO OFF)
  287. if(USE_HYPRO)
  288. find_package(hypro QUIET REQUIRED)
  289. if(hypro_FOUND)
  290. set(STORM_HAVE_HYPRO ON)
  291. message(STATUS "Storm - Linking with hypro.")
  292. include_directories("${hypro_INCLUDE_DIR}")
  293. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  294. else()
  295. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  296. endif()
  297. endif()
  298. #############################################################
  299. ##
  300. ## gmp
  301. ##
  302. #############################################################
  303. #
  304. #find_package(GMP QUIET REQUIRED)
  305. #
  306. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  307. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  308. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  309. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  310. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  311. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  312. #message(STATUS "Storm - Linking with gmp.")
  313. #include_directories("${GMP_INCLUDE_DIR}")
  314. #list(APPEND STORM_LINK_LIBRARIES ${GMP_LIBRARY})
  315. #############################################################
  316. ##
  317. ## MathSAT (optional)
  318. ##
  319. #############################################################
  320. if ("${MSAT_ROOT}" STREQUAL "")
  321. set(ENABLE_MSAT OFF)
  322. else()
  323. set(ENABLE_MSAT ON)
  324. endif()
  325. # MathSAT Defines
  326. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  327. if (ENABLE_MSAT)
  328. message (STATUS "Storm - Linking with MathSAT.")
  329. find_library(MSAT_LIB mathsat PATHS "${MSAT_ROOT}/lib")
  330. add_imported_library(msat SHARED ${MSAT_LIB} "${MSAT_ROOT}/include")
  331. list(APPEND STORM_DEP_TARGETS msat_SHARED)
  332. endif(ENABLE_MSAT)
  333. #############################################################
  334. ##
  335. ## Xerces
  336. ##
  337. #############################################################
  338. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  339. #############################################################
  340. ##
  341. ## Sylvan
  342. ##
  343. #############################################################
  344. if(STORM_SHIPPED_CARL)
  345. set(sylvan_dep carl)
  346. else()
  347. set(sylvan_dep lib_carl)
  348. endif()
  349. if (STORM_DEBUG_SYLVAN)
  350. set(SYLVAN_BUILD_TYPE "Debug")
  351. else()
  352. set(SYLVAN_BUILD_TYPE "Release")
  353. endif()
  354. ExternalProject_Add(
  355. sylvan
  356. DOWNLOAD_COMMAND ""
  357. PREFIX "sylvan"
  358. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  359. 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
  360. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  361. BUILD_IN_SOURCE 0
  362. INSTALL_COMMAND ""
  363. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  364. LOG_CONFIGURE ON
  365. LOG_BUILD ON
  366. DEPENDS ${sylvan_dep}
  367. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  368. )
  369. ExternalProject_Get_Property(sylvan source_dir)
  370. ExternalProject_Get_Property(sylvan binary_dir)
  371. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  372. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  373. message(STATUS "Storm - Using shipped version of sylvan.")
  374. message(STATUS "Storm - Linking with sylvan.")
  375. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  376. add_dependencies(sylvan_STATIC sylvan)
  377. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  378. find_package(Hwloc QUIET REQUIRED)
  379. if(HWLOC_FOUND)
  380. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  381. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  382. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  383. else()
  384. if(${OPERATING_SYSTEM} MATCHES "Linux")
  385. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  386. endif()
  387. endif()
  388. #############################################################
  389. ##
  390. ## cpptemplate
  391. ##
  392. #############################################################
  393. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  394. list(APPEND STORM_DEP_TARGETS CppTemplate)
  395. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  396. #############################################################
  397. ##
  398. ## Google Test gtest
  399. ##
  400. #############################################################
  401. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  402. ExternalProject_Add(
  403. googletest
  404. #For downloads (may be useful later!)
  405. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  406. #TIMEOUT 10
  407. DOWNLOAD_COMMAND ""
  408. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  409. # Force the same output paths for debug and release builds so that
  410. # we know in which place the binaries end up when using the Xcode generator
  411. 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}
  412. # Disable install step
  413. INSTALL_COMMAND ""
  414. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  415. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  416. # Wrap download, configure and build steps in a script to log output
  417. LOG_CONFIGURE ON
  418. LOG_BUILD ON
  419. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  420. )
  421. # Specify include dir
  422. ExternalProject_Get_Property(googletest source_dir)
  423. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  424. # Specify MainTest's link libraries
  425. ExternalProject_Get_Property(googletest binary_dir)
  426. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  427. add_dependencies(test-resources googletest)
  428. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  429. #############################################################
  430. ##
  431. ## Intel Threading Building Blocks (optional)
  432. ##
  433. #############################################################
  434. set(STORM_HAVE_INTELTBB OFF)
  435. if (STORM_USE_INTELTBB)
  436. find_package(TBB QUIET REQUIRED)
  437. if (TBB_FOUND)
  438. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  439. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  440. set(STORM_HAVE_INTELTBB ON)
  441. link_directories(${TBB_LIBRARY_DIRS})
  442. include_directories(${TBB_INCLUDE_DIRS})
  443. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  444. else(TBB_FOUND)
  445. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  446. endif(TBB_FOUND)
  447. endif(STORM_USE_INTELTBB)
  448. #############################################################
  449. ##
  450. ## Threads
  451. ##
  452. #############################################################
  453. find_package(Threads QUIET REQUIRED)
  454. if (NOT Threads_FOUND)
  455. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  456. endif()
  457. include_directories(${THREADS_INCLUDE_DIRS})
  458. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  459. if (STORM_USE_COTIRE)
  460. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  461. endif(STORM_USE_COTIRE)
  462. #############################################################
  463. ##
  464. ## CUDA Library generation
  465. ##
  466. #############################################################
  467. if ("${CUDA_ROOT}" STREQUAL "")
  468. set(ENABLE_CUDA OFF)
  469. else()
  470. set(ENABLE_CUDA ON)
  471. endif()
  472. # CUDA Defines
  473. if (ENABLE_CUDA)
  474. set(STORM_CPP_CUDA_DEF "define")
  475. else()
  476. set(STORM_CPP_CUDA_DEF "undef")
  477. endif()
  478. # CUDA Defines
  479. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  480. if(ENABLE_CUDA)
  481. # Test for type alignment
  482. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  483. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  484. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  485. )
  486. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  487. 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}")
  488. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  489. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  490. else()
  491. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  492. endif()
  493. # Test for Float 64bit Alignment
  494. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  495. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  496. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  497. )
  498. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  499. 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}")
  500. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  501. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  502. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  503. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  504. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  505. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  506. else()
  507. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  508. endif()
  509. #
  510. # Make a version file containing the current version from git.
  511. #
  512. include(GetGitRevisionDescription)
  513. git_describe_checkout(STORM_GIT_VERSION_STRING)
  514. # Parse the git Tag into variables
  515. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  516. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  517. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  518. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  519. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  520. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  521. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  522. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  523. else()
  524. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  525. endif()
  526. 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})")
  527. # Configure a header file to pass some of the CMake settings to the source code
  528. configure_file (
  529. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  530. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  531. )
  532. #create library
  533. find_package(CUDA REQUIRED)
  534. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  535. find_package(Cusp REQUIRED)
  536. find_package(Thrust REQUIRED)
  537. set(STORM_CUDA_LIB_NAME "storm-cuda")
  538. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  539. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  540. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  541. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  542. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  543. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  544. #############################################################
  545. ##
  546. ## CUSP
  547. ##
  548. #############################################################
  549. if(CUSP_FOUND)
  550. include_directories(${CUSP_INCLUDE_DIR})
  551. cuda_include_directories(${CUSP_INCLUDE_DIR})
  552. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  553. else()
  554. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  555. endif()
  556. #############################################################
  557. ##
  558. ## Thrust
  559. ##
  560. #############################################################
  561. if(THRUST_FOUND)
  562. include_directories(${THRUST_INCLUDE_DIR})
  563. cuda_include_directories(${THRUST_INCLUDE_DIR})
  564. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  565. else()
  566. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  567. endif()
  568. include_directories(${CUDA_INCLUDE_DIRS})
  569. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  570. cuda_add_library(${STORM_CUDA_LIB_NAME}
  571. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  572. )
  573. message (STATUS "Storm - Linking with CUDA.")
  574. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  575. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  576. endif()
  577. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})