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.

752 lines
29 KiB

  1. add_custom_target(resources)
  2. add_custom_target(test-resources)
  3. set(STORM_3RDPARTY_SOURCE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty)
  4. set(STORM_3RDPARTY_BINARY_DIR ${PROJECT_BINARY_DIR}/resources/3rdparty)
  5. #############################################################
  6. ##
  7. ## l3pp
  8. ##
  9. #############################################################
  10. # Do not take a branch, needs internet connection.
  11. ExternalProject_Add(
  12. l3pp_ext
  13. GIT_REPOSITORY https://github.com/hbruintjes/l3pp.git
  14. GIT_TAG e4f8d7fe6c328849aff34d2dfd6fd592c14070d5
  15. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/l3pp
  16. UPDATE_COMMAND ""
  17. CONFIGURE_COMMAND ""
  18. BUILD_COMMAND ""
  19. INSTALL_COMMAND ""
  20. LOG_INSTALL ON
  21. )
  22. ExternalProject_Get_Property(l3pp_ext source_dir)
  23. set(l3pp_INCLUDE "${source_dir}/")
  24. add_imported_library_interface(l3pp "${l3pp_INCLUDE}")
  25. list(APPEND STORM_DEP_TARGETS l3pp)
  26. add_dependencies(l3pp l3pp_ext)
  27. #############################################################
  28. ##
  29. ## gmm
  30. ##
  31. #############################################################
  32. add_imported_library_interface(gmm "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.2/include")
  33. list(APPEND STORM_DEP_TARGETS gmm)
  34. #############################################################
  35. ##
  36. ## Eigen
  37. ##
  38. #############################################################
  39. add_imported_library_interface(StormEigen33 "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1")
  40. list(APPEND STORM_DEP_TARGETS StormEigen33)
  41. #############################################################
  42. ##
  43. ## Boost
  44. ##
  45. #############################################################
  46. # Boost Option variables
  47. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  48. set(Boost_USE_MULTITHREADED ON)
  49. set(Boost_USE_STATIC_RUNTIME OFF)
  50. find_package(Boost 1.61.0 QUIET REQUIRED COMPONENTS filesystem system)
  51. if (NOT Boost_FOUND)
  52. if (Boost_VERSION)
  53. message(FATAL_ERROR "The required Boost version is 1.61.0 or newer, however, only ${Boost_VERSION} was found.")
  54. else ()
  55. message(FATAL_ERROR "Boost was not found.")
  56. endif ()
  57. endif ()
  58. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  59. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  60. endif ()
  61. set(CNTVAR 1)
  62. foreach(BOOSTLIB ${Boost_LIBRARIES})
  63. add_imported_library(target-boost-${CNTVAR} SHARED ${BOOSTLIB} ${Boost_INCLUDE_DIRS})
  64. list(APPEND STORM_DEP_TARGETS target-boost-${CNTVAR}_SHARED)
  65. MATH(EXPR CNTVAR "${CNTVAR}+1")
  66. endforeach()
  67. message(STATUS "Storm - Using boost ${Boost_VERSION} (library version ${Boost_LIB_VERSION}).")
  68. # set the information for the config header
  69. set(STORM_BOOST_INCLUDE_DIR "${Boost_INCLUDE_DIRS}")
  70. #############################################################
  71. ##
  72. ## ExprTk
  73. ##
  74. #############################################################
  75. # Use the shipped version of ExprTK
  76. message (STATUS "Storm - Including ExprTk.")
  77. add_imported_library_interface(ExprTk "${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  78. list(APPEND STORM_DEP_TARGETS ExprTk)
  79. #############################################################
  80. ##
  81. ## Sparsepp
  82. ##
  83. #############################################################
  84. # Use the shipped version of Sparsepp
  85. message (STATUS "Storm - Including Sparsepp.")
  86. set(SPARSEPP_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/sparsepp/sparsepp")
  87. file(GLOB SPARSEPP_HEADERS "${SPARSEPP_INCLUDE_DIR}/*.h")
  88. # Add the sparsepp headers to the headers that are copied to the include directory in the build directory.
  89. set(SPARSEPP_BINDIR_DIR ${CMAKE_BINARY_DIR}/include/resources/3rdparty/sparsepp)
  90. include_directories("${SPARSEPP_BINDIR_DIR}")
  91. foreach(HEADER ${SPARSEPP_HEADERS})
  92. string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/src/?" "" RELATIVE_HEADER_PATH ${HEADER})
  93. string(REGEX MATCH "(.*)[/\\]" RELATIVE_DIRECTORY ${RELATIVE_HEADER_PATH})
  94. string(REGEX REPLACE "${RELATIVE_DIRECTORY}/?" "" HEADER_FILENAME ${RELATIVE_HEADER_PATH})
  95. add_custom_command(
  96. OUTPUT ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  97. COMMAND ${CMAKE_COMMAND} -E make_directory ${SPARSEPP_BINDIR_DIR}/sparsepp
  98. COMMAND ${CMAKE_COMMAND} -E copy ${HEADER} ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME}
  99. DEPENDS ${SPARSEPP_INCLUDE_DIR}/${HEADER_FILENAME}
  100. )
  101. list(APPEND SPARSEPP_BINDIR_HEADERS ${SPARSEPP_BINDIR_DIR}/sparsepp/${HEADER_FILENAME})
  102. endforeach()
  103. #############################################################
  104. ##
  105. ## ModernJSON
  106. ##
  107. #############################################################
  108. #use the shipped version of modernjson
  109. message (STATUS "Storm - Including ModernJSON.")
  110. add_imported_library_interface(ModernJSON "${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/")
  111. list(APPEND STORM_DEP_TARGETS ModernJSON)
  112. #############################################################
  113. ##
  114. ## Z3 (optional)
  115. ##
  116. #############################################################
  117. find_package(Z3 QUIET)
  118. # Z3 Defines
  119. set(STORM_HAVE_Z3 ${Z3_FOUND})
  120. if(Z3_FOUND)
  121. # Get the z3 version by compiling and running a simple program
  122. try_run(version_run_result version_compile_result "${STORM_3RDPARTY_BINARY_DIR}/z3/" "${PROJECT_SOURCE_DIR}/resources/3rdparty/z3/output_version.cpp" CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${Z3_INCLUDE_DIR}" LINK_LIBRARIES "${Z3_LIBRARIES}" RUN_OUTPUT_VARIABLE z3_version_output)
  123. if (version_compile_result AND version_run_result EQUAL 0)
  124. if (z3_version_output MATCHES "([0-9]*\\.[0-9]*\\.[0-9]*)")
  125. set(Z3_VERSION "${CMAKE_MATCH_1}")
  126. endif()
  127. endif()
  128. if(Z3_VERSION)
  129. # Split Z3 version into its components
  130. string(REPLACE "." ";" Z3_VERSION_LIST ${Z3_VERSION})
  131. list(GET Z3_VERSION_LIST 0 STORM_Z3_VERSION_MAJOR)
  132. list(GET Z3_VERSION_LIST 1 STORM_Z3_VERSION_MINOR)
  133. list(GET Z3_VERSION_LIST 2 STORM_Z3_VERSION_PATCH)
  134. # Check whether the version of z3 supports optimization
  135. if(NOT "${Z3_VERSION}" VERSION_LESS "4.5.0")
  136. set(STORM_HAVE_Z3_OPTIMIZE ON)
  137. message (STATUS "Storm - Linking with Z3 (version ${Z3_VERSION}). (Z3 version supports optimization)")
  138. else()
  139. message (STATUS "Storm - Linking with Z3 (version ${Z3_VERSION}). (Z3 version does not support optimization)")
  140. endif()
  141. if (NOT "${Z3_VERSION}" VERSION_LESS "4.7.1")
  142. set(STORM_Z3_API_USES_STANDARD_INTEGERS ON)
  143. endif()
  144. add_imported_library(z3 SHARED ${Z3_LIBRARIES} ${Z3_INCLUDE_DIRS})
  145. list(APPEND STORM_DEP_TARGETS z3_SHARED)
  146. else()
  147. message(WARNING "Storm - Could not obtain Z3 version. Building of Prism/JANI models will not be supported.")
  148. set(Z3_FOUND FALSE)
  149. endif()
  150. else()
  151. message (WARNING "Storm - Z3 not found. Building of Prism/JANI models will not be supported.")
  152. endif(Z3_FOUND)
  153. #############################################################
  154. ##
  155. ## glpk
  156. ##
  157. #############################################################
  158. include(${STORM_3RDPARTY_SOURCE_DIR}/include_glpk.cmake)
  159. #############################################################
  160. ##
  161. ## Gurobi (optional)
  162. ##
  163. #############################################################
  164. if (STORM_USE_GUROBI)
  165. find_package(Gurobi QUIET REQUIRED)
  166. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  167. if (GUROBI_FOUND)
  168. if (EXISTS ${GUROBI_LIBRARY})
  169. message (STATUS "Storm - Linking with Gurobi.")
  170. add_imported_library(Gurobi SHARED ${GUROBI_LIBRARY} ${GUROBI_INCLUDE_DIRS})
  171. list(APPEND STORM_DEP_TARGETS Gurobi_SHARED)
  172. else()
  173. # The FindGurobi.cmake script needs to be updated every now and then as the library file contains the version number...
  174. message(SEND_ERROR "Gurobi Library ${GUROBI_LIBRARY} not found. If your Gurobi Version is higher then 8.1.0, please contact the Storm developers.")
  175. endif()
  176. else()
  177. message(SEND_ERROR "Gurobi Library requested but was not found. Make sure that GUROBI_ROOT points to the correct directory (containing include/ and lib/ subdirectories).")
  178. endif()
  179. else()
  180. set(STORM_HAVE_GUROBI OFF)
  181. endif()
  182. #############################################################
  183. ##
  184. ## CUDD
  185. ##
  186. #############################################################
  187. include(${STORM_3RDPARTY_SOURCE_DIR}/include_cudd.cmake)
  188. #############################################################
  189. ##
  190. ## carl
  191. ##
  192. #############################################################
  193. set(STORM_HAVE_CARL OFF)
  194. set(CARL_MINVERSION "17.12")
  195. set(CARL_C14VERSION "14")
  196. if (NOT STORM_FORCE_SHIPPED_CARL)
  197. if (NOT "${STORM_CARL_DIR_HINT}" STREQUAL "")
  198. find_package(carl QUIET PATHS ${STORM_CARL_DIR_HINT} NO_DEFAULT_PATH)
  199. endif()
  200. if (NOT carl_FOUND)
  201. find_package(carl QUIET)
  202. endif()
  203. endif()
  204. if(carl_FOUND AND NOT STORM_FORCE_SHIPPED_CARL)
  205. get_target_property(carlLOCATION lib_carl LOCATION)
  206. if(${carlLOCATION} STREQUAL "carlLOCATION-NOTFOUND")
  207. message(SEND_ERROR "Library location for carl is not found, did you build carl?")
  208. elseif(EXISTS ${carlLOCATION})
  209. #empty on purpose
  210. else()
  211. message(SEND_ERROR "File ${carlLOCATION} does not exist, did you build carl?")
  212. endif()
  213. if("${carl_VERSION_MAJOR}" STREQUAL "${CARL_C14VERSION}")
  214. message(STATUS "Storm - Found carl using master14 branch.")
  215. # empty on purpose. Maybe put a warning here?
  216. elseif("${carl_VERSION_MAJOR}.${carl_VERSION_MINOR}" VERSION_LESS "${CARL_MINVERSION}")
  217. message(SEND_ERROR "Carl outdated, require ${CARL_MINVERSION}, have ${carl_VERSION}")
  218. endif()
  219. set(STORM_SHIPPED_CARL OFF)
  220. set(STORM_HAVE_CARL ON)
  221. message(STATUS "Storm - Use system version of carl.")
  222. 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}).")
  223. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  224. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  225. else()
  226. set(STORM_SHIPPED_CARL ON)
  227. # The first external project will be built at *configure stage*
  228. message(STATUS "Carl - Start of config process")
  229. file(MAKE_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download)
  230. execute_process(
  231. 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}"
  232. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  233. OUTPUT_VARIABLE carlconfig_out
  234. RESULT_VARIABLE carlconfig_result)
  235. if(NOT carlconfig_result)
  236. message(STATUS "${carlconfig_out}")
  237. endif()
  238. execute_process(
  239. COMMAND ${CMAKE_COMMAND} --build . --target carl-config
  240. WORKING_DIRECTORY ${STORM_3RDPARTY_BINARY_DIR}/carl_download
  241. OUTPUT_VARIABLE carlconfig_out
  242. RESULT_VARIABLE carlconfig_result
  243. )
  244. if(NOT carlconfig_result)
  245. message(STATUS "${carlconfig_out}")
  246. endif()
  247. message(STATUS "Carl - End of config process")
  248. message(STATUS "Storm - Using shipped version of carl.")
  249. ExternalProject_Add(
  250. carl
  251. SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/carl
  252. CONFIGURE_COMMAND ""
  253. BUILD_IN_SOURCE 1
  254. BUILD_COMMAND make lib_carl
  255. INSTALL_COMMAND make install
  256. LOG_BUILD ON
  257. LOG_INSTALL ON
  258. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT}
  259. )
  260. include(${STORM_3RDPARTY_BINARY_DIR}/carl/carlConfig.cmake)
  261. set(STORM_HAVE_CLN ${CARL_USE_CLN_NUMBERS})
  262. set(STORM_HAVE_GINAC ${CARL_USE_GINAC})
  263. add_dependencies(resources carl)
  264. set(carl_INCLUDE_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/include/")
  265. set(carl_DIR "${STORM_3RDPARTY_BINARY_DIR}/carl/")
  266. set(carl_LIBRARIES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT})
  267. set(STORM_HAVE_CARL ON)
  268. 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}).")
  269. # install the carl dynamic library if we built it
  270. install(FILES ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl.${carl_VERSION}${DYNAMIC_EXT} DESTINATION lib)
  271. endif()
  272. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_CLN)
  273. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without.")
  274. endif()
  275. if(STORM_USE_CLN_RF AND NOT STORM_HAVE_GINAC)
  276. message(FATAL_ERROR "Cannot use CLN numbers if carl is build without ginac.")
  277. endif()
  278. # The library that needs symbols must be first, then the library that resolves the symbol.
  279. list(APPEND STORM_DEP_IMP_TARGETS lib_carl)
  280. if(STORM_USE_CLN_EA OR STORM_USE_CLN_RF)
  281. list(APPEND STORM_DEP_IMP_TARGETS GINAC_SHARED CLN_SHARED)
  282. endif()
  283. list(APPEND STORM_DEP_IMP_TARGETS GMPXX_SHARED GMP_SHARED)
  284. #############################################################
  285. ##
  286. ## SMT-RAT
  287. ##
  288. #############################################################
  289. set(STORM_HAVE_SMTRAT OFF)
  290. if(USE_SMTRAT)
  291. find_package(smtrat QUIET REQUIRED)
  292. if(smtrat_FOUND)
  293. set(STORM_HAVE_SMTRAT ON)
  294. message(STATUS "Storm - Linking with smtrat.")
  295. include_directories("${smtrat_INCLUDE_DIR}")
  296. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  297. else()
  298. message(FATAL_ERROR "Storm - SMT-RAT was requested but not found")
  299. endif()
  300. endif()
  301. #############################################################
  302. ##
  303. ## HyPro
  304. ##
  305. #############################################################
  306. set(STORM_HAVE_HYPRO OFF)
  307. if(USE_HYPRO)
  308. find_package(hypro QUIET REQUIRED)
  309. if(hypro_FOUND)
  310. set(STORM_HAVE_HYPRO ON)
  311. message(STATUS "Storm - Linking with hypro.")
  312. include_directories("${hypro_INCLUDE_DIR}")
  313. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  314. else()
  315. message(FATAL_ERROR "Storm - HyPro was requested but not found")
  316. endif()
  317. endif()
  318. #############################################################
  319. ##
  320. ## gmp
  321. ##
  322. #############################################################
  323. get_target_property(GMPXX_LIB GMPXX_SHARED IMPORTED_LIB_LOCATION)
  324. get_target_property(GMP_LIB GMP_SHARED IMPORTED_LIB_LOCATION)
  325. get_target_property(GMPXX_INCLUDE_DIR GMPXX_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  326. get_target_property(GMP_INCLUDE_DIR GMP_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  327. get_filename_component(GMP_LIB_LOCATION ${GMP_LIB} DIRECTORY)
  328. get_filename_component(GMPXX_LIB_LOCATION ${GMPXX_LIB} DIRECTORY)
  329. #############################################################
  330. ##
  331. ## cln
  332. ##
  333. #############################################################
  334. get_target_property(CLN_INCLUDE_DIR CLN_SHARED INTERFACE_INCLUDE_DIRECTORIES)
  335. #############################################################
  336. ##
  337. ## MathSAT (optional)
  338. ##
  339. #############################################################
  340. if ("${MSAT_ROOT}" STREQUAL "")
  341. set(ENABLE_MSAT OFF)
  342. else()
  343. set(ENABLE_MSAT ON)
  344. endif()
  345. # MathSAT Defines
  346. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  347. if (ENABLE_MSAT)
  348. message (STATUS "Storm - Linking with MathSAT.")
  349. if(${OPERATING_SYSTEM} MATCHES "Linux")
  350. find_library(MSAT_LIB mathsat PATHS "${MSAT_ROOT}/lib")
  351. add_imported_library(msat SHARED ${MSAT_LIB} "${MSAT_ROOT}/include")
  352. list(APPEND STORM_DEP_TARGETS msat_SHARED)
  353. else()
  354. # on macOS, the .dylib file has some hard coded path (Version 5.5.4).
  355. # we thus link statically
  356. find_library(MSAT_LIB NAMES libmathsat${STATIC_EXT} mathsat PATHS "${MSAT_ROOT}/lib")
  357. add_imported_library(msat STATIC ${MSAT_LIB} "${MSAT_ROOT}/include")
  358. list(APPEND STORM_DEP_TARGETS msat_STATIC)
  359. endif()
  360. endif(ENABLE_MSAT)
  361. #############################################################
  362. ##
  363. ## QVBS (Quantitative verification benchmark set)
  364. ##
  365. #############################################################
  366. set(STORM_HAVE_QVBS OFF)
  367. if (NOT "${STORM_QVBS_ROOT}" STREQUAL "")
  368. if( EXISTS "${STORM_QVBS_ROOT}/index.json")
  369. set(STORM_HAVE_QVBS ON)
  370. message (STATUS "Storm - Enabled inputs from QVBS located at ${STORM_QVBS_ROOT}")
  371. else()
  372. message(FATAL_ERROR "No file 'index.json' in provided QVBS root directory ${STORM_QVBS_ROOT}")
  373. endif()
  374. endif()
  375. #############################################################
  376. ##
  377. ## Xerces
  378. ##
  379. #############################################################
  380. include(${STORM_3RDPARTY_SOURCE_DIR}/include_xerces.cmake)
  381. #############################################################
  382. ##
  383. ## Sylvan
  384. ##
  385. #############################################################
  386. if(STORM_SHIPPED_CARL)
  387. set(sylvan_dep carl)
  388. else()
  389. set(sylvan_dep lib_carl)
  390. endif()
  391. if (STORM_DEBUG_SYLVAN)
  392. set(SYLVAN_BUILD_TYPE "Debug")
  393. else()
  394. set(SYLVAN_BUILD_TYPE "Release")
  395. endif()
  396. ExternalProject_Add(
  397. sylvan
  398. DOWNLOAD_COMMAND ""
  399. PREFIX "sylvan"
  400. SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/sylvan
  401. 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
  402. BINARY_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  403. BUILD_IN_SOURCE 0
  404. INSTALL_COMMAND ""
  405. INSTALL_DIR ${STORM_3RDPARTY_BINARY_DIR}/sylvan
  406. LOG_CONFIGURE ON
  407. LOG_BUILD ON
  408. DEPENDS ${sylvan_dep}
  409. BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/sylvan/src/libsylvan${STATIC_EXT}
  410. BUILD_ALWAYS 1
  411. )
  412. # BUILD ALWAYS ON due to: https://stackoverflow.com/questions/46708124/cmake-doesnt-rebuild-externalproject-on-changes
  413. ExternalProject_Get_Property(sylvan source_dir)
  414. ExternalProject_Get_Property(sylvan binary_dir)
  415. set(Sylvan_INCLUDE_DIR "${source_dir}/src")
  416. set(Sylvan_LIBRARY "${binary_dir}/src/libsylvan${STATIC_EXT}")
  417. message(STATUS "Storm - Using shipped version of sylvan.")
  418. message(STATUS "Storm - Linking with sylvan.")
  419. add_imported_library(sylvan STATIC ${Sylvan_LIBRARY} ${Sylvan_INCLUDE_DIR})
  420. add_dependencies(sylvan_STATIC sylvan)
  421. list(APPEND STORM_DEP_TARGETS sylvan_STATIC)
  422. find_package(Hwloc QUIET REQUIRED)
  423. if(HWLOC_FOUND)
  424. message(STATUS "Storm - Linking with hwloc ${HWLOC_VERSION}.")
  425. add_imported_library(hwloc STATIC ${HWLOC_LIBRARIES} "")
  426. list(APPEND STORM_DEP_TARGETS hwloc_STATIC)
  427. else()
  428. if(${OPERATING_SYSTEM} MATCHES "Linux")
  429. message(FATAL_ERROR "HWLOC is required on Linux but was not found.")
  430. endif()
  431. endif()
  432. #############################################################
  433. ##
  434. ## cpptemplate
  435. ##
  436. #############################################################
  437. add_imported_library_interface(CppTemplate "${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/")
  438. list(APPEND STORM_DEP_TARGETS CppTemplate)
  439. list(APPEND STORM_3RDPARTY_SOURCES ${STORM_3RDPARTY_SOURCE_DIR}/cpptemplate/cpptempl.cpp)
  440. #############################################################
  441. ##
  442. ## Google Test gtest
  443. ##
  444. #############################################################
  445. set(GOOGLETEST_LIB_DIR ${STORM_3RDPARTY_BINARY_DIR}/gtest-1.7.0)
  446. ExternalProject_Add(
  447. googletest
  448. #For downloads (may be useful later!)
  449. #SVN_REPOSITORY http://googletest.googlecode.com/svn/trunk/
  450. #TIMEOUT 10
  451. DOWNLOAD_COMMAND ""
  452. SOURCE_DIR "${STORM_3RDPARTY_SOURCE_DIR}/gtest-1.7.0"
  453. # Force the same output paths for debug and release builds so that
  454. # we know in which place the binaries end up when using the Xcode generator
  455. 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}
  456. # Disable install step
  457. INSTALL_COMMAND ""
  458. BINARY_DIR ${GOOGLETEST_LIB_DIR}
  459. INSTALL_DIR ${GOOGLETEST_LIB_DIR}
  460. # Wrap download, configure and build steps in a script to log output
  461. LOG_CONFIGURE ON
  462. LOG_BUILD ON
  463. BUILD_BYPRODUCTS ${GOOGLETEST_LIB_DIR}/libgtest${STATIC_EXT} ${GOOGLETEST_LIB_DIR}/libgtest_main${STATIC_EXT}
  464. )
  465. # Specify include dir
  466. ExternalProject_Get_Property(googletest source_dir)
  467. set(GTEST_INCLUDE_DIR ${source_dir}/include)
  468. # Specify MainTest's link libraries
  469. ExternalProject_Get_Property(googletest binary_dir)
  470. set(GTEST_LIBRARIES ${binary_dir}/libgtest${STATIC_EXT} ${binary_dir}/libgtest_main${STATIC_EXT})
  471. add_dependencies(test-resources googletest)
  472. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  473. #############################################################
  474. ##
  475. ## Intel Threading Building Blocks (optional)
  476. ##
  477. #############################################################
  478. set(STORM_HAVE_INTELTBB OFF)
  479. if (STORM_USE_INTELTBB)
  480. find_package(TBB QUIET REQUIRED)
  481. if (TBB_FOUND)
  482. message(STATUS "Storm - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  483. message(STATUS "Storm - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  484. set(STORM_HAVE_INTELTBB ON)
  485. # Under Linux libtbb.so contains a linker script to libtbb.so.2 instead of a symlink.
  486. # This breaks CMake.
  487. # As a workaround we manually try to add the necessary suffix ".2" to the so file and hope for the best.
  488. if (LINUX)
  489. # Check if the library is a linker script which only links to the correct library
  490. # Read first bytes of file
  491. file(READ "${TBB_LIBRARY}" TMPTXT LIMIT 128)
  492. # Check if file starts with "INPUT (libtbb.so.2)"
  493. if("${TMPTXT}" MATCHES "INPUT \\(libtbb\\.so\\.(.*)\\)")
  494. # Manually set library by adding the suffix from the linker script.
  495. # CMAKE_MATCH_1 contains the parsed suffix.
  496. set(TBB_LIB_LINUX "${TBB_LIBRARY}.${CMAKE_MATCH_1}")
  497. set(TBB_MALLOC_LIB_LINUX "${TBB_MALLOC_LIBRARY}.${CMAKE_MATCH_1}")
  498. if (EXISTS "${TBB_LIB_LINUX}")
  499. set(TBB_LIBRARY ${TBB_LIB_LINUX})
  500. message(STATUS "Storm - Using Intel TBB library in manually set path ${TBB_LIBRARY}.")
  501. endif()
  502. if (EXISTS "${TBB_MALLOC_LIB_LINUX}")
  503. set(TBB_MALLOC_LIBRARY ${TBB_MALLOC_LIB_LINUX})
  504. message(STATUS "Storm - Using Intel TBB malloc library in manually set path ${TBB_MALLOC_LIBRARY}.")
  505. endif()
  506. endif()
  507. endif()
  508. add_imported_library(tbb SHARED ${TBB_LIBRARY} ${TBB_INCLUDE_DIRS})
  509. list(APPEND STORM_DEP_TARGETS tbb_SHARED)
  510. add_imported_library(tbb_malloc SHARED ${TBB_MALLOC_LIBRARY} ${TBB_INCLUDE_DIRS})
  511. list(APPEND STORM_DEP_TARGETS tbb_malloc_SHARED)
  512. else(TBB_FOUND)
  513. message(FATAL_ERROR "Storm - TBB was requested, but not found.")
  514. endif(TBB_FOUND)
  515. endif(STORM_USE_INTELTBB)
  516. #############################################################
  517. ##
  518. ## Threads
  519. ##
  520. #############################################################
  521. find_package(Threads QUIET REQUIRED)
  522. if (NOT Threads_FOUND)
  523. message(FATAL_ERROR "Storm - Threads was requested, but not found.")
  524. endif()
  525. include_directories(${THREADS_INCLUDE_DIRS})
  526. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  527. if (STORM_USE_COTIRE)
  528. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  529. endif(STORM_USE_COTIRE)
  530. #############################################################
  531. ##
  532. ## CUDA Library generation
  533. ##
  534. #############################################################
  535. if ("${CUDA_ROOT}" STREQUAL "")
  536. set(ENABLE_CUDA OFF)
  537. else()
  538. set(ENABLE_CUDA ON)
  539. endif()
  540. # CUDA Defines
  541. if (ENABLE_CUDA)
  542. set(STORM_CPP_CUDA_DEF "define")
  543. else()
  544. set(STORM_CPP_CUDA_DEF "undef")
  545. endif()
  546. # CUDA Defines
  547. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  548. if(ENABLE_CUDA)
  549. # Test for type alignment
  550. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  551. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  552. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  553. )
  554. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  555. 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}")
  556. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  557. message(STATUS "Storm (CudaPlugin) - Result of Type Alignment Check: OK.")
  558. else()
  559. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  560. endif()
  561. # Test for Float 64bit Alignment
  562. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  563. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  564. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  565. )
  566. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  567. 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}")
  568. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  569. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  570. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  571. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  572. message(STATUS "Storm (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  573. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  574. else()
  575. message(FATAL_ERROR "Storm (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  576. endif()
  577. #
  578. # Make a version file containing the current version from git.
  579. #
  580. include(GetGitRevisionDescription)
  581. git_describe_checkout(STORM_GIT_VERSION_STRING)
  582. # Parse the git Tag into variables
  583. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  584. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  585. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  586. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  587. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  588. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  589. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  590. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  591. else()
  592. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  593. endif()
  594. 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})")
  595. # Configure a header file to pass some of the CMake settings to the source code
  596. configure_file (
  597. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  598. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  599. )
  600. #create library
  601. find_package(CUDA REQUIRED)
  602. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  603. find_package(Cusp REQUIRED)
  604. find_package(Thrust REQUIRED)
  605. set(STORM_CUDA_LIB_NAME "storm-cuda")
  606. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  607. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  608. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  609. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  610. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  611. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  612. #############################################################
  613. ##
  614. ## CUSP
  615. ##
  616. #############################################################
  617. if(CUSP_FOUND)
  618. include_directories(${CUSP_INCLUDE_DIR})
  619. cuda_include_directories(${CUSP_INCLUDE_DIR})
  620. message(STATUS "Storm (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}.")
  621. else()
  622. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find CUSP.")
  623. endif()
  624. #############################################################
  625. ##
  626. ## Thrust
  627. ##
  628. #############################################################
  629. if(THRUST_FOUND)
  630. include_directories(${THRUST_INCLUDE_DIR})
  631. cuda_include_directories(${THRUST_INCLUDE_DIR})
  632. message(STATUS "Storm (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}.")
  633. else()
  634. message(FATAL_ERROR "Storm (CudaPlugin) - Could not find Thrust. Check your CUDA installation.")
  635. endif()
  636. include_directories(${CUDA_INCLUDE_DIRS})
  637. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  638. cuda_add_library(${STORM_CUDA_LIB_NAME}
  639. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  640. )
  641. message (STATUS "Storm - Linking with CUDA.")
  642. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  643. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  644. endif()
  645. add_custom_target(copy_resources_headers DEPENDS ${SPARSEPP_BINDIR_HEADERS})