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.

745 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. message("${carl_INCLUDE_DIR}")
  372. include_directories("${carl_INCLUDE_DIR}")
  373. list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES})
  374. endif()
  375. #############################################################
  376. ##
  377. ## SMT-RAT
  378. ##
  379. #############################################################
  380. if(STORM_HAVE_SMTRAT)
  381. message(STATUS "StoRM - Linking with smtrat.")
  382. include_directories("${smtrat_INCLUDE_DIR}")
  383. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  384. endif()
  385. #############################################################
  386. ##
  387. ## MathSAT (optional)
  388. ##
  389. #############################################################
  390. if ("${MSAT_ROOT}" STREQUAL "")
  391. set(ENABLE_MSAT OFF)
  392. else()
  393. set(ENABLE_MSAT ON)
  394. endif()
  395. # MathSAT Defines
  396. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  397. if (ENABLE_MSAT)
  398. link_directories("${MSAT_ROOT}/lib")
  399. message (STATUS "StoRM - Linking with MathSAT")
  400. include_directories("${MSAT_ROOT}/include")
  401. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  402. if(GMP_FOUND)
  403. include_directories("${GMP_INCLUDE_DIR}")
  404. list(APPEND STORM_LINK_LIBRARIES "gmp")
  405. elseif(MPIR_FOUND)
  406. include_directories("${GMP_INCLUDE_DIR}")
  407. list(APPEND STORM_LINK_LIBRARIES "mpir" "mpirxx")
  408. else(GMP_FOUND)
  409. message(FATAL_ERROR "GMP is required for MathSAT, but was not found!")
  410. endif(GMP_FOUND)
  411. endif(ENABLE_MSAT)
  412. #############################################################
  413. ##
  414. ## Xerces
  415. ##
  416. #############################################################
  417. find_package(Xerces)
  418. if(NOT XERCES_FOUND)
  419. message("Use shipped version of xerces")
  420. set(XERCES_ROOT ${CMAKE_BINARY_DIR}/resources/3rdparty/xercesc-3.1.2)
  421. set(XERCESC_INCLUDE ${XERCES_ROOT}/include)
  422. set(XERCES_LIBRARY_PATH ${XERCES_ROOT}/lib)
  423. set(XERCESC_LIBRARIES ${XERCES_LIBRARY_PATH}/libxerces-c.a)
  424. endif()
  425. set(STORM_HAVE_XERCES TRUE)
  426. if(STORM_HAVE_XERCES)
  427. include_directories(${XERCESC_INCLUDE})
  428. list(APPEND STORM_LINK_LIBRARIES ${XERCESC_LIBRARIES})
  429. endif()
  430. #############################################################
  431. ##
  432. ## Sylvan
  433. ##
  434. #############################################################
  435. include(ExternalProject)
  436. set(STORM_SYLVAN_ROOT "${PROJECT_SOURCE_DIR}/resources/3rdparty/sylvan")
  437. ExternalProject_Add(
  438. sylvan
  439. DOWNLOAD_COMMAND ""
  440. PREFIX "sylvan"
  441. SOURCE_DIR "${STORM_SYLVAN_ROOT}"
  442. CMAKE_ARGS -DSYLVAN_BUILD_TEST=Off -DSYLVAN_BUILD_EXAMPLES=Off -DCMAKE_BUILD_TYPE=Release
  443. BINARY_DIR "${PROJECT_BINARY_DIR}/sylvan"
  444. INSTALL_COMMAND ""
  445. INSTALL_DIR "${PROJECT_BINARY_DIR}/sylvan"
  446. )
  447. ExternalProject_Get_Property(sylvan binary_dir)
  448. set(Sylvan_INCLUDE_DIR "${STORM_SYLVAN_ROOT}/src")
  449. message(STATUS "Linking with shipped version of sylvan (in directory ${STORM_SYLVAN_ROOT}).")
  450. include_directories("${Sylvan_INCLUDE_DIR}")
  451. list(APPEND STORM_LINK_LIBRARIES "${binary_dir}/src/libsylvan.a")
  452. if(${OPERATING_SYSTEM} MATCHES "Linux")
  453. find_package(Hwloc QUIET)
  454. if(NOT Hwloc_FOUND)
  455. message(SEND_ERROR "HWLOC is required but was not found.")
  456. else()
  457. list(APPEND STORM_LINK_LIBRARIES ${Hwloc_LIBRARIES})
  458. endif()
  459. endif()
  460. #############################################################
  461. ##
  462. ## Google Test gtest
  463. ##
  464. #############################################################
  465. set(gtest_force_shared_crt ON)
  466. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.7.0")
  467. #############################################################
  468. ##
  469. ## Log4CPlus
  470. ##
  471. #############################################################
  472. set(BUILD_SHARED_LIBS OFF CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  473. set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF)
  474. set(LOG4CPLUS_BUILD_TESTING OFF)
  475. set(LOG4CPLUS_USE_UNICODE OFF)
  476. set(LOG4CPLUS_DEFINE_INSTALL_TARGET OFF)
  477. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1")
  478. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include")
  479. include_directories("${PROJECT_BINARY_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") # This adds the defines.hxx file
  480. list(APPEND STORM_LINK_LIBRARIES log4cplusS)
  481. if (UNIX AND NOT APPLE)
  482. list(APPEND STORM_LINK_LIBRARIES rt)
  483. endif(UNIX AND NOT APPLE)
  484. #############################################################
  485. ##
  486. ## Intel Threading Building Blocks (optional)
  487. ##
  488. #############################################################
  489. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  490. find_package(TBB)
  491. if (TBB_FOUND AND STORM_USE_INTELTBB)
  492. link_directories(${TBB_LIBRARY_DIRS})
  493. set(STORM_CPP_INTELTBB_DEF "define")
  494. else()
  495. set(STORM_CPP_INTELTBB_DEF "undef")
  496. endif()
  497. if (TBB_FOUND)
  498. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  499. if (STORM_USE_INTELTBB)
  500. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  501. include_directories(${TBB_INCLUDE_DIRS})
  502. target_link_libraries(storm tbb tbbmalloc)
  503. endif(STORM_USE_INTELTBB)
  504. endif(TBB_FOUND)
  505. #############################################################
  506. ##
  507. ## Threads
  508. ##
  509. #############################################################
  510. find_package(Threads REQUIRED)
  511. include_directories(${THREADS_INCLUDE_DIRS})
  512. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  513. if (STORM_USE_COTIRE)
  514. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  515. endif(STORM_USE_COTIRE)
  516. if (MSVC)
  517. # Add the DebugHelper DLL
  518. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  519. target_link_libraries(storm "Dbghelp.lib")
  520. endif(MSVC)
  521. #############################################################
  522. ##
  523. ## Cotire
  524. ##
  525. #############################################################
  526. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  527. if (STORM_USE_COTIRE)
  528. # Include Cotire for PCH Generation
  529. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  530. include(cotire)
  531. cotire(storm)
  532. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  533. #cotire(storm-functional-tests)
  534. #cotire(storm-performance-tests)
  535. endif()
  536. #############################################################
  537. ##
  538. ## libc++abi
  539. ##
  540. #############################################################
  541. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  542. if (LINK_LIBCXXABI)
  543. message (STATUS "StoRM - Linking against libc++abi.")
  544. target_link_libraries(storm "c++abi")
  545. endif(LINK_LIBCXXABI)
  546. #############################################################
  547. ##
  548. ## Doxygen
  549. ##
  550. #############################################################
  551. find_package(Doxygen REQUIRED)
  552. # Add a target to generate API documentation with Doxygen
  553. if(DOXYGEN_FOUND)
  554. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  555. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  556. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  557. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  558. endif(DOXYGEN_FOUND)
  559. #############################################################
  560. ##
  561. ## CMake-generated Config File for StoRM
  562. ##
  563. #############################################################
  564. #
  565. # Make a version file containing the current version from git.
  566. #
  567. include(GetGitRevisionDescription)
  568. git_describe_checkout(STORM_GIT_VERSION_STRING)
  569. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  570. # Parse the git Tag into variables
  571. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  572. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  573. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  574. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  575. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  576. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  577. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  578. set(STORM_CPP_VERSION_DIRTY 1)
  579. else()
  580. set(STORM_CPP_VERSION_DIRTY 0)
  581. endif()
  582. 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})")
  583. # Configure a header file to pass some of the CMake settings to the source code
  584. configure_file (
  585. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  586. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  587. )
  588. # Configure a header file to pass the storm version to the source code
  589. configure_file (
  590. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  591. "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp"
  592. )
  593. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  594. # Add the binary dir include directory for storm-config.h
  595. include_directories("${PROJECT_BINARY_DIR}/include")
  596. add_subdirectory(resources/3rdparty)
  597. add_subdirectory(src)
  598. add_subdirectory(test)
  599. #############################################################
  600. ##
  601. ## memcheck targets
  602. ##
  603. #############################################################
  604. 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)
  605. 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)
  606. 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)
  607. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  608. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  609. include(StormCPackConfig.cmake)