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.

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