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.

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