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.

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