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.

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