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.

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