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.

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