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.

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