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.

287 lines
12 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. # Now define all available custom options
  41. option(DEBUG "Sets whether the DEBUG mode is used" ON)
  42. option(USE_POPCNT "Sets whether the popcnt instruction is going to be used." ON)
  43. option(USE_BOOST_STATIC_LIBRARIES "Sets whether the Boost libraries should be linked statically." ON)
  44. option(USE_INTELTBB "Sets whether the Intel TBB Extensions should be used." OFF)
  45. option(STORM_USE_COTIRE "Sets whether Cotire should be used (for building precompiled headers)." OFF)
  46. # If the DEBUG option was turned on, we will target a debug version and a release version otherwise
  47. if (DEBUG)
  48. set (CMAKE_BUILD_TYPE "DEBUG")
  49. message(STATUS "Building DEBUG version.")
  50. else()
  51. set (CMAKE_BUILD_TYPE "RELEASE")
  52. message(STATUS "Building RELEASE version.")
  53. endif()
  54. message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
  55. message(STATUS "CMAKE_BUILD_TYPE (ENV): $ENV{CMAKE_BUILD_TYPE}")
  56. if(CMAKE_COMPILER_IS_GNUCC)
  57. message(STATUS "Using GCC")
  58. # Set standard flags for GCC
  59. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  60. set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -pedantic")
  61. # -Werror is atm removed as this gave some problems with existing code
  62. # May be re-set later
  63. # (Thomas Heinemann, 2012-12-21)
  64. # Turn on popcnt instruction if desired (yes by default)
  65. if (USE_POPCNT)
  66. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  67. endif(USE_POPCNT)
  68. elseif(MSVC)
  69. message(STATUS "Using MSVC")
  70. # required for GMM to compile, ugly error directive in their code
  71. add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
  72. else(CLANG)
  73. message(STATUS "Using CLANG")
  74. # Set standard flags for clang
  75. set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -funroll-loops -O4")
  76. set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Werror -pedantic -Wno-unused-variable")
  77. set (CMAKE_CXX_FLAGS_DEBUG "-g")
  78. # Turn on popcnt instruction if desired (yes by default)
  79. if (USE_POPCNT)
  80. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  81. endif(USE_POPCNT)
  82. endif()
  83. # Add the binary folder to the search path for include files so that we will find storm-config.h
  84. include_directories("${PROJECT_BINARY_DIR}")
  85. # Base path for test files
  86. set(STORM_CPP_TESTS_BASE_PATH ${PROJECT_SOURCE_DIR}/test)
  87. message(STATUS "STORM_CPP_TESTS_BASE_PATH is ${STORM_CPP_TESTS_BASE_PATH}")
  88. # Main Sources
  89. file(GLOB_RECURSE STORM_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h)
  90. file(GLOB_RECURSE STORM_SOURCES_WITHOUT_MAIN ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
  91. file(GLOB_RECURSE STORM_MAIN_FILE ${PROJECT_SOURCE_DIR}/src/storm.cpp)
  92. set(STORM_SOURCES "${STORM_SOURCES_WITHOUT_MAIN};${STORM_MAIN_FILE}")
  93. file(GLOB_RECURSE STORM_ADAPTERS_FILES ${PROJECT_SOURCE_DIR}/src/adapters/*.h ${PROJECT_SOURCE_DIR}/src/adapters/*.cpp)
  94. file(GLOB_RECURSE STORM_EXCEPTIONS_FILES ${PROJECT_SOURCE_DIR}/src/exceptions/*.h ${PROJECT_SOURCE_DIR}/src/exceptions/*.cpp)
  95. file(GLOB_RECURSE STORM_FORMULA_FILES ${PROJECT_SOURCE_DIR}/src/formula/*.h ${PROJECT_SOURCE_DIR}/src/formula/*.cpp)
  96. file(GLOB_RECURSE STORM_MODELCHECKER_FILES ${PROJECT_SOURCE_DIR}/src/modelchecker/*.h ${PROJECT_SOURCE_DIR}/src/modelchecker/*.cpp)
  97. file(GLOB_RECURSE STORM_MODELS_FILES ${PROJECT_SOURCE_DIR}/src/models/*.h ${PROJECT_SOURCE_DIR}/src/models/*.cpp)
  98. file(GLOB_RECURSE STORM_PARSER_FILES ${PROJECT_SOURCE_DIR}/src/parser/*.h ${PROJECT_SOURCE_DIR}/src/parser/*.cpp)
  99. file(GLOB_RECURSE STORM_STORAGE_FILES ${PROJECT_SOURCE_DIR}/src/storage/*.h ${PROJECT_SOURCE_DIR}/src/storage/*.cpp)
  100. file(GLOB_RECURSE STORM_UTILITY_FILES ${PROJECT_SOURCE_DIR}/src/utility/*.h ${PROJECT_SOURCE_DIR}/src/utility/*.cpp)
  101. # Test Sources
  102. # Note that the tests also need the source files, except for the main file
  103. file(GLOB_RECURSE STORM_TEST_FILES ${PROJECT_SOURCE_DIR}/test/*.h ${PROJECT_SOURCE_DIR}/test/*.cpp)
  104. # Group the headers and sources
  105. source_group(main FILES ${STORM_MAIN_FILE})
  106. source_group(adapters FILES ${STORM_ADAPTERS_FILES})
  107. source_group(exceptions FILES ${STORM_EXCEPTIONS_FILES})
  108. source_group(formula FILES ${STORM_FORMULA_FILES})
  109. source_group(modelchecker FILES ${STORM_MODELCHECKER_FILES})
  110. source_group(models FILES ${STORM_MODELS_FILES})
  111. source_group(parser FILES ${STORM_PARSER_FILES})
  112. source_group(storage FILES ${STORM_STORAGE_FILES})
  113. source_group(utility FILES ${STORM_UTILITY_FILES})
  114. source_group(test FILES ${STORM_TEST_FILES})
  115. # Add base folder for better inclusion paths
  116. include_directories("${PROJECT_SOURCE_DIR}")
  117. include_directories("${PROJECT_SOURCE_DIR}/src")
  118. # Preset pathes for Intel TBB to internal copy in /resources/3rdParty/tbb41_20130314_mergedWindowsLinuxMacOSX
  119. set(TBB_INSTALL_DIR "${PROJECT_SOURCE_DIR}/resources/3rdparty/tbb41_20130314_merged-win-lin-mac/")
  120. if(MSVC)
  121. set(ENV{TBB_ARCH_PLATFORM} "intel64/vc11")
  122. elseif(CMAKE_COMPILER_IS_GNUCC)
  123. set(ENV{TBB_ARCH_PLATFORM} "intel64/gcc4.4")
  124. else(CLANG)
  125. set(ENV{TBB_ARCH_PLATFORM} "intel64/clang3.2")
  126. endif()
  127. # Add the resources/cmake folder to Module Search Path for FindTBB.cmake
  128. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/resources/cmake/")
  129. # Set required external packages
  130. find_package(Threads REQUIRED)
  131. find_package(Doxygen REQUIRED)
  132. set(Boost_USE_STATIC_LIBS ON)
  133. set(Boost_USE_MULTITHREADED ON)
  134. set(Boost_USE_STATIC_RUNTIME OFF)
  135. find_package(Boost REQUIRED COMPONENTS program_options)
  136. find_package(TBB)
  137. if(Boost_FOUND)
  138. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  139. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  140. endif ()
  141. message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  142. message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  143. include_directories(${Boost_INCLUDE_DIRS})
  144. link_directories(${Boost_LIBRARY_DIRS})
  145. endif(Boost_FOUND)
  146. # Intels Thread Building Blocks
  147. if (TBB_FOUND)
  148. message(STATUS "Found TBB with Interface Version ${TBB_INTERFACE_VERSION}")
  149. if(USE_INTELTBB)
  150. add_definitions(-DGMM_USE_TBB)
  151. endif()
  152. include_directories(${TBB_INCLUDE_DIRS})
  153. link_directories(${TBB_LIBRARY_DIRS})
  154. endif(TBB_FOUND)
  155. # Add Eigen to the included directories
  156. include_directories(${EIGEN3_INCLUDE_DIR})
  157. # Add GMMXX to the included directories
  158. include_directories(${GMMXX_INCLUDE_DIR})
  159. # Add the executables
  160. # Must be created *after* Boost was added because of LINK_DIRECTORIES
  161. add_executable(storm ${STORM_SOURCES} ${STORM_HEADERS})
  162. add_executable(storm-tests ${STORM_TEST_FILES} ${STORM_SOURCES_WITHOUT_MAIN} ${STORM_HEADERS})
  163. # Add target link deps for Boost program options
  164. target_link_libraries(storm ${Boost_LIBRARIES})
  165. target_link_libraries(storm-tests ${Boost_LIBRARIES})
  166. if (USE_INTELTBB)
  167. target_link_libraries(storm tbb tbbmalloc)
  168. target_link_libraries(storm-tests tbb tbbmalloc)
  169. endif(USE_INTELTBB)
  170. if (APPLE)
  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(APPLE)
  176. # Print Cotire Usage Status
  177. message (STATUS "Using Cotire: ${STORM_USE_COTIRE}")
  178. if (STORM_USE_COTIRE)
  179. # Include Cotire for PCH Generation
  180. set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/resources/cmake")
  181. include(cotire)
  182. cotire(storm)
  183. target_link_libraries(storm_unity ${Boost_LIBRARIES})
  184. #cotire(storm-tests)
  185. endif()
  186. # Add a target to generate API documentation with Doxygen
  187. if(DOXYGEN_FOUND)
  188. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  189. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  190. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  191. add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COMMENT "Generating API documentation with Doxygen" VERBATIM)
  192. endif(DOXYGEN_FOUND)
  193. if (GTEST_INCLUDE_DIR)
  194. # For make-based builds, defines make target named test.
  195. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  196. enable_testing()
  197. include_directories(${GTEST_INCLUDE_DIR})
  198. target_link_libraries(storm-tests ${GTEST_LIBRARIES})
  199. add_test(NAME storm-tests COMMAND storm-tests)
  200. if(MSVC) # VS2012 doesn't support correctly the tuples yet
  201. add_definitions( /D _VARIADIC_MAX=10 )
  202. endif()
  203. endif(GTEST_INCLUDE_DIR)
  204. if (LOG4CPLUS_INCLUDE_DIR)
  205. include_directories(${LOG4CPLUS_INCLUDE_DIR})
  206. target_link_libraries(storm ${LOG4CPLUS_LIBRARIES})
  207. if (STORM_USE_COTIRE)
  208. target_link_libraries(storm_unity ${LOG4CPLUS_LIBRARIES})
  209. endif(STORM_USE_COTIRE)
  210. target_link_libraries(storm-tests ${LOG4CPLUS_LIBRARIES})
  211. # On Linux, we have to link against librt
  212. if (UNIX AND NOT APPLE)
  213. target_link_libraries(storm rt)
  214. if (STORM_USE_COTIRE)
  215. target_link_libraries(storm_unity rt)
  216. endif(STORM_USE_COTIRE)
  217. target_link_libraries(storm-tests rt)
  218. endif(UNIX AND NOT APPLE)
  219. endif(LOG4CPLUS_INCLUDE_DIR)
  220. if (THREADS_FOUND)
  221. include_directories(${THREADS_INCLUDE_DIRS})
  222. target_link_libraries(storm ${CMAKE_THREAD_LIBS_INIT})
  223. if (STORM_USE_COTIRE)
  224. target_link_libraries(storm_unity ${CMAKE_THREAD_LIBS_INIT})
  225. endif(STORM_USE_COTIRE)
  226. target_link_libraries(storm-tests ${CMAKE_THREAD_LIBS_INIT})
  227. endif(THREADS_FOUND)
  228. # Configure a header file to pass some of the CMake settings to the source code
  229. configure_file (
  230. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  231. "${PROJECT_BINARY_DIR}/storm-config.h"
  232. )
  233. 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
  234. DEPENDS storm)
  235. add_custom_target(memcheck-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-tests -v --fix-deadlocks
  236. DEPENDS storm-tests)
  237. set (CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  238. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp"`)