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.

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