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.

333 lines
15 KiB

  1. cmake_minimum_required (VERSION 2.8.6)
  2. # Set project name
  3. project (storm CXX C)
  4. # Set the version number
  5. set (STORM_CPP_VERSION_MAJOR 1)
  6. set (STORM_CPP_VERSION_MINOR 0)
  7. # Set all GTest references to the version in the repository and show it as output
  8. set (GTEST_INCLUDE_DIR resources/3rdparty/gtest-1.6.0/include)
  9. if(MSVC)
  10. set (STORM_LIB_SUFFIX lib)
  11. set (GTEST_LIBRARY_DEBUG ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Debug/gtest.${STORM_LIB_SUFFIX})
  12. set (GTEST_MAIN_LIBRARY_DEBUG ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Debug/gtest_main.${STORM_LIB_SUFFIX})
  13. set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Release/gtest.${STORM_LIB_SUFFIX})
  14. set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Release/gtest_main.${STORM_LIB_SUFFIX})
  15. set (GTEST_LIBRARIES optimized ${GTEST_LIBRARY} debug ${GTEST_LIBRARY_DEBUG})
  16. else()
  17. set (STORM_LIB_SUFFIX a)
  18. set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest.${STORM_LIB_SUFFIX})
  19. set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest_main.${STORM_LIB_SUFFIX})
  20. set (GTEST_LIBRARIES ${GTEST_LIBRARY}) # as we dont use FindGTest anymore
  21. endif()
  22. message(STATUS "GTEST_INCLUDE_DIR is ${GTEST_INCLUDE_DIR}")
  23. message(STATUS "GTEST_LIBRARY is ${GTEST_LIBRARY}")
  24. message(STATUS "GTEST_MAIN_LIBRARY is ${GTEST_MAIN_LIBRARY}")
  25. # Set all log4cplus references the version in the repository
  26. set (LOG4CPLUS_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/include)
  27. if (MSVC)
  28. set (LOG4CPLUS_LIBRARIES optimized ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/msvc10/x64/bin.Release/log4cplusS.${STORM_LIB_SUFFIX} debug ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/msvc10/x64/bin.Debug/log4cplusSD.${STORM_LIB_SUFFIX})
  29. else()
  30. set (LOG4CPLUS_LIBRARIES ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/src/liblog4cplus.${STORM_LIB_SUFFIX})
  31. endif()
  32. message(STATUS "LOG4CPLUS_INCLUDE_DIR is ${LOG4CPLUS_INCLUDE_DIR}")
  33. message(STATUS "LOG4CPLUS_LIBRARY is ${LOG4CPLUS_LIBRARIES}")
  34. # Set all Eigen references the version in the repository
  35. set(EIGEN3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen)
  36. message(STATUS "EIGEN3_INCLUDE_DIR is ${EIGEN3_INCLUDE_DIR}")
  37. # Set all Eigen references the version in the repository
  38. set(GMMXX_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/gmm-4.2/include)
  39. message(STATUS "GMMXX_INCLUDE_DIR is ${GMMXX_INCLUDE_DIR}")
  40. # Set all CUDD references to the version in the repository
  41. set(CUDD_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/include ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/obj ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/cudd ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/mtr ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/epd)
  42. set(CUDD_LIBRARY_DIRS ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/cudd ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/mtr ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/util ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/st ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/epd ${PROJECT_SOURCE_DIR}/resources/3rdparty/cudd-2.5.0/obj)
  43. message(STATUS "CUDD_INCLUDE_DIRS is ${CUDD_INCLUDE_DIRS}")
  44. message(STATUS "CUDD_LIBRARY_DIRS is ${CUDD_LIBRARY_DIRS}")
  45. # Now define all available custom options
  46. option(DEBUG "Sets whether the DEBUG mode is used" ON)
  47. option(USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON)
  48. option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." ON)
  49. option(USE_INTELTBB "Sets whether the Intel TBB Extensions should be used." OFF)
  50. option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precompiled headers)." OFF)
  51. option(LINK_LIBCXXABI "Sets whether libc++abi should be linked" OFF)
  52. set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.")
  53. set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.")
  54. set(CUSTOM_BOOST_ROOT "" CACHE STRING "A custom path to the Boost root directory.")
  55. # If the DEBUG option was turned on, we will target a debug version and a release version otherwise
  56. if (DEBUG)
  57. set (CMAKE_BUILD_TYPE "DEBUG")
  58. message(STATUS "Building DEBUG version.")
  59. else()
  60. set (CMAKE_BUILD_TYPE "RELEASE")
  61. message(STATUS "Building RELEASE version.")
  62. endif()
  63. message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
  64. message(STATUS "CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}")
  65. if(CMAKE_COMPILER_IS_GNUCC)
  66. message(STATUS "Using GCC")
  67. # Set standard flags for GCC
  68. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  69. set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -pedantic")
  70. # -Werror is atm removed as this gave some problems with existing code
  71. # May be re-set later
  72. # (Thomas Heinemann, 2012-12-21)
  73. # Turn on popcnt instruction if desired (yes by default)
  74. if (USE_POPCNT)
  75. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  76. endif(USE_POPCNT)
  77. elseif(MSVC)
  78. message(STATUS "Using MSVC")
  79. # required for GMM to compile, ugly error directive in their code
  80. add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
  81. else(CLANG)
  82. message(STATUS "Using CLANG")
  83. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  84. set (CLANG ON)
  85. # Set standard flags for clang
  86. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O4")
  87. set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Werror -pedantic -Wno-unused-variable -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE")
  88. set (CMAKE_CXX_FLAGS_DEBUG "-g")
  89. # Turn on popcnt instruction if desired (yes by default)
  90. if (USE_POPCNT)
  91. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  92. endif(USE_POPCNT)
  93. endif()
  94. # Add the binary folder to the search path for include files so that we will find storm-config.h
  95. include_directories("${PROJECT_BINARY_DIR}")
  96. # Base path for test files
  97. set(STORM_CPP_TESTS_BASE_PATH ${PROJECT_SOURCE_DIR}/test)
  98. message(STATUS "STORM_CPP_TESTS_BASE_PATH is ${STORM_CPP_TESTS_BASE_PATH}")
  99. # Main Sources
  100. file(GLOB_RECURSE STORM_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h)
  101. file(GLOB_RECURSE STORM_SOURCES_WITHOUT_MAIN ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
  102. file(GLOB_RECURSE STORM_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/storm.cpp)
  103. set(STORM_SOURCES "${STORM_SOURCES_WITHOUT_MAIN};${STORM_MAIN_FILE}")
  104. file(GLOB_RECURSE STORM_ADAPTERS_FILES ${PROJECT_SOURCE_DIR}/src/adapters/*.h ${PROJECT_SOURCE_DIR}/src/adapters/*.cpp)
  105. file(GLOB_RECURSE STORM_EXCEPTIONS_FILES ${PROJECT_SOURCE_DIR}/src/exceptions/*.h ${PROJECT_SOURCE_DIR}/src/exceptions/*.cpp)
  106. file(GLOB_RECURSE STORM_FORMULA_FILES ${PROJECT_SOURCE_DIR}/src/formula/*.h ${PROJECT_SOURCE_DIR}/src/formula/*.cpp)
  107. file(GLOB_RECURSE STORM_MODELCHECKER_FILES ${PROJECT_SOURCE_DIR}/src/modelchecker/*.h ${PROJECT_SOURCE_DIR}/src/modelchecker/*.cpp)
  108. file(GLOB_RECURSE STORM_MODELS_FILES ${PROJECT_SOURCE_DIR}/src/models/*.h ${PROJECT_SOURCE_DIR}/src/models/*.cpp)
  109. file(GLOB_RECURSE STORM_PARSER_FILES ${PROJECT_SOURCE_DIR}/src/parser/*.h ${PROJECT_SOURCE_DIR}/src/parser/*.cpp)
  110. file(GLOB_RECURSE STORM_STORAGE_FILES ${PROJECT_SOURCE_DIR}/src/storage/*.h ${PROJECT_SOURCE_DIR}/src/storage/*.cpp)
  111. file(GLOB_RECURSE STORM_UTILITY_FILES ${PROJECT_SOURCE_DIR}/src/utility/*.h ${PROJECT_SOURCE_DIR}/src/utility/*.cpp)
  112. # Test Sources
  113. # Note that the tests also need the source files, except for the main file
  114. file(GLOB_RECURSE STORM_TEST_FILES ${PROJECT_SOURCE_DIR}/test/*.h ${PROJECT_SOURCE_DIR}/test/*.cpp)
  115. # Group the headers and sources
  116. source_group(main FILES ${STORM_MAIN_FILE})
  117. source_group(adapters FILES ${STORM_ADAPTERS_FILES})
  118. source_group(exceptions FILES ${STORM_EXCEPTIONS_FILES})
  119. source_group(formula FILES ${STORM_FORMULA_FILES})
  120. source_group(modelchecker FILES ${STORM_MODELCHECKER_FILES})
  121. source_group(models FILES ${STORM_MODELS_FILES})
  122. source_group(parser FILES ${STORM_PARSER_FILES})
  123. source_group(storage FILES ${STORM_STORAGE_FILES})
  124. source_group(utility FILES ${STORM_UTILITY_FILES})
  125. source_group(test FILES ${STORM_TEST_FILES})
  126. # Add base folder for better inclusion paths
  127. include_directories("${PROJECT_SOURCE_DIR}")
  128. include_directories("${PROJECT_SOURCE_DIR}/src")
  129. # Preset pathes for Intel TBB to internal copy in /resources/3rdParty/tbb41_20130314_mergedWindowsLinuxMacOSX
  130. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb41_20130314_merged-win-lin-mac/")
  131. if(MSVC)
  132. set(ENV{TBB_ARCH_PLATFORM} "intel64/vc11")
  133. elseif(CMAKE_COMPILER_IS_GNUCC)
  134. set(ENV{TBB_ARCH_PLATFORM} "intel64/gcc4.4")
  135. else(CLANG)
  136. set(ENV{TBB_ARCH_PLATFORM} "intel64/clang3.2")
  137. endif()
  138. # Add the resources/cmake folder to Module Search Path for FindTBB.cmake
  139. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmake/")
  140. # Set required external packages
  141. find_package(Threads REQUIRED)
  142. find_package(Doxygen REQUIRED)
  143. set(Boost_USE_STATIC_LIBS ON)
  144. set(Boost_USE_MULTITHREADED ON)
  145. set(Boost_USE_STATIC_RUNTIME OFF)
  146. # If a custom boost root directory was specified, we set the corresponding hint for the script to find it.
  147. if(CUSTOM_BOOST_ROOT)
  148. set(BOOST_ROOT "${CUSTOM_BOOST_ROOT}")
  149. endif(CUSTOM_BOOST_ROOT)
  150. find_package(Boost REQUIRED COMPONENTS program_options)
  151. find_package(TBB)
  152. if(Boost_FOUND)
  153. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  154. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  155. endif ()
  156. message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  157. message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  158. include_directories(${Boost_INCLUDE_DIRS})
  159. link_directories(${Boost_LIBRARY_DIRS})
  160. endif(Boost_FOUND)
  161. # Intels Thread Building Blocks
  162. if (TBB_FOUND)
  163. message(STATUS "Found TBB with Interface Version ${TBB_INTERFACE_VERSION}")
  164. if(USE_INTELTBB)
  165. add_definitions(-DGMM_USE_TBB)
  166. endif()
  167. include_directories(${TBB_INCLUDE_DIRS})
  168. link_directories(${TBB_LIBRARY_DIRS})
  169. endif(TBB_FOUND)
  170. # Add Eigen to the included directories
  171. include_directories(${EIGEN3_INCLUDE_DIR})
  172. # Add GMMXX to the included directories
  173. include_directories(${GMMXX_INCLUDE_DIR})
  174. # Add custom additional include or link directories
  175. if (ADDITIONAL_INCLUDE_DIRS)
  176. message(STATUS "Using additional include directories ${ADDITIONAL_INCLUDE_DIRS}")
  177. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  178. endif(ADDITIONAL_INCLUDE_DIRS)
  179. if (ADDITIONAL_LINK_DIRS)
  180. message(STATUS "Using additional link directories ${ADDITIONAL_LINK_DIRS}")
  181. link_directories(${ADDITIONAL_LINK_DIRS})
  182. endif(ADDITIONAL_LINK_DIRS)
  183. if (CUDD_INCLUDE_DIRS)
  184. include_directories(${CUDD_INCLUDE_DIRS})
  185. endif(CUDD_INCLUDE_DIRS)
  186. if (CUDD_LIBRARY_DIRS)
  187. link_directories(${CUDD_LIBRARY_DIRS})
  188. endif(CUDD_LIBRARY_DIRS)
  189. # Add the executables
  190. # Must be created *after* Boost was added because of LINK_DIRECTORIES
  191. add_executable(storm ${STORM_SOURCES} ${STORM_HEADERS})
  192. add_executable(storm-tests ${STORM_TEST_FILES} ${STORM_SOURCES_WITHOUT_MAIN} ${STORM_HEADERS})
  193. # Add target link deps for Boost program options
  194. target_link_libraries(storm ${Boost_LIBRARIES})
  195. target_link_libraries(storm-tests ${Boost_LIBRARIES})
  196. if (USE_INTELTBB)
  197. target_link_libraries(storm tbb tbbmalloc)
  198. target_link_libraries(storm-tests tbb tbbmalloc)
  199. endif(USE_INTELTBB)
  200. if (APPLE)
  201. set(STORM_USE_COTIRE OFF)
  202. # Set up some Xcode specific settings
  203. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
  204. set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
  205. endif(APPLE)
  206. # Print Cotire Usage Status
  207. message (STATUS "Using Cotire: ${STORM_USE_COTIRE}")
  208. if (STORM_USE_COTIRE)
  209. # Include Cotire for PCH Generation
  210. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  211. include(cotire)
  212. cotire(storm)
  213. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  214. #cotire(storm-tests)
  215. endif()
  216. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  217. if (LINK_LIBCXXABI)
  218. message (STATUS "Linking against libc++abi.")
  219. target_link_libraries(storm "c++abi")
  220. target_link_libraries(storm-tests "c++abi")
  221. endif(LINK_LIBCXXABI)
  222. # Add a target to generate API documentation with Doxygen
  223. if(DOXYGEN_FOUND)
  224. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  225. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  226. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  227. add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COMMENT "Generating API documentation with Doxygen" VERBATIM)
  228. endif(DOXYGEN_FOUND)
  229. if (GTEST_INCLUDE_DIR)
  230. # For make-based builds, defines make target named test.
  231. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  232. enable_testing()
  233. include_directories(${GTEST_INCLUDE_DIR})
  234. target_link_libraries(storm-tests ${GTEST_LIBRARIES})
  235. add_test(NAME storm-tests COMMAND storm-tests)
  236. if(MSVC) # VS2012 doesn't support correctly the tuples yet
  237. add_definitions( /D _VARIADIC_MAX=10 )
  238. endif()
  239. endif(GTEST_INCLUDE_DIR)
  240. if (LOG4CPLUS_INCLUDE_DIR)
  241. include_directories(${LOG4CPLUS_INCLUDE_DIR})
  242. target_link_libraries(storm ${LOG4CPLUS_LIBRARIES})
  243. if (STORM_USE_COTIRE)
  244. target_link_libraries(storm_unity ${LOG4CPLUS_LIBRARIES})
  245. endif(STORM_USE_COTIRE)
  246. target_link_libraries(storm-tests ${LOG4CPLUS_LIBRARIES})
  247. # On Linux, we have to link against librt
  248. if (UNIX AND NOT APPLE)
  249. target_link_libraries(storm rt)
  250. if (STORM_USE_COTIRE)
  251. target_link_libraries(storm_unity rt)
  252. endif(STORM_USE_COTIRE)
  253. target_link_libraries(storm-tests rt)
  254. endif(UNIX AND NOT APPLE)
  255. endif(LOG4CPLUS_INCLUDE_DIR)
  256. if (CUDD_LIBRARY_DIRS)
  257. target_link_libraries(storm "-lobj -lcudd -lmtr -lst -lutil -lepd")
  258. target_link_libraries(storm-tests "-lobj -lcudd -lmtr -lst -lutil -lepd")
  259. endif(CUDD_LIBRARY_DIRS)
  260. if (THREADS_FOUND)
  261. include_directories(${THREADS_INCLUDE_DIRS})
  262. target_link_libraries(storm ${CMAKE_THREAD_LIBS_INIT})
  263. if (STORM_USE_COTIRE)
  264. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  265. endif(STORM_USE_COTIRE)
  266. target_link_libraries(storm-tests ${CMAKE_THREAD_LIBS_INIT})
  267. endif(THREADS_FOUND)
  268. # Configure a header file to pass some of the CMake settings to the source code
  269. configure_file (
  270. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  271. "${PROJECT_BINARY_DIR}/storm-config.h"
  272. )
  273. 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
  274. DEPENDS storm)
  275. add_custom_target(memcheck-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-tests -v --fix-deadlocks
  276. DEPENDS storm-tests)
  277. set (CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  278. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp"`)