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.

831 lines
30 KiB

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