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.

812 lines
29 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. ## gmp
  187. ##
  188. #############################################################
  189. # GMP is optional (unless MathSAT is used, see below)
  190. find_package(GMP QUIET)
  191. #############################################################
  192. ##
  193. ## Boost
  194. ##
  195. #############################################################
  196. # Boost Option variables
  197. set(Boost_USE_STATIC_LIBS ${USE_BOOST_STATIC_LIBRARIES})
  198. set(Boost_USE_MULTITHREADED ON)
  199. set(Boost_USE_STATIC_RUNTIME OFF)
  200. find_package(Boost 1.56.0 QUIET REQUIRED)
  201. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  202. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  203. endif ()
  204. link_directories(${Boost_LIBRARY_DIRS})
  205. include_directories(${Boost_INCLUDE_DIRS})
  206. list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES})
  207. message(STATUS "StoRM - Using Boost ${Boost_VERSION} (lib ${Boost_LIB_VERSION})")
  208. #message(STATUS "StoRM - BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  209. #message(STATUS "StoRM - BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  210. #############################################################
  211. ##
  212. ## ExprTk
  213. ##
  214. #############################################################
  215. # Use the shipped version of ExprTK
  216. message (STATUS "StoRM - Including ExprTk")
  217. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  218. #############################################################
  219. ##
  220. ## Z3 (optional)
  221. ##
  222. #############################################################
  223. find_package(Z3 QUIET)
  224. # Z3 Defines
  225. set(STORM_HAVE_Z3 ${Z3_FOUND})
  226. if(Z3_FOUND)
  227. message (STATUS "StoRM - Linking with Z3")
  228. include_directories(${Z3_INCLUDE_DIRS})
  229. list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES})
  230. endif(Z3_FOUND)
  231. #############################################################
  232. ##
  233. ## glpk
  234. ##
  235. #############################################################
  236. find_package(GLPK QUIET)
  237. if(GLPK_FOUND)
  238. message (STATUS "StoRM - Using system version of GLPK")
  239. else()
  240. message (STATUS "StoRM - Using shipped version of GLPK")
  241. set(GLPK_LIBRARIES ${CMAKE_BINARY_DIR}/resources/3rdparty/glpk-4.57/lib/libglpk${DYNAMIC_EXT})
  242. set(GLPK_INCLUDE_DIR ${CMAKE_BINARY_DIR}/resources/3rdparty/glpk-4.57/include)
  243. set(GLPK_VERSION_STRING 4.57)
  244. add_dependencies(resources glpk)
  245. endif()
  246. # Since there is a shipped version, always use GLPK
  247. set(STORM_HAVE_GLPK ON)
  248. message (STATUS "StoRM - Linking with glpk ${GLPK_VERSION_STRING}")
  249. include_directories(${GLPK_INCLUDE_DIR})
  250. list(APPEND STORM_LINK_LIBRARIES ${GLPK_LIBRARIES})
  251. #############################################################
  252. ##
  253. ## Gurobi (optional)
  254. ##
  255. #############################################################
  256. if (STORM_USE_GUROBI)
  257. find_package(Gurobi QUIET REQUIRED)
  258. set(STORM_HAVE_GUROBI ${GUROBI_FOUND})
  259. if (GUROBI_FOUND)
  260. message (STATUS "StoRM - Linking with Gurobi")
  261. include_directories(${GUROBI_INCLUDE_DIRS})
  262. list(APPEND STORM_LINK_LIBRARIES ${GUROBI_LIBRARY})
  263. #link_directories("${GUROBI_ROOT}/lib")
  264. else()
  265. #message(FATAL_ERROR "StoRM - Gurobi was requested, but not found!")
  266. endif()
  267. else()
  268. set(STORM_HAVE_GUROBI OFF)
  269. endif()
  270. #############################################################
  271. ##
  272. ## CUDD
  273. ##
  274. #############################################################
  275. # Do not use system CUDD, StoRM has a modified version
  276. set(CUDD_INCLUDE_DIR ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/include)
  277. set(CUDD_SHARED_LIBRARY ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/lib/libcudd${DYNAMIC_EXT})
  278. set(CUDD_STATIC_LIBRARY ${CMAKE_BINARY_DIR}/resources/3rdparty/cudd-3.0.0/lib/libcudd${STATIC_EXT})
  279. set(CUDD_VERSION_STRING 3.0.0)
  280. list(APPEND STORM_LINK_LIBRARIES ${CUDD_SHARED_LIBRARY})
  281. add_dependencies(resources cudd3)
  282. message(STATUS "StoRM - Linking with CUDD ${CUDD_VERSION_STRING}")
  283. #message("StoRM - CUDD include dir: ${CUDD_INCLUDE_DIR}")
  284. include_directories(${CUDD_INCLUDE_DIR})
  285. #############################################################
  286. ##
  287. ## CLN
  288. ##
  289. #############################################################
  290. find_package(CLN QUIET)
  291. if(CLN_FOUND)
  292. set(STORM_HAVE_CLN ON)
  293. message(STATUS "StoRM - Linking with CLN ${CLN_VERSION_STRING}")
  294. include_directories("${CLN_INCLUDE_DIR}")
  295. list(APPEND STORM_LINK_LIBRARIES ${CLN_LIBRARIES})
  296. else()
  297. set(STORM_HAVE_CLN OFF)
  298. if(NOT GMP_FOUND)
  299. message(FATAL_ERROR "StoRM - Neither CLN nor GMP found")
  300. endif()
  301. endif()
  302. #############################################################
  303. ##
  304. ## carl
  305. ##
  306. #############################################################
  307. set(STORM_HAVE_CARL OFF)
  308. if(USE_CARL)
  309. find_package(carl QUIET REQUIRED)
  310. if(carl_FOUND)
  311. set(STORM_HAVE_CARL ON)
  312. message(STATUS "StoRM - Linking with carl ${carl_VERSION_STRING}")
  313. include_directories("${carl_INCLUDE_DIR}")
  314. list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES})
  315. else()
  316. message(FATAL_ERROR "StoRM - CARL was requested but not found")
  317. endif()
  318. endif()
  319. #############################################################
  320. ##
  321. ## SMT-RAT
  322. ##
  323. #############################################################
  324. set(STORM_HAVE_SMTRAT OFF)
  325. if(USE_SMTRAT)
  326. find_package(smtrat QUIET REQUIRED)
  327. if(smtrat_FOUND)
  328. set(STORM_HAVE_SMTRAT ON)
  329. message(STATUS "StoRM - Linking with smtrat.")
  330. include_directories("${smtrat_INCLUDE_DIR}")
  331. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  332. else()
  333. message(FATAL_ERROR "StoRM - SMT-RAT was requested but not found")
  334. endif()
  335. endif()
  336. #############################################################
  337. ##
  338. ## HyPro
  339. ##
  340. #############################################################
  341. set(STORM_HAVE_HYPRO OFF)
  342. if(USE_HYPRO)
  343. find_package(hypro QUIET REQUIRED)
  344. if(hypro_FOUND)
  345. set(STORM_HAVE_HYPRO ON)
  346. message(STATUS "StoRM - Linking with hypro ${hypro_VERSION_STRING}")
  347. include_directories("${hypro_INCLUDE_DIR}")
  348. link_directories( /Users/tim/hypro/build )
  349. list(APPEND STORM_LINK_LIBRARIES ${hypro_LIBRARIES})
  350. else()
  351. message(FATAL_ERROR "StoRM - HyPro was requested but not found")
  352. endif()
  353. endif()
  354. #############################################################
  355. ##
  356. ## GiNaC
  357. ##
  358. #############################################################
  359. find_package(GiNaC QUIET)
  360. if(GINAC_FOUND)
  361. set(STORM_HAVE_GINAC ON)
  362. message(STATUS "StoRM - Linking with GiNaC ${GINAC_VERSION_STRING}")
  363. # Right now only link with GiNaC for carl
  364. #include_directories("${GINAC_INCLUDE_DIR}")
  365. list(APPEND STORM_LINK_LIBRARIES ${GINAC_LIBRARIES})
  366. else()
  367. set(STORM_HAVE_GINAC OFF)
  368. #TODO: Check if CARL actually requires the use of GiNaC
  369. endif()
  370. #############################################################
  371. ##
  372. ## MathSAT (optional)
  373. ##
  374. #############################################################
  375. if ("${MSAT_ROOT}" STREQUAL "")
  376. set(ENABLE_MSAT OFF)
  377. else()
  378. set(ENABLE_MSAT ON)
  379. endif()
  380. # MathSAT Defines
  381. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  382. if (ENABLE_MSAT)
  383. message (STATUS "StoRM - Linking with MathSAT")
  384. link_directories("${MSAT_ROOT}/lib")
  385. include_directories("${MSAT_ROOT}/include")
  386. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  387. if(GMP_FOUND)
  388. include_directories("${GMP_INCLUDE_DIR}")
  389. list(APPEND STORM_LINK_LIBRARIES "gmp")
  390. elseif(MPIR_FOUND)
  391. include_directories("${GMP_INCLUDE_DIR}")
  392. list(APPEND STORM_LINK_LIBRARIES "mpir" "mpirxx")
  393. else(GMP_FOUND)
  394. message(FATAL_ERROR "GMP is required for MathSAT, but was not found!")
  395. endif(GMP_FOUND)
  396. endif(ENABLE_MSAT)
  397. #############################################################
  398. ##
  399. ## Xerces
  400. ##
  401. #############################################################
  402. if(USE_XERCES)
  403. find_package(Xerces QUIET REQUIRED)
  404. if(XERCES_FOUND)
  405. message(STATUS "StoRM - Use system version of xerces")
  406. else()
  407. message(STATUS "StoRM - Use shipped version of xerces")
  408. set(XERCES_ROOT ${CMAKE_BINARY_DIR}/resources/3rdparty/xercesc-3.1.2)
  409. set(XERCESC_INCLUDE ${XERCES_ROOT}/include)
  410. set(XERCES_LIBRARY_PATH ${XERCES_ROOT}/lib)
  411. set(XERCESC_LIBRARIES ${XERCES_LIBRARY_PATH}/libxerces-c.a)
  412. add_dependencies(resources xercesc)
  413. endif()
  414. message (STATUS "StoRM - Linking with xercesc")
  415. set(STORM_HAVE_XERCES ON)
  416. include_directories(${XERCESC_INCLUDE})
  417. list(APPEND STORM_LINK_LIBRARIES ${XERCESC_LIBRARIES})
  418. endif(USE_XERCES)
  419. #############################################################
  420. ##
  421. ## Sylvan
  422. ##
  423. #############################################################
  424. message(STATUS "StoRM - Using shipped version of sylvan")
  425. message(STATUS "StoRM - Linking with sylvan")
  426. include_directories("${Sylvan_INCLUDE_DIR}")
  427. list(APPEND STORM_LINK_LIBRARIES ${Sylvan_LIBRARY})
  428. add_dependencies(resources sylvan)
  429. if(${OPERATING_SYSTEM} MATCHES "Linux")
  430. find_package(Hwloc QUIET REQUIRED)
  431. if(Hwloc_FOUND)
  432. message(STATUS "StoRM - Linking with hwloc ${Hwloc_VERSION}")
  433. list(APPEND STORM_LINK_LIBRARIES ${Hwloc_LIBRARIES})
  434. else()
  435. message(FATAL_ERROR "HWLOC is required but was not found.")
  436. endif()
  437. endif()
  438. #############################################################
  439. ##
  440. ## Google Test gtest
  441. ##
  442. #############################################################
  443. add_dependencies(test-resources googletest)
  444. list(APPEND STORM_TEST_LINK_LIBRARIES ${GTEST_LIBRARIES})
  445. #############################################################
  446. ##
  447. ## Intel Threading Building Blocks (optional)
  448. ##
  449. #############################################################
  450. set(STORM_HAVE_INTELTBB OFF)
  451. if (STORM_USE_INTELTBB)
  452. # Point to shipped TBB directory
  453. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  454. find_package(TBB QUIET REQUIRED)
  455. if (TBB_FOUND)
  456. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  457. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  458. set(STORM_HAVE_INTELTBB ON)
  459. link_directories(${TBB_LIBRARY_DIRS})
  460. include_directories(${TBB_INCLUDE_DIRS})
  461. list(APPEND STORM_LINK_LIBRARIES tbb tbbmalloc)
  462. else(TBB_FOUND)
  463. message(FATAL_ERROR "StoRM - TBB was requested, but not found!")
  464. endif(TBB_FOUND)
  465. endif(STORM_USE_INTELTBB)
  466. #############################################################
  467. ##
  468. ## Threads
  469. ##
  470. #############################################################
  471. find_package(Threads QUIET REQUIRED)
  472. if (NOT Threads_FOUND)
  473. message(FATAL_ERROR "StoRM - Threads was requested, but not found!")
  474. endif()
  475. include_directories(${THREADS_INCLUDE_DIRS})
  476. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  477. if (STORM_USE_COTIRE)
  478. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  479. endif(STORM_USE_COTIRE)
  480. if (MSVC)
  481. # Add the DebugHelper DLL
  482. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  483. target_link_libraries(storm "Dbghelp.lib")
  484. endif(MSVC)
  485. #############################################################
  486. ##
  487. ## CUDA Library generation
  488. ##
  489. #############################################################
  490. if ("${CUDA_ROOT}" STREQUAL "")
  491. set(ENABLE_CUDA OFF)
  492. else()
  493. set(ENABLE_CUDA ON)
  494. endif()
  495. # CUDA Defines
  496. if (ENABLE_CUDA)
  497. set(STORM_CPP_CUDA_DEF "define")
  498. else()
  499. set(STORM_CPP_CUDA_DEF "undef")
  500. endif()
  501. # CUDA Defines
  502. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  503. if(ENABLE_CUDA)
  504. # Test for type alignment
  505. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  506. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  507. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  508. )
  509. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  510. 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}")
  511. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  512. message(STATUS "StoRM (CudaPlugin) - Result of Type Alignment Check: OK.")
  513. else()
  514. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  515. endif()
  516. # Test for Float 64bit Alignment
  517. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  518. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  519. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  520. )
  521. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  522. 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}")
  523. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  524. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  525. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  526. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  527. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  528. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  529. else()
  530. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  531. endif()
  532. #
  533. # Make a version file containing the current version from git.
  534. #
  535. include(GetGitRevisionDescription)
  536. git_describe_checkout(STORM_GIT_VERSION_STRING)
  537. # Parse the git Tag into variables
  538. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  539. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  540. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  541. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  542. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  543. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  544. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  545. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  546. else()
  547. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  548. endif()
  549. 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})")
  550. # Configure a header file to pass some of the CMake settings to the source code
  551. configure_file (
  552. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  553. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  554. )
  555. #create library
  556. find_package(CUDA REQUIRED)
  557. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  558. find_package(Cusp REQUIRED)
  559. find_package(Thrust REQUIRED)
  560. set(STORM_CUDA_LIB_NAME "storm-cuda")
  561. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  562. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  563. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  564. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  565. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  566. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  567. #############################################################
  568. ##
  569. ## CUSP
  570. ##
  571. #############################################################
  572. if(CUSP_FOUND)
  573. include_directories(${CUSP_INCLUDE_DIR})
  574. cuda_include_directories(${CUSP_INCLUDE_DIR})
  575. message(STATUS "StoRM (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}")
  576. else()
  577. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find CUSP!")
  578. endif()
  579. #############################################################
  580. ##
  581. ## Thrust
  582. ##
  583. #############################################################
  584. if(THRUST_FOUND)
  585. include_directories(${THRUST_INCLUDE_DIR})
  586. cuda_include_directories(${THRUST_INCLUDE_DIR})
  587. message(STATUS "StoRM (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}")
  588. else()
  589. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find Thrust! Check your CUDA installation.")
  590. endif()
  591. include_directories(${CUDA_INCLUDE_DIRS})
  592. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  593. cuda_add_library(${STORM_CUDA_LIB_NAME}
  594. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  595. )
  596. message (STATUS "StoRM - Linking with CUDA")
  597. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  598. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  599. endif()
  600. #############################################################
  601. ##
  602. ## Cotire
  603. ##
  604. #############################################################
  605. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  606. if (STORM_USE_COTIRE)
  607. # Include Cotire for PCH Generation
  608. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  609. include(cotire)
  610. cotire(storm)
  611. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  612. #cotire(storm-functional-tests)
  613. #cotire(storm-performance-tests)
  614. endif()
  615. #############################################################
  616. ##
  617. ## libc++abi
  618. ##
  619. #############################################################
  620. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  621. if (LINK_LIBCXXABI)
  622. message (STATUS "StoRM - Linking against libc++abi.")
  623. target_link_libraries(storm "c++abi")
  624. endif(LINK_LIBCXXABI)
  625. #############################################################
  626. ##
  627. ## Doxygen
  628. ##
  629. #############################################################
  630. find_package(Doxygen REQUIRED)
  631. # Add a target to generate API documentation with Doxygen
  632. if(DOXYGEN_FOUND)
  633. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  634. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  635. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  636. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  637. endif(DOXYGEN_FOUND)
  638. #############################################################
  639. ##
  640. ## CMake-generated Config File for StoRM
  641. ##
  642. #############################################################
  643. #
  644. # Make a version file containing the current version from git.
  645. #
  646. include(GetGitRevisionDescription)
  647. git_describe_checkout(STORM_GIT_VERSION_STRING)
  648. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  649. # Parse the git Tag into variables
  650. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  651. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  652. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  653. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  654. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  655. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  656. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  657. set(STORM_CPP_VERSION_DIRTY 1)
  658. else()
  659. set(STORM_CPP_VERSION_DIRTY 0)
  660. endif()
  661. 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})")
  662. # Configure a header file to pass some of the CMake settings to the source code
  663. configure_file (
  664. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  665. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  666. )
  667. # Configure a header file to pass the storm version to the source code
  668. configure_file (
  669. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  670. "${PROJECT_SOURCE_DIR}/src/utility/storm-version.cpp"
  671. )
  672. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  673. # Add the binary dir include directory for storm-config.h
  674. include_directories("${PROJECT_BINARY_DIR}/include")
  675. add_subdirectory(src)
  676. add_subdirectory(test)
  677. #############################################################
  678. ##
  679. ## memcheck targets
  680. ##
  681. #############################################################
  682. 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)
  683. 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)
  684. 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)
  685. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  686. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  687. include(StormCPackConfig.cmake)