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.

687 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. #############################################################
  27. ##
  28. ## gmm
  29. ##
  30. #############################################################
  31. add_imported_library_interface(gmm "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.2/include")
  32. list(APPEND STORM_DEP_TARGETS gmm)
  33. #############################################################
  34. ##
  35. ## Eigen
  36. ##
  37. #############################################################
  38. add_imported_library_interface(StormEigen33 "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1")
  39. list(APPEND STORM_DEP_TARGETS StormEigen33)
  40. #############################################################
  41. ##
  42. ## Boost
  43. ##
  44. #############################################################
  45. # Boost Option variables
  46. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  47. set(Boost_USE_MULTITHREADED ON)
  48. set(Boost_USE_STATIC_RUNTIME OFF)
  49. find_package(Boost 1.61.0 QUIET REQUIRED COMPONENTS filesystem system)
  50. if (NOT Boost_FOUND)
  51. if (Boost_VERSION)
  52. message(FATAL_ERROR "The required Boost version is 1.61.0 or newer, however, only ${Boost_VERSION} was found.")
  53. else ()
  54. message(FATAL_ERROR "Boost was not found.")
  55. endif ()
  56. endif ()
  57. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  58. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  59. endif ()
  60. set(CNTVAR 1)
  61. foreach(BOOSTLIB ${Boost_LIBRARIES})
  62. add_imported_library(target-boost-${CNTVAR} SHARED ${BOOSTLIB} ${Boost_INCLUDE_DIRS})
  63. list(APPEND STORM_DEP_TARGETS target-boost-${CNTVAR}_SHARED)
  64. MATH(EXPR CNTVAR "${CNTVAR}+1")
  65. endforeach()
  66. message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).")
  67. # set the information for the config header
  68. set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}")
  69. #############################################################
  70. ##
  71. ## ExprTk
  72. ##
  73. #############################################################
  74. # Use the shipped version of ExprTK
  75. message (STATUS "Storm - Including ExprTk.")
  76. add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  77. list(APPEND STORM_DEP_TARGETS ExprTk)
  78. #############################################################
  79. ##
  80. ## Sparsepp
  81. ##
  82. #############################################################
  83. # Use the shipped version of Sparsepp
  84. message (STATUS "Storm - Including Sparsepp.")
  85. set(SPARSEPP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp")
  86. file(GLOB SPARSEPP_HEADERS "${SPARSEPP_INCLUDE_DIR}/*.h")
  87. # Add the sparsepp headers to the headers that are copied to the include directory in the build directory.
  88. set(SPARSEPP_BINDIR_DIR ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp)
  89. include_directories("${SPARSEPP_BINDIR_DIR}")
  90. foreach(HEADER ${SPARSEPP_HEADERS})
  91. string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER})
  92. string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH})
  93. string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH})
  94. add_custom_command(
  95. OUTPUT ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  96. COMMAND ${CMAKE_COMMAND} -E make_directory ${SPARSEPP_BINDIR_DIR}/sparsepp
  97. COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  98. DEPENDS ${SPARSEPP_INCLUDE_DIR}/${HEADER_FILENAME}
  99. )
  100. list(APPEND SPARSEPP_BINDIR_HEADERS ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME})
  101. endforeach()
  102. #############################################################
  103. ##
  104. ## ModernJSON
  105. ##
  106. #############################################################
  107. #use the shipped version of modernjson
  108. message (STATUS "Storm - Including ModernJSON.")
  109. add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/")
  110. list(APPEND STORM_DEP_TARGETS ModernJSON)
  111. #############################################################
  112. ##
  113. ## Z3 (optional)
  114. ##
  115. #############################################################
  116. find_package(Z3 QUIET)
  117. # Z3 Defines
  118. set(STORM_HAVE_Z3 ${Z3_FOUND})
  119. if(Z3_FOUND)
  120. # Check whether the version of z3 supports optimization
  121. if (Z3_EXEC)
  122. execute_process (COMMAND ${Z3_EXEC} -version
  123. OUTPUT_VARIABLE z3_version_output
  124. ERROR_QUIET
  125. OUTPUT_STRIP_TRAILING_WHITESPACE)
  126. if (z3_version_output MATCHES "([0-9]*\\.[0-9]*\\.[0-9]*)")
  127. set(Z3_VERSION "${CMAKE_MATCH_1}")
  128. if(NOT "${Z3_VERSION}" VERSION_LESS "4.5.0")
  129. set(STORM_HAVE_Z3_OPTIMIZE ON)
  130. endif()
  131. endif()
  132. endif()
  133. if(STORM_HAVE_Z3_OPTIMIZE)
  134. message (STATUS "Storm - Linking with Z3. (Z3 version supports optimization)")
  135. else()
  136. message (STATUS "Storm - Linking with Z3. (Z3 version does not support optimization)")
  137. endif()
  138. add_imported_library(z3 SHARED ${Z3_LIBRARIES} ${Z3_INCLUDE_DIRS})
  139. list(APPEND STORM_DEP_TARGETS z3_SHARED)
  140. else()
  141. message (WARNING "Storm - Z3 not found. Building of Prism/JANI models will not be supported.")
  142. endif(Z3_FOUND)
  143. #############################################################
  144. ##
  145. ## glpk
  146. ##
  147. #############################################################
  148. include(${STORM_3RDPARTY_SOURCE_DIR}/include_glpk.cmake)
  149. #############################################################
  150. ##
  151. ## Gurobi (optional)
  152. ##
  153. #############################################################
  154. if (STORM_USE_GUROBI)
  155. find_package(Gurobi QUIET REQUIRED)
  156. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  157. if (GUROBI_FOUND)
  158. message (STATUS "Storm - Linking with Gurobi.")
  159. add_imported_library(Gurobi SHARED ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS})
  160. list(APPEND STORM_DEP_TARGETS Gurobi_SHARED)
  161. endif()
  162. else()
  163. set(STORM_HAVE_GUROBI OFF)
  164. endif()
  165. #############################################################
  166. ##
  167. ## CUDD
  168. ##
  169. #############################################################
  170. include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake)
  171. #############################################################
  172. ##
  173. ## carl
  174. ##
  175. #############################################################
  176. set(STORM_HAVE_CARL OFF)
  177. set(CARL_MINYEAR 17)
  178. set(CARL_MINMONTH 08)
  179. set(CARL_MINPATCH 0)
  180. if (NOT STORM_FORCE_SHIPPED_CARL)
  181. if (NOT "${STORM_CARL_DIR_HINT}" STREQUAL "")
  182. find_package(carl QUIET PATHS ${STORM_CARL_DIR_HINT} NO_DEFAULT_PATH)
  183. endif()
  184. if (NOT carl_FOUND)
  185. find_package(carl QUIET)
  186. endif()
  187. endif()
  188. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  189. get_target_property(carlLOCATION lib_carl LOCATION)
  190. if(${carlLOCATION} STREQUAL "carlLOCATION-NOTFOUND")
  191. message(SEND_ERROR "Library location for carl is not found, did you build carl?")
  192. elseif(EXISTS ${carlLOCATION})
  193. #empty on purpose
  194. else()
  195. message(SEND_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  196. endif()
  197. if("${carl_MINORYEARVERSION}" STREQUAL "" OR "${carl_MINORMONTHVERSION}" STREQUAL "" OR "${carl_MAINTENANCEVERSION}" STREQUAL "")
  198. # don't have detailed version information, probably an old version of carl
  199. message(FATAL_ERROR "Carl at ${carlLOCATION} outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  200. endif()
  201. if(${carl_MINORYEARVERSION} LESS ${CARL_MINYEAR})
  202. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  203. elseif(${carl_MINORYEARVERSION} EQUAL ${CARL_MINYEAR})
  204. if(${carl_MINORMONTHVERSION} LESS ${CARL_MINMONTH})
  205. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  206. elseif(${carl_MINORMONTHVERSION} EQUAL ${CARL_MINMONTH})
  207. if(${carl_MAINTENANCEVERSION} LESS ${CARL_MINPATCH})
  208. message(SEND_ERROR "Carl outdated, require ${CARL_MINYEAR}.${CARL_MINMONTH}.${CARL_MINPATCH}, have ${carl_VERSION}")
  209. endif()
  210. endif()
  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("START CARL 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("${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("${carlconfig_out}")
  239. endif()
  240. message("END CARL 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_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  259. set(STORM_HAVE_CARL ON)
  260. 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}).")
  261. # install the carl dynamic library if we built it
  262. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  263. endif()
  264. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  265. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  266. endif()
  267. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  268. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  269. endif()
  270. # The library that needs symbols must be first, then the library that resolves the symbol.
  271. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  272. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  273. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  274. endif()
  275. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  276. #############################################################
  277. ##
  278. ## SMT-RAT
  279. ##
  280. #############################################################
  281. set(STORM_HAVE_SMTRAT OFF)
  282. if(USE_SMTRAT)
  283. find_package(smtrat QUIET REQUIRED)
  284. if(smtrat_FOUND)
  285. set(STORM_HAVE_SMTRAT ON)
  286. message(STATUS "Storm - Linking with smtrat.")
  287. include_directories("${smtrat_INCLUDE_DIR}")
  288. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  289. else()
  290. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  291. endif()
  292. endif()
  293. #############################################################
  294. ##
  295. ## HyPro
  296. ##
  297. #############################################################
  298. set(STORM_HAVE_HYPRO OFF)
  299. if(USE_HYPRO)
  300. find_package(hypro QUIET REQUIRED)
  301. if(hypro_FOUND)
  302. set(STORM_HAVE_HYPRO ON)
  303. message(STATUS "Storm - Linking with hypro.")
  304. include_directories("${hypro_INCLUDE_DIR}")
  305. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  306. else()
  307. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  308. endif()
  309. endif()
  310. #############################################################
  311. ##
  312. ## gmp
  313. ##
  314. #############################################################
  315. #
  316. #find_package(GMP QUIET REQUIRED)
  317. #
  318. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  319. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  320. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  321. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  322. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  323. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  324. #message(STATUS "Storm - Linking with gmp.")
  325. #include_directories("${GMP_INCLUDE_DIR}")
  326. #list(APPEND STORM_LINK_LIBRARIES ${GMP_LIBRARY})
  327. #############################################################
  328. ##
  329. ## MathSAT (optional)
  330. ##
  331. #############################################################
  332. if ("${MSAT_ROOT}" STREQUAL "")
  333. set(ENABLE_MSAT OFF)
  334. else()
  335. set(ENABLE_MSAT ON)
  336. endif()
  337. # MathSAT Defines
  338. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  339. if (ENABLE_MSAT)
  340. message (STATUS "Storm - Linking with MathSAT.")
  341. find_library(MSAT_LIB mathsat PATHS "${MSAT_ROOT}/lib")
  342. add_imported_library(msat SHARED ${MSAT_LIB} "${MSAT_ROOT}/include")
  343. list(APPEND STORM_DEP_TARGETS msat_SHARED)
  344. endif(ENABLE_MSAT)
  345. #############################################################
  346. ##
  347. ## Xerces
  348. ##
  349. #############################################################
  350. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  351. #############################################################
  352. ##
  353. ## Sylvan
  354. ##
  355. #############################################################
  356. if(STORM_SHIPPED_CARL)
  357. set(sylvan_dep carl)
  358. else()
  359. set(sylvan_dep lib_carl)
  360. endif()
  361. if (STORM_DEBUG_SYLVAN)
  362. set(SYLVAN_BUILD_TYPE "Debug")
  363. else()
  364. set(SYLVAN_BUILD_TYPE "Release")
  365. endif()
  366. ExternalProject_Add(
  367. sylvan
  368. DOWNLOAD_COMMAND ""
  369. PREFIX "sylvan"
  370. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  371. 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
  372. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  373. BUILD_IN_SOURCE 0
  374. INSTALL_COMMAND ""
  375. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  376. LOG_CONFIGURE ON
  377. LOG_BUILD ON
  378. DEPENDS ${sylvan_dep}
  379. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  380. )
  381. ExternalProject_Get_Property(sylvan source_dir)
  382. ExternalProject_Get_Property(sylvan binary_dir)
  383. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  384. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  385. message(STATUS "Storm - Using shipped version of sylvan.")
  386. message(STATUS "Storm - Linking with sylvan.")
  387. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  388. add_dependencies(sylvan_STATIC sylvan)
  389. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  390. find_package(Hwloc QUIET REQUIRED)
  391. if(HWLOC_FOUND)
  392. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  393. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  394. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  395. else()
  396. if(${OPERATING_SYSTEM} MATCHES "Linux")
  397. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  398. endif()
  399. endif()
  400. #############################################################
  401. ##
  402. ## cpptemplate
  403. ##
  404. #############################################################
  405. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  406. list(APPEND STORM_DEP_TARGETS CppTemplate)
  407. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  408. #############################################################
  409. ##
  410. ## Google Test gtest
  411. ##
  412. #############################################################
  413. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  414. ExternalProject_Add(
  415. googletest
  416. #For downloads (may be useful later!)
  417. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  418. #TIMEOUT 10
  419. DOWNLOAD_COMMAND ""
  420. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  421. # Force the same output paths for debug and release builds so that
  422. # we know in which place the binaries end up when using the Xcode generator
  423. 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}
  424. # Disable install step
  425. INSTALL_COMMAND ""
  426. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  427. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  428. # Wrap download, configure and build steps in a script to log output
  429. LOG_CONFIGURE ON
  430. LOG_BUILD ON
  431. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  432. )
  433. # Specify include dir
  434. ExternalProject_Get_Property(googletest source_dir)
  435. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  436. # Specify MainTest's link libraries
  437. ExternalProject_Get_Property(googletest binary_dir)
  438. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  439. add_dependencies(test-resources googletest)
  440. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  441. #############################################################
  442. ##
  443. ## Intel Threading Building Blocks (optional)
  444. ##
  445. #############################################################
  446. set(STORM_HAVE_INTELTBB OFF)
  447. if (STORM_USE_INTELTBB)
  448. find_package(TBB QUIET REQUIRED)
  449. if (TBB_FOUND)
  450. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  451. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  452. set(STORM_HAVE_INTELTBB ON)
  453. link_directories(${TBB_LIBRARY_DIRS})
  454. include_directories(${TBB_INCLUDE_DIRS})
  455. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  456. else(TBB_FOUND)
  457. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  458. endif(TBB_FOUND)
  459. endif(STORM_USE_INTELTBB)
  460. #############################################################
  461. ##
  462. ## Threads
  463. ##
  464. #############################################################
  465. find_package(Threads QUIET REQUIRED)
  466. if (NOT Threads_FOUND)
  467. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  468. endif()
  469. include_directories(${THREADS_INCLUDE_DIRS})
  470. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  471. if (STORM_USE_COTIRE)
  472. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  473. endif(STORM_USE_COTIRE)
  474. #############################################################
  475. ##
  476. ## CUDA Library generation
  477. ##
  478. #############################################################
  479. if ("${CUDA_ROOT}" STREQUAL "")
  480. set(ENABLE_CUDA OFF)
  481. else()
  482. set(ENABLE_CUDA ON)
  483. endif()
  484. # CUDA Defines
  485. if (ENABLE_CUDA)
  486. set(STORM_CPP_CUDA_DEF "define")
  487. else()
  488. set(STORM_CPP_CUDA_DEF "undef")
  489. endif()
  490. # CUDA Defines
  491. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  492. if(ENABLE_CUDA)
  493. # Test for type alignment
  494. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  495. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  496. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  497. )
  498. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  499. 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}")
  500. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  501. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  502. else()
  503. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  504. endif()
  505. # Test for Float 64bit Alignment
  506. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  507. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  508. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  509. )
  510. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  511. 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}")
  512. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  513. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  514. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  515. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  516. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  517. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  518. else()
  519. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  520. endif()
  521. #
  522. # Make a version file containing the current version from git.
  523. #
  524. include(GetGitRevisionDescription)
  525. git_describe_checkout(STORM_GIT_VERSION_STRING)
  526. # Parse the git Tag into variables
  527. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  528. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  529. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  530. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  531. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  532. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  533. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  534. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  535. else()
  536. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  537. endif()
  538. 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})")
  539. # Configure a header file to pass some of the CMake settings to the source code
  540. configure_file (
  541. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  542. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  543. )
  544. #create library
  545. find_package(CUDA REQUIRED)
  546. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  547. find_package(Cusp REQUIRED)
  548. find_package(Thrust REQUIRED)
  549. set(STORM_CUDA_LIB_NAME "storm-cuda")
  550. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  551. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  552. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  553. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  554. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  555. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  556. #############################################################
  557. ##
  558. ## CUSP
  559. ##
  560. #############################################################
  561. if(CUSP_FOUND)
  562. include_directories(${CUSP_INCLUDE_DIR})
  563. cuda_include_directories(${CUSP_INCLUDE_DIR})
  564. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  565. else()
  566. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  567. endif()
  568. #############################################################
  569. ##
  570. ## Thrust
  571. ##
  572. #############################################################
  573. if(THRUST_FOUND)
  574. include_directories(${THRUST_INCLUDE_DIR})
  575. cuda_include_directories(${THRUST_INCLUDE_DIR})
  576. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  577. else()
  578. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  579. endif()
  580. include_directories(${CUDA_INCLUDE_DIRS})
  581. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  582. cuda_add_library(${STORM_CUDA_LIB_NAME}
  583. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  584. )
  585. message (STATUS "Storm - Linking with CUDA.")
  586. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  587. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  588. endif()
  589. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})