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.

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