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. # 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. message(STATUS "StoRM - CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}")
  39. if(STORM_COMPILE_WITH_CCACHE)
  40. find_program(CCACHE_FOUND ccache)
  41. if(CCACHE_FOUND)
  42. message(STATUS "SToRM - Using ccache")
  43. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  44. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  45. else()
  46. message(STATUS "Could not find ccache")
  47. endif()
  48. endif()
  49. # Base path for test files
  50. set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test")
  51. # Auto-detect operating system.
  52. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  53. # Mac OS
  54. set(OPERATING_SYSTEM "Mac OS")
  55. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  56. # Linux
  57. set(OPERATING_SYSTEM "Linux")
  58. else()
  59. # Assuming Windows.
  60. set(OPERATING_SYSTEM "Windows")
  61. ENDIF()
  62. message(STATUS "Detected operating system: ${OPERATING_SYSTEM}")
  63. #############################################################
  64. ##
  65. ## Compiler specific settings and definitions
  66. ##
  67. #############################################################
  68. # Path to the no-strict-aliasing target
  69. set(CONVERSIONHELPER_TARGET "${PROJECT_SOURCE_DIR}/src/utility/ConversionHelper.cpp")
  70. if(CMAKE_COMPILER_IS_GNUCC)
  71. set(STORM_COMPILED_BY "GCC")
  72. # Set standard flags for GCC
  73. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  74. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops")
  75. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  76. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
  77. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
  78. # Turn on popcnt instruction if desired (yes by default)
  79. if (STORM_USE_POPCNT)
  80. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  81. endif(STORM_USE_POPCNT)
  82. # Set the no-strict-aliasing target for GCC
  83. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing")
  84. elseif(MSVC)
  85. set(STORM_COMPILED_BY "MSVC")
  86. # required for GMM to compile, ugly error directive in their code
  87. add_definitions(/D_SCL_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS)
  88. # 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)
  89. add_definitions(/bigobj)
  90. # required by GTest and PrismGrammar::createIntegerVariable
  91. add_definitions(/D_VARIADIC_MAX=10)
  92. # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max
  93. add_definitions(/DNOMINMAX)
  94. # Boost Defs, required for using boost's transform iterator
  95. add_definitions(/DBOOST_RESULT_OF_USE_DECLTYPE)
  96. # since nobody cares at the moment
  97. add_definitions(/wd4250)
  98. # MSVC does not do strict-aliasing, so no option needed
  99. else(CLANG)
  100. set(STORM_COMPILED_BY "Clang (LLVM)")
  101. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  102. set (CLANG ON)
  103. # Set standard flags for clang
  104. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O3")
  105. if(UNIX AND NOT APPLE AND NOT USE_LIBCXX)
  106. set(CLANG_STDLIB libstdc++)
  107. message(STATUS "StoRM - Linking against libstdc++")
  108. else()
  109. set(CLANG_STDLIB libc++)
  110. message(STATUS "StoRM - Linking against libc++")
  111. # Disable Cotire
  112. set(STORM_USE_COTIRE OFF)
  113. # Set up some Xcode specific settings
  114. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
  115. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  116. endif()
  117. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  118. 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")
  119. if(FORCE_COLOR)
  120. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  121. endif()
  122. # Turn on popcnt instruction if desired (yes by default)
  123. if (STORM_USE_POPCNT)
  124. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  125. endif(STORM_USE_POPCNT)
  126. # Set the no-strict-aliasing target for Clang
  127. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
  128. endif()
  129. if(CCACHE_FOUND)
  130. set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)")
  131. endif()
  132. message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}")
  133. #############################################################
  134. ##
  135. ## Inclusion of required libraries
  136. ##
  137. #############################################################
  138. # Add the version of Eigen3 in the repository to the include pathes
  139. set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen")
  140. include_directories(${EIGEN3_INCLUDE_DIR})
  141. # Add the version of GMM in the repository to the include pathes
  142. set(GMMXX_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include")
  143. include_directories(${GMMXX_INCLUDE_DIR})
  144. find_package(GMP)
  145. #############################################################
  146. ##
  147. ## Boost
  148. ##
  149. #############################################################
  150. # Boost Option variables
  151. set(Boost_USE_STATIC_LIBS ON)
  152. set(Boost_USE_MULTITHREADED ON)
  153. set(Boost_USE_STATIC_RUNTIME OFF)
  154. # If a custom boost root directory was specified, we set the corresponding hint for the script to find it.
  155. if(CUSTOM_BOOST_ROOT)
  156. message(STATUS "StoRM - Using Boost from CUSTOM_BOOST_ROOT located at ${CUSTOM_BOOST_ROOT}")
  157. set(BOOST_ROOT "${CUSTOM_BOOST_ROOT}")
  158. endif(CUSTOM_BOOST_ROOT)
  159. find_package(Boost REQUIRED)
  160. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  161. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  162. endif ()
  163. link_directories(${Boost_LIBRARY_DIRS})
  164. include_directories(${Boost_INCLUDE_DIRS})
  165. list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES})
  166. #message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  167. #message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  168. #############################################################
  169. ##
  170. ## ExprTk
  171. ##
  172. #############################################################
  173. message (STATUS "StoRM - Including ExprTk")
  174. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  175. #############################################################
  176. ##
  177. ## Z3 (optional)
  178. ##
  179. #############################################################
  180. find_package(Z3 QUIET)
  181. # Z3 Defines
  182. set(STORM_HAVE_Z3 ${Z3_FOUND})
  183. if(STORM_HAVE_Z3)
  184. message (STATUS "StoRM - Linking with Z3")
  185. include_directories(${Z3_INCLUDE_DIRS})
  186. list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES})
  187. endif(STORM_HAVE_Z3)
  188. #############################################################
  189. ##
  190. ## glpk
  191. ##
  192. #############################################################
  193. set(STORM_HAVE_GLPK 1)
  194. message (STATUS "StoRM - Linking with glpk")
  195. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/glpk-4.53")
  196. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/glpk-4.53/src")
  197. list(APPEND STORM_LINK_LIBRARIES "glpk")
  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("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. set(gtest_force_shared_crt ON)
  465. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.7.0")
  466. #############################################################
  467. ##
  468. ## Log4CPlus
  469. ##
  470. #############################################################
  471. set(BUILD_SHARED_LIBS OFF CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  472. set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF)
  473. set(LOG4CPLUS_BUILD_TESTING OFF)
  474. set(LOG4CPLUS_USE_UNICODE OFF)
  475. set(LOG4CPLUS_DEFINE_INSTALL_TARGET OFF)
  476. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1")
  477. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include")
  478. include_directories("${PROJECT_BINARY_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") # This adds the defines.hxx file
  479. list(APPEND STORM_LINK_LIBRARIES log4cplusS)
  480. if (UNIX AND NOT APPLE)
  481. list(APPEND STORM_LINK_LIBRARIES rt)
  482. endif(UNIX AND NOT APPLE)
  483. #############################################################
  484. ##
  485. ## Intel Threading Building Blocks (optional)
  486. ##
  487. #############################################################
  488. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  489. find_package(TBB)
  490. if (TBB_FOUND AND STORM_USE_INTELTBB)
  491. link_directories(${TBB_LIBRARY_DIRS})
  492. set(STORM_CPP_INTELTBB_DEF "define")
  493. else()
  494. set(STORM_CPP_INTELTBB_DEF "undef")
  495. endif()
  496. if (TBB_FOUND)
  497. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  498. if (STORM_USE_INTELTBB)
  499. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  500. include_directories(${TBB_INCLUDE_DIRS})
  501. target_link_libraries(storm tbb tbbmalloc)
  502. endif(STORM_USE_INTELTBB)
  503. endif(TBB_FOUND)
  504. #############################################################
  505. ##
  506. ## Threads
  507. ##
  508. #############################################################
  509. find_package(Threads REQUIRED)
  510. include_directories(${THREADS_INCLUDE_DIRS})
  511. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  512. if (STORM_USE_COTIRE)
  513. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  514. endif(STORM_USE_COTIRE)
  515. if (MSVC)
  516. # Add the DebugHelper DLL
  517. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  518. target_link_libraries(storm "Dbghelp.lib")
  519. endif(MSVC)
  520. #############################################################
  521. ##
  522. ## Cotire
  523. ##
  524. #############################################################
  525. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  526. if (STORM_USE_COTIRE)
  527. # Include Cotire for PCH Generation
  528. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  529. include(cotire)
  530. cotire(storm)
  531. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  532. #cotire(storm-functional-tests)
  533. #cotire(storm-performance-tests)
  534. endif()
  535. #############################################################
  536. ##
  537. ## libc++abi
  538. ##
  539. #############################################################
  540. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  541. if (LINK_LIBCXXABI)
  542. message (STATUS "StoRM - Linking against libc++abi.")
  543. target_link_libraries(storm "c++abi")
  544. endif(LINK_LIBCXXABI)
  545. #############################################################
  546. ##
  547. ## Doxygen
  548. ##
  549. #############################################################
  550. find_package(Doxygen REQUIRED)
  551. # Add a target to generate API documentation with Doxygen
  552. if(DOXYGEN_FOUND)
  553. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  554. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  555. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  556. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  557. endif(DOXYGEN_FOUND)
  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)