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.

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