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.

680 lines
25 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 -ftemplate-depth=1024")
  107. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
  108. if(FORCE_COLOR)
  109. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  110. endif()
  111. # Turn on popcnt instruction if desired (yes by default)
  112. if (STORM_USE_POPCNT)
  113. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  114. endif(STORM_USE_POPCNT)
  115. # Set the no-strict-aliasing target for Clang
  116. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
  117. endif()
  118. if(CCACHE_FOUND)
  119. set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)")
  120. endif()
  121. message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}")
  122. #############################################################
  123. ##
  124. ## Inclusion of required libraries
  125. ##
  126. #############################################################
  127. # Add the version of Eigen3 in the repository to the include pathes
  128. set(EIGEN3_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen")
  129. include_directories(${EIGEN3_INCLUDE_DIR})
  130. # Add the version of GMM in the repository to the include pathes
  131. set(GMMXX_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-5.0/include")
  132. include_directories(${GMMXX_INCLUDE_DIR})
  133. find_package(GMP)
  134. #############################################################
  135. ##
  136. ## Boost
  137. ##
  138. #############################################################
  139. # Boost Option variables
  140. set(Boost_USE_STATIC_LIBS ON)
  141. set(Boost_USE_MULTITHREADED ON)
  142. set(Boost_USE_STATIC_RUNTIME OFF)
  143. # If a custom boost root directory was specified, we set the corresponding hint for the script to find it.
  144. if(CUSTOM_BOOST_ROOT)
  145. message(STATUS "StoRM - Using Boost from CUSTOM_BOOST_ROOT located at ${CUSTOM_BOOST_ROOT}")
  146. set(BOOST_ROOT "${CUSTOM_BOOST_ROOT}")
  147. endif(CUSTOM_BOOST_ROOT)
  148. find_package(Boost REQUIRED)
  149. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  150. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  151. endif ()
  152. link_directories(${Boost_LIBRARY_DIRS})
  153. include_directories(${Boost_INCLUDE_DIRS})
  154. list(APPEND STORM_LINK_LIBRARIES ${Boost_LIBRARIES})
  155. #message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  156. #message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  157. #############################################################
  158. ##
  159. ## ExprTk
  160. ##
  161. #############################################################
  162. message (STATUS "StoRM - Including ExprTk")
  163. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/exprtk")
  164. #############################################################
  165. ##
  166. ## Z3 (optional)
  167. ##
  168. #############################################################
  169. find_package(Z3 QUIET)
  170. # Z3 Defines
  171. set(STORM_HAVE_Z3 ${Z3_FOUND})
  172. if(STORM_HAVE_Z3)
  173. message (STATUS "StoRM - Linking with Z3")
  174. include_directories(${Z3_INCLUDE_DIRS})
  175. list(APPEND STORM_LINK_LIBRARIES ${Z3_LIBRARIES})
  176. endif(STORM_HAVE_Z3)
  177. #############################################################
  178. ##
  179. ## glpk
  180. ##
  181. #############################################################
  182. set(STORM_HAVE_GLPK 1)
  183. message (STATUS "StoRM - Linking with glpk")
  184. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/glpk-4.53")
  185. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/glpk-4.53/src")
  186. list(APPEND STORM_LINK_LIBRARIES "glpk")
  187. #############################################################
  188. ##
  189. ## Gurobi (optional)
  190. ##
  191. #############################################################
  192. find_package(Gurobi)
  193. if ("${GUROBI_ROOT}" STREQUAL "" AND NOT GUROBI_FOUND)
  194. set(ENABLE_GUROBI OFF)
  195. else()
  196. set(ENABLE_GUROBI ON)
  197. endif()
  198. # Gurobi Defines
  199. set(STORM_HAVE_GUROBI ${ENABLE_GUROBI})
  200. if (ENABLE_GUROBI)
  201. if (NOT GUROBI_FOUND)
  202. message(FATAL_ERROR "Gurobi was requested, but not found!")
  203. endif()
  204. message (STATUS "StoRM - Linking with Gurobi (include: ${GUROBI_INCLUDE_DIRS})")
  205. include_directories(${GUROBI_INCLUDE_DIRS})
  206. list(APPEND STORM_LINK_LIBRARIES ${GUROBI_LIBRARY})
  207. #link_directories("${GUROBI_ROOT}/lib")
  208. endif()
  209. #############################################################
  210. ##
  211. ## CUDA Library generation
  212. ##
  213. #############################################################
  214. if ("${CUDA_ROOT}" STREQUAL "")
  215. set(ENABLE_CUDA OFF)
  216. else()
  217. set(ENABLE_CUDA ON)
  218. endif()
  219. # CUDA Defines
  220. if (ENABLE_CUDA)
  221. set(STORM_CPP_CUDA_DEF "define")
  222. else()
  223. set(STORM_CPP_CUDA_DEF "undef")
  224. endif()
  225. # CUDA Defines
  226. set(STORM_CPP_CUDAFORSTORM_DEF "undef")
  227. if(ENABLE_CUDA)
  228. # Test for type alignment
  229. try_run(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT
  230. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeAlignmentCheck.cpp"
  231. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  232. )
  233. if(NOT STORM_CUDA_COMPILE_RESULT_TYPEALIGNMENT)
  234. 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}")
  235. elseif(STORM_CUDA_RUN_RESULT_TYPEALIGNMENT EQUAL 0)
  236. message(STATUS "StoRM (CudaPlugin) - Result of Type Alignment Check: OK.")
  237. else()
  238. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_TYPEALIGNMENT})")
  239. endif()
  240. # Test for Float 64bit Alignment
  241. try_run(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT
  242. ${PROJECT_BINARY_DIR} "${PROJECT_SOURCE_DIR}/cuda/CMakeFloatAlignmentCheck.cpp"
  243. COMPILE_OUTPUT_VARIABLE OUTPUT_TEST_VAR
  244. )
  245. if(NOT STORM_CUDA_COMPILE_RESULT_FLOATALIGNMENT)
  246. 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}")
  247. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 2)
  248. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment active.")
  249. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "define")
  250. elseif(STORM_CUDA_RUN_RESULT_FLOATALIGNMENT EQUAL 3)
  251. message(STATUS "StoRM (CudaPlugin) - Result of Float Type Alignment Check: 64bit alignment disabled.")
  252. set(STORM_CUDAPLUGIN_FLOAT_64BIT_ALIGN_DEF "undef")
  253. else()
  254. message(FATAL_ERROR "StoRM (CudaPlugin) - Result of Float Type Alignment Check: FAILED (Code ${STORM_CUDA_RUN_RESULT_FLOATALIGNMENT})")
  255. endif()
  256. #
  257. # Make a version file containing the current version from git.
  258. #
  259. include(GetGitRevisionDescription)
  260. git_describe_checkout(STORM_GIT_VERSION_STRING)
  261. # Parse the git Tag into variables
  262. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CUDAPLUGIN_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  263. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  264. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  265. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CUDAPLUGIN_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  266. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CUDAPLUGIN_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  267. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CUDAPLUGIN_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  268. if ("${STORM_CUDAPLUGIN_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  269. set(STORM_CUDAPLUGIN_VERSION_DIRTY 1)
  270. else()
  271. set(STORM_CUDAPLUGIN_VERSION_DIRTY 0)
  272. endif()
  273. 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})")
  274. # Configure a header file to pass some of the CMake settings to the source code
  275. configure_file (
  276. "${PROJECT_SOURCE_DIR}/cuda/storm-cudaplugin-config.h.in"
  277. "${PROJECT_BINARY_DIR}/include/storm-cudaplugin-config.h"
  278. )
  279. #create library
  280. find_package(CUDA REQUIRED)
  281. set(CUSP_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/resources/3rdparty/cusplibrary")
  282. find_package(Cusp REQUIRED)
  283. find_package(Thrust REQUIRED)
  284. set(STORM_CUDA_LIB_NAME "storm-cuda")
  285. file(GLOB_RECURSE STORM_CUDA_KERNEL_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.cu)
  286. file(GLOB_RECURSE STORM_CUDA_HEADER_FILES ${PROJECT_SOURCE_DIR}/cuda/kernels/*.h)
  287. source_group(kernels FILES ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES})
  288. include_directories(${PROJECT_SOURCE_DIR}/cuda/kernels/)
  289. #set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  290. set(CUDA_NVCC_FLAGS "-arch=sm_30")
  291. #############################################################
  292. ##
  293. ## CUSP
  294. ##
  295. #############################################################
  296. if(CUSP_FOUND)
  297. include_directories(${CUSP_INCLUDE_DIR})
  298. cuda_include_directories(${CUSP_INCLUDE_DIR})
  299. message(STATUS "StoRM (CudaPlugin) - Found CUSP Version ${CUSP_VERSION} in location ${CUSP_INCLUDE_DIR}")
  300. else()
  301. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find CUSP!")
  302. endif()
  303. #############################################################
  304. ##
  305. ## Thrust
  306. ##
  307. #############################################################
  308. if(THRUST_FOUND)
  309. include_directories(${THRUST_INCLUDE_DIR})
  310. cuda_include_directories(${THRUST_INCLUDE_DIR})
  311. message(STATUS "StoRM (CudaPlugin) - Found Thrust Version ${THRUST_VERSION} in location ${THRUST_INCLUDE_DIR}")
  312. else()
  313. message(FATAL_ERROR "StoRM (CudaPlugin) - Could not find Thrust! Check your CUDA installation.")
  314. endif()
  315. include_directories(${CUDA_INCLUDE_DIRS})
  316. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  317. cuda_add_library(${STORM_CUDA_LIB_NAME}
  318. ${STORM_CUDA_KERNEL_FILES} ${STORM_CUDA_HEADER_FILES}
  319. )
  320. message (STATUS "StoRM - Linking with CUDA")
  321. list(APPEND STORM_LINK_LIBRARIES ${STORM_CUDA_LIB_NAME})
  322. include_directories("${PROJECT_SOURCE_DIR}/cuda/kernels/")
  323. endif()
  324. if(GMP_FOUND)
  325. link_directories(${GMP_LIBRARY_DIR})
  326. elseif(MPIR_FOUND)
  327. link_directories(${GMP_MPIR_LIBRARY_DIR} ${GMP_MPIRXX_LIBRARY_DIR})
  328. endif(GMP_FOUND)
  329. #############################################################
  330. ##
  331. ## CUDD
  332. ##
  333. #############################################################
  334. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0")
  335. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/cudd")
  336. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/epd")
  337. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/mtr")
  338. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/nanotrav")
  339. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/obj")
  340. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/st")
  341. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/src/util")
  342. list(APPEND STORM_LINK_LIBRARIES cudd)
  343. #############################################################
  344. ##
  345. ## carl
  346. ##
  347. #############################################################
  348. if(USE_CARL)
  349. find_package(carl QUIET)
  350. if(carl_FOUND)
  351. set(STORM_HAVE_CARL ON)
  352. endif()
  353. #find_package(smtrat QUIET)
  354. if(smtrat_FOUND)
  355. set(STORM_HAVE_SMTRAT ON)
  356. endif()
  357. endif()
  358. if(STORM_HAVE_CARL)
  359. message(STATUS "StoRM - Linking with carl.")
  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. ## Google Test gtest
  403. ##
  404. #############################################################
  405. set(gtest_force_shared_crt ON)
  406. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.7.0")
  407. #############################################################
  408. ##
  409. ## Log4CPlus
  410. ##
  411. #############################################################
  412. set(BUILD_SHARED_LIBS OFF CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  413. set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF)
  414. set(LOG4CPLUS_BUILD_TESTING OFF)
  415. set(LOG4CPLUS_USE_UNICODE OFF)
  416. set(LOG4CPLUS_DEFINE_INSTALL_TARGET OFF)
  417. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1")
  418. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include")
  419. include_directories("${PROJECT_BINARY_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") # This adds the defines.hxx file
  420. list(APPEND STORM_LINK_LIBRARIES log4cplusS)
  421. if (UNIX AND NOT APPLE)
  422. list(APPEND STORM_LINK_LIBRARIES rt)
  423. endif(UNIX AND NOT APPLE)
  424. #############################################################
  425. ##
  426. ## Intel Threading Building Blocks (optional)
  427. ##
  428. #############################################################
  429. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  430. find_package(TBB)
  431. if (TBB_FOUND AND STORM_USE_INTELTBB)
  432. link_directories(${TBB_LIBRARY_DIRS})
  433. set(STORM_CPP_INTELTBB_DEF "define")
  434. else()
  435. set(STORM_CPP_INTELTBB_DEF "undef")
  436. endif()
  437. if (TBB_FOUND)
  438. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  439. if (STORM_USE_INTELTBB)
  440. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  441. include_directories(${TBB_INCLUDE_DIRS})
  442. target_link_libraries(storm tbb tbbmalloc)
  443. endif(STORM_USE_INTELTBB)
  444. endif(TBB_FOUND)
  445. #############################################################
  446. ##
  447. ## Threads
  448. ##
  449. #############################################################
  450. find_package(Threads REQUIRED)
  451. include_directories(${THREADS_INCLUDE_DIRS})
  452. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  453. if (STORM_USE_COTIRE)
  454. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  455. endif(STORM_USE_COTIRE)
  456. if (MSVC)
  457. # Add the DebugHelper DLL
  458. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  459. target_link_libraries(storm "Dbghelp.lib")
  460. endif(MSVC)
  461. #############################################################
  462. ##
  463. ## Cotire
  464. ##
  465. #############################################################
  466. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  467. if (STORM_USE_COTIRE)
  468. # Include Cotire for PCH Generation
  469. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  470. include(cotire)
  471. cotire(storm)
  472. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  473. #cotire(storm-functional-tests)
  474. #cotire(storm-performance-tests)
  475. endif()
  476. #############################################################
  477. ##
  478. ## libc++abi
  479. ##
  480. #############################################################
  481. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  482. if (LINK_LIBCXXABI)
  483. message (STATUS "StoRM - Linking against libc++abi.")
  484. target_link_libraries(storm "c++abi")
  485. endif(LINK_LIBCXXABI)
  486. #############################################################
  487. ##
  488. ## Doxygen
  489. ##
  490. #############################################################
  491. find_package(Doxygen REQUIRED)
  492. # Add a target to generate API documentation with Doxygen
  493. if(DOXYGEN_FOUND)
  494. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  495. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  496. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  497. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  498. endif(DOXYGEN_FOUND)
  499. #############################################################
  500. ##
  501. ## CMake-generated Config File for StoRM
  502. ##
  503. #############################################################
  504. #
  505. # Make a version file containing the current version from git.
  506. #
  507. include(GetGitRevisionDescription)
  508. git_describe_checkout(STORM_GIT_VERSION_STRING)
  509. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  510. # Parse the git Tag into variables
  511. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  512. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  513. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  514. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  515. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  516. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  517. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  518. set(STORM_CPP_VERSION_DIRTY 1)
  519. else()
  520. set(STORM_CPP_VERSION_DIRTY 0)
  521. endif()
  522. 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})")
  523. # Configure a header file to pass some of the CMake settings to the source code
  524. configure_file (
  525. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  526. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  527. )
  528. # Configure a header file to pass the storm version to the source code
  529. configure_file (
  530. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  531. "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp"
  532. )
  533. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  534. # Add the binary dir include directory for storm-config.h
  535. include_directories("${PROJECT_BINARY_DIR}/include")
  536. add_subdirectory(src)
  537. add_subdirectory(test)
  538. #############################################################
  539. ##
  540. ## memcheck targets
  541. ##
  542. #############################################################
  543. 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)
  544. 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)
  545. 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)
  546. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  547. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  548. include(StormCPackConfig.cmake)