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.

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