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.

311 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. 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(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -pedantic -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unknown-pragmas")
  103. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-deprecated-declarations")
  104. # Turn on popcnt instruction if desired (yes by default)
  105. if (STORM_USE_POPCNT)
  106. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  107. endif(STORM_USE_POPCNT)
  108. # Set the no-strict-aliasing target for GCC
  109. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing")
  110. elseif(MSVC)
  111. set(STORM_COMPILED_BY "MSVC")
  112. # required for GMM to compile, ugly error directive in their code
  113. add_definitions(/D_SCL_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS)
  114. # 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)
  115. add_definitions(/bigobj)
  116. # required by GTest and PrismGrammar::createIntegerVariable
  117. add_definitions(/D_VARIADIC_MAX=10)
  118. # Windows.h breaks GMM in gmm_except.h because of its macro definition for min and max
  119. add_definitions(/DNOMINMAX)
  120. # Boost Defs, required for using boost's transform iterator
  121. add_definitions(/DBOOST_RESULT_OF_USE_DECLTYPE)
  122. # since nobody cares at the moment
  123. add_definitions(/wd4250)
  124. # MSVC does not do strict-aliasing, so no option needed
  125. else(CLANG)
  126. set(STORM_COMPILED_BY "Clang (LLVM)")
  127. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  128. set (CLANG ON)
  129. # Set standard flags for clang
  130. set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O3")
  131. if(UNIX AND NOT APPLE AND NOT USE_LIBCXX)
  132. set(CLANG_STDLIB libstdc++)
  133. message(STATUS "StoRM - Linking against libstdc++")
  134. else()
  135. set(CLANG_STDLIB libc++)
  136. message(STATUS "StoRM - Linking against libc++")
  137. # Disable Cotire
  138. set(STORM_USE_COTIRE OFF)
  139. # Set up some Xcode specific settings
  140. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
  141. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  142. endif()
  143. add_definitions(-DBOOST_RESULT_OF_USE_DECLTYPE)
  144. 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")
  145. if(FORCE_COLOR)
  146. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
  147. endif()
  148. # Turn on popcnt instruction if desired (yes by default)
  149. if (STORM_USE_POPCNT)
  150. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  151. endif(STORM_USE_POPCNT)
  152. # Set the no-strict-aliasing target for Clang
  153. set_source_files_properties(${CONVERSIONHELPER_TARGET} PROPERTIES COMPILE_FLAGS " -fno-strict-aliasing ")
  154. endif()
  155. if(CCACHE_FOUND)
  156. set(STORM_COMPILED_BY "${STORM_COMPILED_BY} (ccache)")
  157. endif()
  158. message(STATUS "StoRM - Using Compiler Configuration: ${STORM_COMPILED_BY}")
  159. #############################################################
  160. #############################################################
  161. ##
  162. ## Inclusion of required libraries
  163. ##
  164. #############################################################
  165. #############################################################
  166. #############################################################
  167. ##
  168. ## Include the targets for non-system resources
  169. ##
  170. #############################################################
  171. # In 3rdparty, targets are being defined that can be used
  172. # in the the system does not have a library
  173. include(resources/3rdparty/CMakeLists.txt)
  174. #############################################################
  175. ##
  176. ## Cotire
  177. ##
  178. #############################################################
  179. message (STATUS "StoRM - Using Cotire: ${STORM_USE_COTIRE}")
  180. if (STORM_USE_COTIRE)
  181. # Include Cotire for PCH Generation
  182. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  183. include(cotire)
  184. cotire(storm)
  185. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  186. #cotire(storm-functional-tests)
  187. #cotire(storm-performance-tests)
  188. endif()
  189. #############################################################
  190. ##
  191. ## libc++abi
  192. ##
  193. #############################################################
  194. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  195. if (LINK_LIBCXXABI)
  196. message (STATUS "StoRM - Linking against libc++abi.")
  197. target_link_libraries(storm "c++abi")
  198. endif(LINK_LIBCXXABI)
  199. #############################################################
  200. ##
  201. ## Doxygen
  202. ##
  203. #############################################################
  204. find_package(Doxygen)
  205. # Add a target to generate API documentation with Doxygen
  206. if(DOXYGEN_FOUND)
  207. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  208. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  209. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in" "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" @ONLY)
  210. add_custom_target(doc ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" COMMENT "Generating API documentation with Doxygen" VERBATIM)
  211. endif(DOXYGEN_FOUND)
  212. #############################################################
  213. ##
  214. ## CMake-generated Config File for StoRM
  215. ##
  216. #############################################################
  217. #
  218. # Make a version file containing the current version from git.
  219. #
  220. include(GetGitRevisionDescription)
  221. git_describe_checkout(STORM_GIT_VERSION_STRING)
  222. message(STATUS "STORM_GIT_VERSION_STRING: ${STORM_GIT_VERSION_STRING}")
  223. # Parse the git Tag into variables
  224. string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" STORM_CPP_VERSION_MAJOR "${STORM_GIT_VERSION_STRING}")
  225. string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_MINOR "${STORM_GIT_VERSION_STRING}")
  226. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" STORM_CPP_VERSION_PATCH "${STORM_GIT_VERSION_STRING}")
  227. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-([0-9]+)\\-.*" "\\1" STORM_CPP_VERSION_COMMITS_AHEAD "${STORM_GIT_VERSION_STRING}")
  228. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-([a-z0-9]+).*" "\\1" STORM_CPP_VERSION_HASH "${STORM_GIT_VERSION_STRING}")
  229. string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\-[0-9]+\\-[a-z0-9]+\\-(.*)" "\\1" STORM_CPP_VERSION_APPENDIX "${STORM_GIT_VERSION_STRING}")
  230. if ("${STORM_CPP_VERSION_APPENDIX}" MATCHES "^.*dirty.*$")
  231. set(STORM_CPP_VERSION_DIRTY 1)
  232. else()
  233. set(STORM_CPP_VERSION_DIRTY 0)
  234. endif()
  235. 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})")
  236. # Configure a header file to pass some of the CMake settings to the source code
  237. configure_file (
  238. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  239. "${PROJECT_BINARY_DIR}/include/storm-config.h"
  240. )
  241. # Configure a header file to pass the storm version to the source code
  242. configure_file (
  243. "${PROJECT_SOURCE_DIR}/storm-version.cpp.in"
  244. "${PROJECT_SOURCE_DIR}/src/utility/storm-version.cpp"
  245. )
  246. set(STORM_GENERATED_SOURCES "${PROJECT_BINARY_DIR}/src/utility/storm-version.cpp")
  247. # Add the binary dir include directory for storm-config.h
  248. include_directories("${PROJECT_BINARY_DIR}/include")
  249. add_subdirectory(src)
  250. add_subdirectory(test)
  251. #############################################################
  252. ##
  253. ## memcheck targets
  254. ##
  255. #############################################################
  256. 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)
  257. 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)
  258. 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)
  259. set(CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  260. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp" `)
  261. include(StormCPackConfig.cmake)