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.

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