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.

782 lines
28 KiB

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