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.

832 lines
30 KiB

  1. cmake_minimum_required (VERSION 2.8.6)
  2. cmake_policy(VERSION 3.2)
  3. # Set project name
  4. project (storm CXX C)
  5. # Add base folder for better inclusion paths
  6. include_directories("${PROJECT_SOURCE_DIR}")
  7. include_directories("${PROJECT_SOURCE_DIR}/src")
  8. # Add the resources/cmake folder to Module Search Path for FindTBB.cmake
  9. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmake/")
  10. include(ExternalProject)
  11. #############################################################
  12. ##
  13. ## CMake options of StoRM
  14. ##
  15. #############################################################
  16. option(STORM_DEVELOPER "Sets whether the development mode is used" OFF)
  17. option(STORM_USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON)
  18. option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." ON)
  19. option(STORM_USE_INTELTBB "Sets whether the Intel TBB libraries should be used." OFF)
  20. option(STORM_USE_GUROBI "Sets whether Gurobi should be used." OFF)
  21. option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precompiled headers)." OFF)
  22. option(LINK_LIBCXXABI "Sets whether libc++abi should be linked." OFF)
  23. option(USE_LIBCXX "Sets whether the standard library is libc++." OFF)
  24. option(USE_CARL "Sets whether carl should be included." ON)
  25. option(USE_SMTRAT "Sets whether SMT-RAT should be included." OFF)
  26. option(USE_HYPRO "Sets whether HyPro should be included." OFF)
  27. option(USE_XERCES "Sets whether xerces should be used." OFF)
  28. option(FORCE_COLOR "Force color output" OFF)
  29. option(STORM_PYTHON "Builds the API for Python" OFF)
  30. option(STORM_COMPILE_WITH_CCACHE "Compile using CCache" ON)
  31. option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF)
  32. set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).")
  33. set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).")
  34. set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).")
  35. set(CUDA_ROOT "" CACHE STRING "The hint to the root directory of CUDA (optional).")
  36. set(MSAT_ROOT "" CACHE STRING "The hint to the root directory of MathSAT (optional).")
  37. set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.")
  38. set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.")
  39. # If the STORM_DEVELOPER option was turned on, we will target a debug version.
  40. if (STORM_DEVELOPER)
  41. message(STATUS "StoRM - Using development mode")
  42. set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "Set the build type" FORCE)
  43. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTORM_DEV")
  44. endif()
  45. message(STATUS "StoRM - Building ${CMAKE_BUILD_TYPE} version.")
  46. if(STORM_COMPILE_WITH_CCACHE)
  47. find_program(CCACHE_FOUND ccache)
  48. if(CCACHE_FOUND)
  49. message(STATUS "StoRM - Using ccache")
  50. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  51. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  52. else()
  53. message(STATUS "Could not find ccache")
  54. endif()
  55. endif()
  56. # Base path for test files
  57. set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test")
  58. set(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy")
  59. set(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/stormpy")
  60. # Auto-detect operating system.
  61. set(MACOSX 0)
  62. set(LINUX 0)
  63. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  64. # Mac OS
  65. set(OPERATING_SYSTEM "Mac OS")
  66. set(MACOSX 1)
  67. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  68. # Linux
  69. set(OPERATING_SYSTEM "Linux")
  70. set(LINUX 1)
  71. elseif(WIN32)
  72. # Assuming Windows.
  73. set(OPERATING_SYSTEM "Windows")
  74. else()
  75. message(WARNING "We are unsure about your operating system.")
  76. set(OPERATING_SYSTEM "Linux")
  77. set(LINUX 1)
  78. ENDIF()
  79. message(STATUS "Operating system: ${OPERATING_SYSTEM}")
  80. set(DYNAMIC_EXT ".so")
  81. set(STATIC_EXT ".a")
  82. if(MACOSX)
  83. set(DYNAMIC_EXT ".dylib")
  84. set(STATIC_EXT ".a")
  85. elseif (WIN32)
  86. set(DYNAMIC_EXT ".dll")
  87. set(STATIC_EXT ".lib")
  88. endif()
  89. message(STATUS "Assuming extension for shared libraries: ${DYNAMIC_EXT}")
  90. message(STATUS "Assuming extension for static libraries: ${STATIC_EXT}")
  91. #############################################################
  92. ##
  93. ## Compiler specific settings and definitions
  94. ##
  95. #############################################################
  96. # Path to the no-strict-aliasing target
  97. set(CONVERSIONHELPER_TARGET "${PROJECT_SOURCE_DIR}/src/utility/ConversionHelper.cpp")
  98. if(CMAKE_COMPILER_IS_GNUCC)
  99. set(STORM_COMPILED_BY "GCC")
  100. # Set standard flags for GCC
  101. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  102. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops")
  103. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  104. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
  105. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
  106. # Turn on popcnt instruction if desired (yes by default)
  107. if (STORM_USE_POPCNT)
  108. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  109. endif(STORM_USE_POPCNT)
  110. # Set the no-strict-aliasing target for GCC
  111. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing")
  112. elseif(MSVC)
  113. set(STORM_COMPILED_BY "MSVC")
  114. # required for GMM to compile, ugly error directive in their code
  115. add_definitions(/D_SCL_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS)
  116. # required as the PRCTL Parser bloats object files (COFF) beyond their maximum size (see http://msdn.microsoft.com/en-us/library/8578y171(v=vs.110).aspx)
  117. add_definitions(/bigobj)
  118. # required by GTest and PrismGrammar::createIntegerVariable
  119. add_definitions(/D_VARIADIC_MAX=10)
  120. # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max
  121. add_definitions(/DNOMINMAX)
  122. # Boost Defs, required for using boost's transform iterator
  123. add_definitions(/DBOOST_RESULT_OF_USE_DECLTYPE)
  124. # since nobody cares at the moment
  125. add_definitions(/wd4250)
  126. # MSVC does not do strict-aliasing, so no option needed
  127. else(CLANG)
  128. set(STORM_COMPILED_BY "Clang (LLVM)")
  129. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  130. set (CLANG ON)
  131. # Set standard flags for clang
  132. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O3")
  133. if(UNIX AND NOT APPLE AND NOT USE_LIBCXX)
  134. set(CLANG_STDLIB libstdc++)
  135. message(STATUS "StoRM - Linking against libstdc++")
  136. else()
  137. set(CLANG_STDLIB libc++)
  138. message(STATUS "StoRM - Linking against libc++")
  139. # Disable Cotire
  140. set(STORM_USE_COTIRE OFF)
  141. # Set up some Xcode specific settings
  142. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
  143. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  144. endif()
  145. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  146. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -stdlib=${CLANG_STDLIB} -Wall -pedantic -Wno-newline-eof -Wno-mismatched-tags -Wno-unused-local-typedefs -ftemplate-depth=1024 -Wno-parentheses-equality")
  147. if(FORCE_COLOR)
  148. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  149. endif()
  150. # Turn on popcnt instruction if desired (yes by default)
  151. if (STORM_USE_POPCNT)
  152. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  153. endif(STORM_USE_POPCNT)
  154. # Set the no-strict-aliasing target for Clang
  155. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
  156. endif()
  157. if(CCACHE_FOUND)
  158. set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)")
  159. endif()
  160. message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}")
  161. #############################################################
  162. #############################################################
  163. ##
  164. ## Inclusion of required libraries
  165. ##
  166. #############################################################
  167. #############################################################
  168. #############################################################
  169. ##
  170. ## Include the targets for non-system resources
  171. ##
  172. #############################################################
  173. # In 3rdparty, targets are being defined that can be used
  174. # in the the system does not have a library
  175. add_subdirectory(resources/3rdparty)
  176. #############################################################
  177. ##
  178. ## gmm
  179. ##
  180. #############################################################
  181. # Add the shipped version of GMM to the include pathes
  182. set(GMMXX_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include")
  183. include_directories(${GMMXX_INCLUDE_DIR})
  184. #############################################################
  185. ##
  186. ## Eigen
  187. ##
  188. #############################################################
  189. # Add the shipped version of Eigen to the include pathes
  190. set(EIGEN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen-3.3-beta1")
  191. include_directories(${EIGEN_INCLUDE_DIR})
  192. #############################################################
  193. ##
  194. ## gmp
  195. ##
  196. #############################################################
  197. # GMP is optional (unless MathSAT is used, see below)
  198. find_package(GMP QUIET)
  199. #############################################################
  200. ##
  201. ## Boost
  202. ##
  203. #############################################################
  204. # Boost Option variables
  205. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  206. set(Boost_USE_MULTITHREADED ON)
  207. set(Boost_USE_STATIC_RUNTIME OFF)
  208. find_package(Boost 1.56.0 QUIET REQUIRED)
  209. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  210. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  211. endif ()
  212. link_directories(${Boost_LIBRARY_DIRS})
  213. include_directories(${Boost_INCLUDE_DIRS})
  214. list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES})
  215. message(STATUS "StoRM - Using Boost ${Boost_VERSION} (lib ${Boost_LIB_VERSION})")
  216. #message(STATUS "StoRM - BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  217. #message(STATUS "StoRM - BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  218. #############################################################
  219. ##
  220. ## ExprTk
  221. ##
  222. #############################################################
  223. # Use the shipped version of ExprTK
  224. message (STATUS "StoRM - Including ExprTk")
  225. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  226. #############################################################
  227. ##
  228. ## ModernJSON
  229. ##
  230. #############################################################
  231. #use the shipped version of modernjson
  232. message (STATUS "StoRM - Including ModernJSON")
  233. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/modernjson/src/")
  234. #############################################################
  235. ##
  236. ## Z3 (optional)
  237. ##
  238. #############################################################
  239. find_package(Z3 QUIET)
  240. # Z3 Defines
  241. set(STORM_HAVE_Z3 ${Z3_FOUND})
  242. if(Z3_FOUND)
  243. message (STATUS "StoRM - Linking with Z3")
  244. include_directories(${Z3_INCLUDE_DIRS})
  245. list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES})
  246. endif(Z3_FOUND)
  247. #############################################################
  248. ##
  249. ## glpk
  250. ##
  251. #############################################################
  252. find_package(GLPK QUIET)
  253. if(GLPK_FOUND)
  254. message (STATUS "StoRM - Using system version of GLPK")
  255. else()
  256. message (STATUS "StoRM - Using shipped version of GLPK")
  257. set(GLPK_LIBRARIES ${CMAKE_BINARY_DIR}/resources/3rdparty/glpk-4.57/lib/libglpk${DYNAMIC_EXT})
  258. set(GLPK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/resources/3rdparty/glpk-4.57/include)
  259. set(GLPK_VERSION_STRING 4.57)
  260. add_dependencies(resources glpk)
  261. endif()
  262. # Since there is a shipped version, always use GLPK
  263. set(STORM_HAVE_GLPK ON)
  264. message (STATUS "StoRM - Linking with glpk ${GLPK_VERSION_STRING}")
  265. include_directories(${GLPK_INCLUDE_DIR})
  266. list(APPEND STORM_LINK_LIBRARIES ${GLPK_LIBRARIES})
  267. #############################################################
  268. ##
  269. ## Gurobi (optional)
  270. ##
  271. #############################################################
  272. if (STORM_USE_GUROBI)
  273. find_package(Gurobi QUIET REQUIRED)
  274. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  275. if (GUROBI_FOUND)
  276. message (STATUS "StoRM - Linking with Gurobi")
  277. include_directories(${GUROBI_INCLUDE_DIRS})
  278. list(APPEND STORM_LINK_LIBRARIES ${GUROBI_LIBRARY})
  279. #link_directories("${GUROBI_ROOT}/lib")
  280. else()
  281. #message(FATAL_ERROR "StoRM - Gurobi was requested, but not found!")
  282. endif()
  283. else()
  284. set(STORM_HAVE_GUROBI OFF)
  285. endif()
  286. #############################################################
  287. ##
  288. ## CUDD
  289. ##
  290. #############################################################
  291. # Do not use system CUDD, StoRM has a modified version
  292. set(CUDD_INCLUDE_DIR ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/include)
  293. set(CUDD_SHARED_LIBRARY ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/lib/libcudd${DYNAMIC_EXT})
  294. set(CUDD_STATIC_LIBRARY ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/lib/libcudd${STATIC_EXT})
  295. set(CUDD_VERSION_STRING 3.0.0)
  296. list(APPEND STORM_LINK_LIBRARIES ${CUDD_SHARED_LIBRARY})
  297. add_dependencies(resources cudd3)
  298. message(STATUS "StoRM - Linking with CUDD ${CUDD_VERSION_STRING}")
  299. #message("StoRM - CUDD include dir: ${CUDD_INCLUDE_DIR}")
  300. include_directories(${CUDD_INCLUDE_DIR})
  301. #############################################################
  302. ##
  303. ## CLN
  304. ##
  305. #############################################################
  306. find_package(CLN QUIET)
  307. if(CLN_FOUND)
  308. set(STORM_HAVE_CLN ON)
  309. message(STATUS "StoRM - Linking with CLN ${CLN_VERSION_STRING}")
  310. include_directories("${CLN_INCLUDE_DIR}")
  311. list(APPEND STORM_LINK_LIBRARIES ${CLN_LIBRARIES})
  312. else()
  313. set(STORM_HAVE_CLN OFF)
  314. if(NOT GMP_FOUND)
  315. message(FATAL_ERROR "StoRM - Neither CLN nor GMP found")
  316. endif()
  317. endif()
  318. #############################################################
  319. ##
  320. ## carl
  321. ##
  322. #############################################################
  323. set(STORM_HAVE_CARL OFF)
  324. if(USE_CARL)
  325. find_package(carl QUIET REQUIRED)
  326. if(carl_FOUND)
  327. set(STORM_HAVE_CARL ON)
  328. message(STATUS "StoRM - Linking with carl ${carl_VERSION_STRING}")
  329. include_directories("${carl_INCLUDE_DIR}")
  330. list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES})
  331. else()
  332. message(FATAL_ERROR "StoRM - CARL was requested but not found")
  333. endif()
  334. endif()
  335. #############################################################
  336. ##
  337. ## SMT-RAT
  338. ##
  339. #############################################################
  340. set(STORM_HAVE_SMTRAT OFF)
  341. if(USE_SMTRAT)
  342. find_package(smtrat QUIET REQUIRED)
  343. if(smtrat_FOUND)
  344. set(STORM_HAVE_SMTRAT ON)
  345. message(STATUS "StoRM - Linking with smtrat.")
  346. include_directories("${smtrat_INCLUDE_DIR}")
  347. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  348. else()
  349. message(FATAL_ERROR "StoRM - SMT-RAT was requested but not found")
  350. endif()
  351. endif()
  352. #############################################################
  353. ##
  354. ## HyPro
  355. ##
  356. #############################################################
  357. set(STORM_HAVE_HYPRO OFF)
  358. if(USE_HYPRO)
  359. find_package(hypro QUIET REQUIRED)
  360. if(hypro_FOUND)
  361. set(STORM_HAVE_HYPRO ON)
  362. message(STATUS "StoRM - Linking with hypro ${hypro_VERSION_STRING}")
  363. include_directories("${hypro_INCLUDE_DIR}")
  364. link_directories( /Users/tim/hypro/build )
  365. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  366. else()
  367. message(FATAL_ERROR "StoRM - HyPro was requested but not found")
  368. endif()
  369. endif()
  370. #############################################################
  371. ##
  372. ## GiNaC
  373. ##
  374. #############################################################
  375. find_package(GiNaC QUIET)
  376. if(GINAC_FOUND)
  377. set(STORM_HAVE_GINAC ON)
  378. message(STATUS "StoRM - Linking with GiNaC ${GINAC_VERSION_STRING}")
  379. # Right now only link with GiNaC for carl
  380. #include_directories("${GINAC_INCLUDE_DIR}")
  381. list(APPEND STORM_LINK_LIBRARIES ${GINAC_LIBRARIES})
  382. else()
  383. set(STORM_HAVE_GINAC OFF)
  384. #TODO: Check if CARL actually requires the use of GiNaC
  385. endif()
  386. #############################################################
  387. ##
  388. ## MathSAT (optional)
  389. ##
  390. #############################################################
  391. if ("${MSAT_ROOT}" STREQUAL "")
  392. set(ENABLE_MSAT OFF)
  393. else()
  394. set(ENABLE_MSAT ON)
  395. endif()
  396. # MathSAT Defines
  397. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  398. if (ENABLE_MSAT)
  399. message (STATUS "StoRM - Linking with MathSAT")
  400. link_directories("${MSAT_ROOT}/lib")
  401. include_directories("${MSAT_ROOT}/include")
  402. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  403. if(GMP_FOUND)
  404. include_directories("${GMP_INCLUDE_DIR}")
  405. list(APPEND STORM_LINK_LIBRARIES "gmp")
  406. elseif(MPIR_FOUND)
  407. include_directories("${GMP_INCLUDE_DIR}")
  408. list(APPEND STORM_LINK_LIBRARIES "mpir" "mpirxx")
  409. else(GMP_FOUND)
  410. message(FATAL_ERROR "GMP is required for MathSAT, but was not found!")
  411. endif(GMP_FOUND)
  412. endif(ENABLE_MSAT)
  413. #############################################################
  414. ##
  415. ## Xerces
  416. ##
  417. #############################################################
  418. if(USE_XERCES)
  419. find_package(Xerces QUIET REQUIRED)
  420. if(XERCES_FOUND)
  421. message(STATUS "StoRM - Use system version of xerces")
  422. else()
  423. message(STATUS "StoRM - Use shipped version of xerces")
  424. set(XERCES_ROOT ${CMAKE_BINARY_DIR}/resources/3rdparty/xercesc-3.1.2)
  425. set(XERCESC_INCLUDE ${XERCES_ROOT}/include)
  426. set(XERCES_LIBRARY_PATH ${XERCES_ROOT}/lib)
  427. set(XERCESC_LIBRARIES ${XERCES_LIBRARY_PATH}/libxerces-c.a)
  428. add_dependencies(resources xercesc)
  429. endif()
  430. message (STATUS "StoRM - Linking with xercesc")
  431. set(STORM_HAVE_XERCES ON)
  432. include_directories(${XERCESC_INCLUDE})
  433. list(APPEND STORM_LINK_LIBRARIES ${XERCESC_LIBRARIES})
  434. endif(USE_XERCES)
  435. #############################################################
  436. ##
  437. ## Sylvan
  438. ##
  439. #############################################################
  440. message(STATUS "StoRM - Using shipped version of sylvan")
  441. message(STATUS "StoRM - Linking with sylvan")
  442. include_directories("${Sylvan_INCLUDE_DIR}")
  443. list(APPEND STORM_LINK_LIBRARIES ${Sylvan_LIBRARY})
  444. add_dependencies(resources sylvan)
  445. if(${OPERATING_SYSTEM} MATCHES "Linux")
  446. find_package(Hwloc QUIET REQUIRED)
  447. if(Hwloc_FOUND)
  448. message(STATUS "StoRM - Linking with hwloc ${Hwloc_VERSION}")
  449. list(APPEND STORM_LINK_LIBRARIES ${Hwloc_LIBRARIES})
  450. else()
  451. message(FATAL_ERROR "HWLOC is required but was not found.")
  452. endif()
  453. endif()
  454. #############################################################
  455. ##
  456. ## Google Test gtest
  457. ##
  458. #############################################################
  459. add_dependencies(test-resources googletest)
  460. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  461. #############################################################
  462. ##
  463. ## Intel Threading Building Blocks (optional)
  464. ##
  465. #############################################################
  466. set(STORM_HAVE_INTELTBB OFF)
  467. if (STORM_USE_INTELTBB)
  468. # Point to shipped TBB directory
  469. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  470. find_package(TBB QUIET REQUIRED)
  471. if (TBB_FOUND)
  472. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  473. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  474. set(STORM_HAVE_INTELTBB ON)
  475. link_directories(${TBB_LIBRARY_DIRS})
  476. include_directories(${TBB_INCLUDE_DIRS})
  477. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  478. else(TBB_FOUND)
  479. message(FATAL_ERROR "StoRM - TBB was requested, but not found!")
  480. endif(TBB_FOUND)
  481. endif(STORM_USE_INTELTBB)
  482. #############################################################
  483. ##
  484. ## Threads
  485. ##
  486. #############################################################
  487. find_package(Threads QUIET REQUIRED)
  488. if (NOT Threads_FOUND)
  489. message(FATAL_ERROR "StoRM - Threads was requested, but not found!")
  490. endif()
  491. include_directories(${THREADS_INCLUDE_DIRS})
  492. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  493. if (STORM_USE_COTIRE)
  494. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  495. endif(STORM_USE_COTIRE)
  496. if (MSVC)
  497. # Add the DebugHelper DLL
  498. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  499. target_link_libraries(storm "Dbghelp.lib")
  500. endif(MSVC)
  501. #############################################################
  502. ##
  503. ## CUDA Library generation
  504. ##
  505. #############################################################
  506. if ("${CUDA_ROOT}" STREQUAL "")
  507. set(ENABLE_CUDA OFF)
  508. else()
  509. set(ENABLE_CUDA ON)
  510. endif()
  511. # CUDA Defines
  512. if (ENABLE_CUDA)
  513. set(STORM_CPP_CUDA_DEF "define")
  514. else()
  515. set(STORM_CPP_CUDA_DEF "undef")
  516. endif()
  517. # CUDA Defines
  518. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  519. if(ENABLE_CUDA)
  520. # Test for type alignment
  521. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  522. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  523. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  524. )
  525. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  526. 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}")
  527. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  528. message(STATUS "StoRM (CudaPlugin) - Result of Type Alignment Check: OK.")
  529. else()
  530. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  531. endif()
  532. # Test for Float 64bit Alignment
  533. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  534. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  535. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  536. )
  537. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  538. 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}")
  539. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  540. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  541. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  542. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  543. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  544. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  545. else()
  546. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  547. endif()
  548. #
  549. # Make a version file containing the current version from git.
  550. #
  551. include(GetGitRevisionDescription)
  552. git_describe_checkout(STORM_GIT_VERSION_STRING)
  553. # Parse the git Tag into variables
  554. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  555. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  556. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  557. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  558. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  559. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  560. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  561. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  562. else()
  563. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  564. endif()
  565. 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})")
  566. # Configure a header file to pass some of the CMake settings to the source code
  567. configure_file (
  568. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  569. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  570. )
  571. #create library
  572. find_package(CUDA REQUIRED)
  573. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  574. find_package(Cusp REQUIRED)
  575. find_package(Thrust REQUIRED)
  576. set(STORM_CUDA_LIB_NAME "storm-cuda")
  577. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  578. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  579. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  580. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  581. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  582. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  583. #############################################################
  584. ##
  585. ## CUSP
  586. ##
  587. #############################################################
  588. if(CUSP_FOUND)
  589. include_directories(${CUSP_INCLUDE_DIR})
  590. cuda_include_directories(${CUSP_INCLUDE_DIR})
  591. message(STATUS "StoRM (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}")
  592. else()
  593. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find CUSP!")
  594. endif()
  595. #############################################################
  596. ##
  597. ## Thrust
  598. ##
  599. #############################################################
  600. if(THRUST_FOUND)
  601. include_directories(${THRUST_INCLUDE_DIR})
  602. cuda_include_directories(${THRUST_INCLUDE_DIR})
  603. message(STATUS "StoRM (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}")
  604. else()
  605. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find Thrust! Check your CUDA installation.")
  606. endif()
  607. include_directories(${CUDA_INCLUDE_DIRS})
  608. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  609. cuda_add_library(${STORM_CUDA_LIB_NAME}
  610. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  611. )
  612. message (STATUS "StoRM - Linking with CUDA")
  613. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  614. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  615. endif()
  616. #############################################################
  617. ##
  618. ## Cotire
  619. ##
  620. #############################################################
  621. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  622. if (STORM_USE_COTIRE)
  623. # Include Cotire for PCH Generation
  624. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  625. include(cotire)
  626. cotire(storm)
  627. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  628. #cotire(storm-functional-tests)
  629. #cotire(storm-performance-tests)
  630. endif()
  631. #############################################################
  632. ##
  633. ## libc++abi
  634. ##
  635. #############################################################
  636. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  637. if (LINK_LIBCXXABI)
  638. message (STATUS "StoRM - Linking against libc++abi.")
  639. target_link_libraries(storm "c++abi")
  640. endif(LINK_LIBCXXABI)
  641. #############################################################
  642. ##
  643. ## Doxygen
  644. ##
  645. #############################################################
  646. find_package(Doxygen REQUIRED)
  647. # Add a target to generate API documentation with Doxygen
  648. if(DOXYGEN_FOUND)
  649. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  650. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  651. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  652. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  653. endif(DOXYGEN_FOUND)
  654. #############################################################
  655. ##
  656. ## CMake-generated Config File for StoRM
  657. ##
  658. #############################################################
  659. #
  660. # Make a version file containing the current version from git.
  661. #
  662. include(GetGitRevisionDescription)
  663. git_describe_checkout(STORM_GIT_VERSION_STRING)
  664. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  665. # Parse the git Tag into variables
  666. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  667. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  668. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  669. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  670. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  671. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  672. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  673. set(STORM_CPP_VERSION_DIRTY 1)
  674. else()
  675. set(STORM_CPP_VERSION_DIRTY 0)
  676. endif()
  677. message(STATUS "StoRM - Version information: ${STORM_CPP_VERSION_MAJOR}.${STORM_CPP_VERSION_MINOR}.${STORM_CPP_VERSION_PATCH} (${STORM_CPP_VERSION_COMMITS_AHEAD} commits ahead of Tag) build from ${STORM_CPP_VERSION_HASH} (Dirty: ${STORM_CPP_VERSION_DIRTY})")
  678. # Configure a header file to pass some of the CMake settings to the source code
  679. configure_file (
  680. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  681. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  682. )
  683. # Configure a header file to pass the storm version to the source code
  684. configure_file (
  685. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  686. "${PROJECT_SOURCE_DIR}/src/utility/storm-version.cpp"
  687. )
  688. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  689. # Add the binary dir include directory for storm-config.h
  690. include_directories("${PROJECT_BINARY_DIR}/include")
  691. add_subdirectory(src)
  692. add_subdirectory(test)
  693. #############################################################
  694. ##
  695. ## memcheck targets
  696. ##
  697. #############################################################
  698. add_custom_target(memcheck valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm -v --fix-deadlocks ${PROJECT_SOURCE_DIR}/examples/dtmc/crowds/crowds5_5.tra examples/dtmc/crowds/crowds5_5.lab DEPENDS storm)
  699. add_custom_target(memcheck-functional-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-functional-tests -v --fix-deadlocks DEPENDS storm-functional-tests)
  700. add_custom_target(memcheck-performance-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-performance-tests -v --fix-deadlocks DEPENDS storm-performance-tests)
  701. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  702. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  703. include(StormCPackConfig.cmake)