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.

679 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 -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. include_directories("${carl_INCLUDE_DIR}")
  360. list(APPEND STORM_LINK_LIBRARIES ${carl_LIBRARIES})
  361. endif()
  362. #############################################################
  363. ##
  364. ## SMT-RAT
  365. ##
  366. #############################################################
  367. if(STORM_HAVE_SMTRAT)
  368. message(STATUS "StoRM - Linking with smtrat.")
  369. include_directories("${smtrat_INCLUDE_DIR}")
  370. list(APPEND STORM_LINK_LIBRARIES ${smtrat_LIBRARIES})
  371. endif()
  372. #############################################################
  373. ##
  374. ## MathSAT (optional)
  375. ##
  376. #############################################################
  377. if ("${MSAT_ROOT}" STREQUAL "")
  378. set(ENABLE_MSAT OFF)
  379. else()
  380. set(ENABLE_MSAT ON)
  381. endif()
  382. # MathSAT Defines
  383. set(STORM_HAVE_MSAT ${ENABLE_MSAT})
  384. if (ENABLE_MSAT)
  385. link_directories("${MSAT_ROOT}/lib")
  386. message (STATUS "StoRM - Linking with MathSAT")
  387. include_directories("${MSAT_ROOT}/include")
  388. list(APPEND STORM_LINK_LIBRARIES "mathsat")
  389. if(GMP_FOUND)
  390. include_directories("${GMP_INCLUDE_DIR}")
  391. list(APPEND STORM_LINK_LIBRARIES "gmp")
  392. elseif(MPIR_FOUND)
  393. include_directories("${GMP_INCLUDE_DIR}")
  394. list(APPEND STORM_LINK_LIBRARIES "mpir" "mpirxx")
  395. else(GMP_FOUND)
  396. message(FATAL_ERROR "GMP is required for MathSAT, but was not found!")
  397. endif(GMP_FOUND)
  398. endif(ENABLE_MSAT)
  399. #############################################################
  400. ##
  401. ## Google Test gtest
  402. ##
  403. #############################################################
  404. set(gtest_force_shared_crt ON)
  405. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.7.0")
  406. #############################################################
  407. ##
  408. ## Log4CPlus
  409. ##
  410. #############################################################
  411. set(BUILD_SHARED_LIBS OFF CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  412. set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF)
  413. set(LOG4CPLUS_BUILD_TESTING OFF)
  414. set(LOG4CPLUS_USE_UNICODE OFF)
  415. set(LOG4CPLUS_DEFINE_INSTALL_TARGET OFF)
  416. add_subdirectory("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1")
  417. include_directories("${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include")
  418. include_directories("${PROJECT_BINARY_DIR}/resources/3rdparty/log4cplus-1.1.3-rc1/include") # This adds the defines.hxx file
  419. list(APPEND STORM_LINK_LIBRARIES log4cplusS)
  420. if (UNIX AND NOT APPLE)
  421. list(APPEND STORM_LINK_LIBRARIES rt)
  422. endif(UNIX AND NOT APPLE)
  423. #############################################################
  424. ##
  425. ## Intel Threading Building Blocks (optional)
  426. ##
  427. #############################################################
  428. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb42_20140122_merged-win-lin-mac")
  429. find_package(TBB)
  430. if (TBB_FOUND AND STORM_USE_INTELTBB)
  431. link_directories(${TBB_LIBRARY_DIRS})
  432. set(STORM_CPP_INTELTBB_DEF "define")
  433. else()
  434. set(STORM_CPP_INTELTBB_DEF "undef")
  435. endif()
  436. if (TBB_FOUND)
  437. message(STATUS "StoRM - Found Intel TBB with interface version ${TBB_INTERFACE_VERSION}.")
  438. if (STORM_USE_INTELTBB)
  439. message(STATUS "StoRM - Linking with Intel TBB in ${TBB_LIBRARY_DIRS}.")
  440. include_directories(${TBB_INCLUDE_DIRS})
  441. target_link_libraries(storm tbb tbbmalloc)
  442. endif(STORM_USE_INTELTBB)
  443. endif(TBB_FOUND)
  444. #############################################################
  445. ##
  446. ## Threads
  447. ##
  448. #############################################################
  449. find_package(Threads REQUIRED)
  450. include_directories(${THREADS_INCLUDE_DIRS})
  451. list(APPEND STORM_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
  452. if (STORM_USE_COTIRE)
  453. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  454. endif(STORM_USE_COTIRE)
  455. if (MSVC)
  456. # Add the DebugHelper DLL
  457. set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} Dbghelp.lib")
  458. target_link_libraries(storm "Dbghelp.lib")
  459. endif(MSVC)
  460. #############################################################
  461. ##
  462. ## Cotire
  463. ##
  464. #############################################################
  465. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  466. if (STORM_USE_COTIRE)
  467. # Include Cotire for PCH Generation
  468. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  469. include(cotire)
  470. cotire(storm)
  471. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  472. #cotire(storm-functional-tests)
  473. #cotire(storm-performance-tests)
  474. endif()
  475. #############################################################
  476. ##
  477. ## libc++abi
  478. ##
  479. #############################################################
  480. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  481. if (LINK_LIBCXXABI)
  482. message (STATUS "StoRM - Linking against libc++abi.")
  483. target_link_libraries(storm "c++abi")
  484. endif(LINK_LIBCXXABI)
  485. #############################################################
  486. ##
  487. ## Doxygen
  488. ##
  489. #############################################################
  490. find_package(Doxygen REQUIRED)
  491. # Add a target to generate API documentation with Doxygen
  492. if(DOXYGEN_FOUND)
  493. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  494. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  495. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  496. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  497. endif(DOXYGEN_FOUND)
  498. #############################################################
  499. ##
  500. ## CMake-generated Config File for StoRM
  501. ##
  502. #############################################################
  503. #
  504. # Make a version file containing the current version from git.
  505. #
  506. include(GetGitRevisionDescription)
  507. git_describe_checkout(STORM_GIT_VERSION_STRING)
  508. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  509. # Parse the git Tag into variables
  510. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  511. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  512. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  513. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  514. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  515. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  516. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  517. set(STORM_CPP_VERSION_DIRTY 1)
  518. else()
  519. set(STORM_CPP_VERSION_DIRTY 0)
  520. endif()
  521. 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})")
  522. # Configure a header file to pass some of the CMake settings to the source code
  523. configure_file (
  524. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  525. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  526. )
  527. # Configure a header file to pass the storm version to the source code
  528. configure_file (
  529. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  530. "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp"
  531. )
  532. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  533. # Add the binary dir include directory for storm-config.h
  534. include_directories("${PROJECT_BINARY_DIR}/include")
  535. add_subdirectory(src)
  536. add_subdirectory(test)
  537. #############################################################
  538. ##
  539. ## memcheck targets
  540. ##
  541. #############################################################
  542. 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)
  543. 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)
  544. 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)
  545. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  546. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  547. include(StormCPackConfig.cmake)