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.

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