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.

688 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. # 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_MINYEAR 17)
  179. set(CARL_MINMONTH 08)
  180. set(CARL_MINPATCH 0)
  181. if (NOT STORM_FORCE_SHIPPED_CARL)
  182. if (NOT "${STORM_CARL_DIR_HINT}" STREQUAL "")
  183. find_package(carl QUIET PATHS ${STORM_CARL_DIR_HINT} NO_DEFAULT_PATH)
  184. endif()
  185. if (NOT carl_FOUND)
  186. find_package(carl QUIET)
  187. endif()
  188. endif()
  189. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  190. get_target_property(carlLOCATION lib_carl LOCATION)
  191. if(${carlLOCATION} STREQUAL "carlLOCATION-NOTFOUND")
  192. message(SEND_ERROR "Library location for carl is not found, did you build carl?")
  193. elseif(EXISTS ${carlLOCATION})
  194. #empty on purpose
  195. else()
  196. message(SEND_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  197. endif()
  198. if("${carl_MINORYEARVERSION}" STREQUAL "" OR "${carl_MINORMONTHVERSION}" STREQUAL "" OR "${carl_MAINTENANCEVERSION}" STREQUAL "")
  199. # don't have detailed version information, probably an old version of carl
  200. message(FATAL_ERROR "Carl at ${carlLOCATION} outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  201. endif()
  202. if(${carl_MINORYEARVERSION} LESS ${CARL_MINYEAR})
  203. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  204. elseif(${carl_MINORYEARVERSION} EQUAL ${CARL_MINYEAR})
  205. if(${carl_MINORMONTHVERSION} LESS ${CARL_MINMONTH})
  206. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  207. elseif(${carl_MINORMONTHVERSION} EQUAL ${CARL_MINMONTH})
  208. if(${carl_MAINTENANCEVERSION} LESS ${CARL_MINPATCH})
  209. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  210. endif()
  211. endif()
  212. endif()
  213. set(STORM_SHIPPED_CARL OFF)
  214. set(STORM_HAVE_CARL ON)
  215. message(STATUS "Storm - Use system version of carl.")
  216. 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}).")
  217. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  218. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  219. else()
  220. set(STORM_SHIPPED_CARL ON)
  221. # The first external project will be built at *configure stage*
  222. message("START CARL CONFIG PROCESS")
  223. file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
  224. execute_process(
  225. 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}"
  226. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  227. OUTPUT_VARIABLE carlconfig_out
  228. RESULT_VARIABLE carlconfig_result)
  229. if(NOT carlconfig_result)
  230. message("${carlconfig_out}")
  231. endif()
  232. execute_process(
  233. COMMAND ${CMAKE_COMMAND} --build . --target carl-config
  234. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  235. OUTPUT_VARIABLE carlconfig_out
  236. RESULT_VARIABLE carlconfig_result
  237. )
  238. if(NOT carlconfig_result)
  239. message("${carlconfig_out}")
  240. endif()
  241. message("END CARL CONFIG PROCESS")
  242. message(STATUS "Storm - Using shipped version of carl.")
  243. ExternalProject_Add(
  244. carl
  245. SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl
  246. CONFIGURE_COMMAND ""
  247. BUILD_IN_SOURCE 1
  248. BUILD_COMMAND make lib_carl
  249. INSTALL_COMMAND make install
  250. LOG_BUILD ON
  251. LOG_INSTALL ON
  252. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}
  253. )
  254. include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake)
  255. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  256. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  257. add_dependencies(resources carl)
  258. set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/")
  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. ## Xerces
  349. ##
  350. #############################################################
  351. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  352. #############################################################
  353. ##
  354. ## Sylvan
  355. ##
  356. #############################################################
  357. if(STORM_SHIPPED_CARL)
  358. set(sylvan_dep carl)
  359. else()
  360. set(sylvan_dep lib_carl)
  361. endif()
  362. if (STORM_DEBUG_SYLVAN)
  363. set(SYLVAN_BUILD_TYPE "Debug")
  364. else()
  365. set(SYLVAN_BUILD_TYPE "Release")
  366. endif()
  367. ExternalProject_Add(
  368. sylvan
  369. DOWNLOAD_COMMAND ""
  370. PREFIX "sylvan"
  371. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  372. 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
  373. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  374. BUILD_IN_SOURCE 0
  375. INSTALL_COMMAND ""
  376. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  377. LOG_CONFIGURE ON
  378. LOG_BUILD ON
  379. DEPENDS ${sylvan_dep}
  380. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  381. )
  382. ExternalProject_Get_Property(sylvan source_dir)
  383. ExternalProject_Get_Property(sylvan binary_dir)
  384. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  385. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  386. message(STATUS "Storm - Using shipped version of sylvan.")
  387. message(STATUS "Storm - Linking with sylvan.")
  388. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  389. add_dependencies(sylvan_STATIC sylvan)
  390. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  391. find_package(Hwloc QUIET REQUIRED)
  392. if(HWLOC_FOUND)
  393. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  394. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  395. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  396. else()
  397. if(${OPERATING_SYSTEM} MATCHES "Linux")
  398. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  399. endif()
  400. endif()
  401. #############################################################
  402. ##
  403. ## cpptemplate
  404. ##
  405. #############################################################
  406. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  407. list(APPEND STORM_DEP_TARGETS CppTemplate)
  408. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  409. #############################################################
  410. ##
  411. ## Google Test gtest
  412. ##
  413. #############################################################
  414. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  415. ExternalProject_Add(
  416. googletest
  417. #For downloads (may be useful later!)
  418. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  419. #TIMEOUT 10
  420. DOWNLOAD_COMMAND ""
  421. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  422. # Force the same output paths for debug and release builds so that
  423. # we know in which place the binaries end up when using the Xcode generator
  424. 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}
  425. # Disable install step
  426. INSTALL_COMMAND ""
  427. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  428. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  429. # Wrap download, configure and build steps in a script to log output
  430. LOG_CONFIGURE ON
  431. LOG_BUILD ON
  432. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  433. )
  434. # Specify include dir
  435. ExternalProject_Get_Property(googletest source_dir)
  436. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  437. # Specify MainTest's link libraries
  438. ExternalProject_Get_Property(googletest binary_dir)
  439. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  440. add_dependencies(test-resources googletest)
  441. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  442. #############################################################
  443. ##
  444. ## Intel Threading Building Blocks (optional)
  445. ##
  446. #############################################################
  447. set(STORM_HAVE_INTELTBB OFF)
  448. if (STORM_USE_INTELTBB)
  449. find_package(TBB QUIET REQUIRED)
  450. if (TBB_FOUND)
  451. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  452. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  453. set(STORM_HAVE_INTELTBB ON)
  454. link_directories(${TBB_LIBRARY_DIRS})
  455. include_directories(${TBB_INCLUDE_DIRS})
  456. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  457. else(TBB_FOUND)
  458. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  459. endif(TBB_FOUND)
  460. endif(STORM_USE_INTELTBB)
  461. #############################################################
  462. ##
  463. ## Threads
  464. ##
  465. #############################################################
  466. find_package(Threads QUIET REQUIRED)
  467. if (NOT Threads_FOUND)
  468. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  469. endif()
  470. include_directories(${THREADS_INCLUDE_DIRS})
  471. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  472. if (STORM_USE_COTIRE)
  473. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  474. endif(STORM_USE_COTIRE)
  475. #############################################################
  476. ##
  477. ## CUDA Library generation
  478. ##
  479. #############################################################
  480. if ("${CUDA_ROOT}" STREQUAL "")
  481. set(ENABLE_CUDA OFF)
  482. else()
  483. set(ENABLE_CUDA ON)
  484. endif()
  485. # CUDA Defines
  486. if (ENABLE_CUDA)
  487. set(STORM_CPP_CUDA_DEF "define")
  488. else()
  489. set(STORM_CPP_CUDA_DEF "undef")
  490. endif()
  491. # CUDA Defines
  492. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  493. if(ENABLE_CUDA)
  494. # Test for type alignment
  495. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  496. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  497. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  498. )
  499. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  500. 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}")
  501. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  502. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  503. else()
  504. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  505. endif()
  506. # Test for Float 64bit Alignment
  507. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  508. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  509. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  510. )
  511. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  512. 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}")
  513. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  514. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  515. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  516. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  517. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  518. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  519. else()
  520. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  521. endif()
  522. #
  523. # Make a version file containing the current version from git.
  524. #
  525. include(GetGitRevisionDescription)
  526. git_describe_checkout(STORM_GIT_VERSION_STRING)
  527. # Parse the git Tag into variables
  528. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  529. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  530. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  531. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  532. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  533. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  534. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  535. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  536. else()
  537. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  538. endif()
  539. 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})")
  540. # Configure a header file to pass some of the CMake settings to the source code
  541. configure_file (
  542. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  543. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  544. )
  545. #create library
  546. find_package(CUDA REQUIRED)
  547. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  548. find_package(Cusp REQUIRED)
  549. find_package(Thrust REQUIRED)
  550. set(STORM_CUDA_LIB_NAME "storm-cuda")
  551. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  552. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  553. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  554. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  555. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  556. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  557. #############################################################
  558. ##
  559. ## CUSP
  560. ##
  561. #############################################################
  562. if(CUSP_FOUND)
  563. include_directories(${CUSP_INCLUDE_DIR})
  564. cuda_include_directories(${CUSP_INCLUDE_DIR})
  565. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  566. else()
  567. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  568. endif()
  569. #############################################################
  570. ##
  571. ## Thrust
  572. ##
  573. #############################################################
  574. if(THRUST_FOUND)
  575. include_directories(${THRUST_INCLUDE_DIR})
  576. cuda_include_directories(${THRUST_INCLUDE_DIR})
  577. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  578. else()
  579. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  580. endif()
  581. include_directories(${CUDA_INCLUDE_DIRS})
  582. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  583. cuda_add_library(${STORM_CUDA_LIB_NAME}
  584. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  585. )
  586. message (STATUS "Storm - Linking with CUDA.")
  587. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  588. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  589. endif()
  590. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})