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.

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