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.

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