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.

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