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.

352 lines
14 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/find_modules" "${PROJECT_SOURCE_DIR}/resources/cmake/macros")
  10. include(ExternalProject)
  11. include(RegisterSourceGroup)
  12. #############################################################
  13. ##
  14. ## CMake options of StoRM
  15. ##
  16. #############################################################
  17. option(STORM_DEVELOPER "Sets whether the development mode is used" OFF)
  18. option(STORM_USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON)
  19. MARK_AS_ADVANCED(STORM_USE_POPCNT)
  20. option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." ON)
  21. option(STORM_USE_INTELTBB "Sets whether the Intel TBB libraries should be used." OFF)
  22. option(STORM_USE_GUROBI "Sets whether Gurobi should be used." OFF)
  23. option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precompiled headers)." OFF)
  24. option(LINK_LIBCXXABI "Sets whether libc++abi should be linked." OFF)
  25. option(USE_LIBCXX "Sets whether the standard library is libc++." OFF)
  26. option(USE_CARL "Sets whether carl should be included." ON)
  27. option(USE_XERCES "Sets whether xerces should be used." OFF)
  28. option(FORCE_COLOR "Force color output" OFF)
  29. mark_as_advanced(FORCE_COLOR)
  30. option(STORM_PYTHON "Builds the API for Python" OFF)
  31. option(STORM_COMPILE_WITH_CCACHE "Compile using CCache [if found]" ON)
  32. mark_as_advanced(STORM_COMPILE_WITH_CCACHE)
  33. option(STORM_LOG_DISABLE_DEBUG "Disable log and trace message support" OFF)
  34. set(BOOST_ROOT "" CACHE STRING "A hint to the root directory of Boost (optional).")
  35. set(GUROBI_ROOT "" CACHE STRING "A hint to the root directory of Gurobi (optional).")
  36. set(Z3_ROOT "" CACHE STRING "A hint to the root directory of Z3 (optional).")
  37. set(CUDA_ROOT "" CACHE STRING "The hint to the root directory of CUDA (optional).")
  38. set(MSAT_ROOT "" CACHE STRING "The hint to the root directory of MathSAT (optional).")
  39. set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.")
  40. set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.")
  41. # Set some CMAKE Variables as advanced
  42. mark_as_advanced(CMAKE_OSX_ARCHITECTURES)
  43. mark_as_advanced(CMAKE_OSX_SYSROOT)
  44. mark_as_advanced(CMAKE_OSX_DEPLOYMENT_TARGET)
  45. # If the STORM_DEVELOPER option was turned on, we will target a debug version.
  46. if (STORM_DEVELOPER)
  47. message(STATUS "StoRM - Using development mode")
  48. set(CMAKE_BUILD_TYPE "DEBUG" CACHE STRING "Set the build type" FORCE)
  49. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTORM_DEV")
  50. endif()
  51. message(STATUS "StoRM - Building ${CMAKE_BUILD_TYPE} version.")
  52. if(STORM_COMPILE_WITH_CCACHE)
  53. find_program(CCACHE_FOUND ccache)
  54. mark_as_advanced(CCACHE_FOUND)
  55. if(CCACHE_FOUND)
  56. message(STATUS "StoRM - Using ccache")
  57. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  58. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  59. else()
  60. message(STATUS "Could not find ccache")
  61. endif()
  62. endif()
  63. # Base path for test files
  64. set(STORM_CPP_TESTS_BASE_PATH "${PROJECT_SOURCE_DIR}/test")
  65. set(STORMPY_OUTPUT_DIR "${PROJECT_BINARY_DIR}/stormpy")
  66. set(STORMPY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/stormpy")
  67. # Auto-detect operating system.
  68. set(MACOSX 0)
  69. set(LINUX 0)
  70. if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  71. # Mac OS
  72. set(OPERATING_SYSTEM "Mac OS")
  73. set(MACOSX 1)
  74. elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  75. # Linux
  76. set(OPERATING_SYSTEM "Linux")
  77. set(LINUX 1)
  78. elseif(WIN32)
  79. # Assuming Windows.
  80. set(OPERATING_SYSTEM "Windows")
  81. else()
  82. message(WARNING "We are unsure about your operating system.")
  83. set(OPERATING_SYSTEM "Linux")
  84. set(LINUX 1)
  85. ENDIF()
  86. message(STATUS "Operating system: ${OPERATING_SYSTEM}")
  87. set(DYNAMIC_EXT ".so")
  88. set(STATIC_EXT ".a")
  89. if(MACOSX)
  90. set(DYNAMIC_EXT ".dylib")
  91. set(STATIC_EXT ".a")
  92. elseif (WIN32)
  93. set(DYNAMIC_EXT ".dll")
  94. set(STATIC_EXT ".lib")
  95. endif()
  96. message(STATUS "Assuming extension for shared libraries: ${DYNAMIC_EXT}")
  97. message(STATUS "Assuming extension for static libraries: ${STATIC_EXT}")
  98. #############################################################
  99. ##
  100. ## Compiler specific settings and definitions
  101. ##
  102. #############################################################
  103. # Path to the no-strict-aliasing target
  104. set(CONVERSIONHELPER_TARGET "${PROJECT_SOURCE_DIR}/src/utility/ConversionHelper.cpp")
  105. if(CMAKE_COMPILER_IS_GNUCC)
  106. set(STORM_COMPILED_BY "GCC")
  107. # Set standard flags for GCC
  108. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  109. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops")
  110. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  111. set(STORM_CXX_STD_COMMAND "-std=c++14")
  112. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.1)
  113. message(STATUS "GCC Version is greater then 5.1, using -std=c++14")
  114. set(STORM_CXX_STD_COMMAND "-std=c++14")
  115. elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.2)
  116. message(WARNING "GCC Version is less then 4.9.2 - your compiler is probably too old for StoRM!")
  117. set(STORM_CXX_STD_COMMAND "-std=c++1y")
  118. else()
  119. message(STATUS "GCC Version is between 4.9.2 and 5.1, using -std=c++1y")
  120. set(STORM_CXX_STD_COMMAND "-std=c++1y")
  121. endif()
  122. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STORM_CXX_STD_COMMAND} -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
  123. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
  124. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  125. message(FATAL_ERROR "GCC version must be at least 5.0!")
  126. endif()
  127. # Turn on popcnt instruction if desired (yes by default)
  128. if (STORM_USE_POPCNT)
  129. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  130. endif(STORM_USE_POPCNT)
  131. # Set the no-strict-aliasing target for GCC
  132. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing")
  133. elseif(MSVC)
  134. set(STORM_COMPILED_BY "MSVC")
  135. # required for GMM to compile, ugly error directive in their code
  136. add_definitions(/D_SCL_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS)
  137. # 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)
  138. add_definitions(/bigobj)
  139. # required by GTest and PrismGrammar::createIntegerVariable
  140. add_definitions(/D_VARIADIC_MAX=10)
  141. # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max
  142. add_definitions(/DNOMINMAX)
  143. # Boost Defs, required for using boost's transform iterator
  144. add_definitions(/DBOOST_RESULT_OF_USE_DECLTYPE)
  145. # since nobody cares at the moment
  146. add_definitions(/wd4250)
  147. # MSVC does not do strict-aliasing, so no option needed
  148. else(CLANG)
  149. set(STORM_COMPILED_BY "Clang (LLVM)")
  150. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  151. set (CLANG ON)
  152. # Set standard flags for clang
  153. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O3")
  154. if(UNIX AND NOT APPLE)
  155. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.2)
  156. message(FATAL_ERROR "Clang version must be at least 3.2!")
  157. endif()
  158. endif()
  159. if(UNIX AND APPLE)
  160. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
  161. message(FATAL_ERROR "Clang version must be at least 7.3!")
  162. endif()
  163. endif()
  164. if(UNIX AND NOT APPLE AND NOT USE_LIBCXX)
  165. set(CLANG_STDLIB libstdc++)
  166. message(STATUS "StoRM - Linking against libstdc++")
  167. else()
  168. set(CLANG_STDLIB libc++)
  169. message(STATUS "StoRM - Linking against libc++")
  170. # Disable Cotire
  171. set(STORM_USE_COTIRE OFF)
  172. # Set up some Xcode specific settings
  173. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
  174. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  175. endif()
  176. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  177. 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")
  178. if(FORCE_COLOR)
  179. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  180. endif()
  181. # Turn on popcnt instruction if desired (yes by default)
  182. if (STORM_USE_POPCNT)
  183. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  184. endif(STORM_USE_POPCNT)
  185. # Set the no-strict-aliasing target for Clang
  186. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
  187. endif()
  188. if(CCACHE_FOUND)
  189. set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)")
  190. endif()
  191. message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}")
  192. #############################################################
  193. #############################################################
  194. ##
  195. ## Inclusion of required libraries
  196. ##
  197. #############################################################
  198. #############################################################
  199. #############################################################
  200. ##
  201. ## Include the targets for non-system resources
  202. ##
  203. #############################################################
  204. # In 3rdparty, targets are being defined that can be used
  205. # in the the system does not have a library
  206. include(resources/3rdparty/CMakeLists.txt)
  207. #############################################################
  208. ##
  209. ## Cotire
  210. ##
  211. #############################################################
  212. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  213. if (STORM_USE_COTIRE)
  214. # Include Cotire for PCH Generation
  215. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  216. include(cotire)
  217. cotire(storm)
  218. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  219. #cotire(storm-functional-tests)
  220. #cotire(storm-performance-tests)
  221. endif()
  222. #############################################################
  223. ##
  224. ## libc++abi
  225. ##
  226. #############################################################
  227. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  228. if (LINK_LIBCXXABI)
  229. message (STATUS "StoRM - Linking against libc++abi.")
  230. target_link_libraries(storm "c++abi")
  231. endif(LINK_LIBCXXABI)
  232. #############################################################
  233. ##
  234. ## Doxygen
  235. ##
  236. #############################################################
  237. find_package(Doxygen)
  238. # Add a target to generate API documentation with Doxygen
  239. if(DOXYGEN_FOUND)
  240. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  241. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  242. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/resources/doxygen/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  243. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  244. endif(DOXYGEN_FOUND)
  245. #############################################################
  246. ##
  247. ## CMake-generated Config File for StoRM
  248. ##
  249. #############################################################
  250. #
  251. # Make a version file containing the current version from git.
  252. #
  253. include(GetGitRevisionDescription)
  254. git_describe_checkout(STORM_GIT_VERSION_STRING)
  255. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  256. # Parse the git Tag into variables
  257. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  258. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  259. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  260. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  261. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  262. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  263. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  264. set(STORM_CPP_VERSION_DIRTY 1)
  265. else()
  266. set(STORM_CPP_VERSION_DIRTY 0)
  267. endif()
  268. 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})")
  269. # Configure a header file to pass some of the CMake settings to the source code
  270. configure_file (
  271. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  272. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  273. )
  274. # Configure a header file to pass the storm version to the source code
  275. configure_file (
  276. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  277. "${PROJECT_SOURCE_DIR}/src/utility/storm-version.cpp"
  278. )
  279. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  280. # Add the binary dir include directory for storm-config.h
  281. include_directories("${PROJECT_BINARY_DIR}/include")
  282. add_subdirectory(src)
  283. add_subdirectory(test)
  284. #############################################################
  285. ##
  286. ## memcheck targets
  287. ##
  288. #############################################################
  289. 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)
  290. 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)
  291. 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)
  292. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  293. add_custom_target(style python resources/3rdparty/cpplint/cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  294. include(StormCPackConfig.cmake)