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.

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