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.

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