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.

249 lines
11 KiB

  1. cmake_minimum_required (VERSION 2.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(LINK_LIBCXXABI "Sets whether libc++abi should be linked" OFF)
  50. set(ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "Additional directories added to the include directories.")
  51. set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the link directories.")
  52. set(CUSTOM_BOOST_ROOT "" CACHE STRING "A custom path to the Boost root directory.")
  53. # If the DEBUG option was turned on, we will target a debug version and a release version otherwise
  54. if (DEBUG)
  55. set (CMAKE_BUILD_TYPE "DEBUG")
  56. message(STATUS "Building DEBUG version.")
  57. else()
  58. set (CMAKE_BUILD_TYPE "RELEASE")
  59. message(STATUS "Building RELEASE version.")
  60. endif()
  61. if(CMAKE_COMPILER_IS_GNUCC)
  62. # Set standard flags for GCC
  63. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops")
  64. set (CMAKE_CXX_FLAGS "-std=c++0x -Wall -pedantic")
  65. # -Werror is atm removed as this gave some problems with existing code
  66. # May be re-set later
  67. # (Thomas Heinemann, 2012-12-21)
  68. # Turn on popcnt instruction if desired (yes by default)
  69. if (USE_POPCNT)
  70. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  71. endif(USE_POPCNT)
  72. elseif(MSVC)
  73. # required for GMM to compile, ugly error directive in their code
  74. add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
  75. else(CLANG)
  76. # As CLANG is not set as a variable, we need to set it in case we have not matched another compiler.
  77. set (CLANG ON)
  78. # Set standard flags for clang
  79. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -funroll-loops -O4")
  80. set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Werror -pedantic -Wno-unused-variable -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE")
  81. # Turn on popcnt instruction if desired (yes by default)
  82. if (USE_POPCNT)
  83. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
  84. endif(USE_POPCNT)
  85. endif()
  86. # Add the binary folder to the search path for include files so that we will find storm-config.h
  87. include_directories("${PROJECT_BINARY_DIR}")
  88. # Base path for test files
  89. set(STORM_CPP_TESTS_BASE_PATH ${PROJECT_SOURCE_DIR}/test)
  90. message(STATUS "STORM_CPP_TESTS_BASE_PATH is ${STORM_CPP_TESTS_BASE_PATH}")
  91. # Main Sources
  92. file(GLOB_RECURSE STORM_HEADERS ${PROJECT_SOURCE_DIR}/src/*.h)
  93. file(GLOB_RECURSE STORM_SOURCES ${PROJECT_SOURCE_DIR}/src/*.cpp)
  94. # Test Sources
  95. # Note that the tests also need the source files, except for the main file
  96. file(GLOB_RECURSE STORM_TEST_HEADERS ${PROJECT_SOURCE_DIR}/test/*.h)
  97. file(GLOB_RECURSE STORM_TEST_SOURCES ${PROJECT_SOURCE_DIR}/test/*.cpp ${PROJECT_SOURCE_DIR}/src/*/*.cpp)
  98. # Main Grouping
  99. source_group(Headers FILES ${STORM_HEADERS})
  100. source_group(Sources FILES ${STORM_SOURCES})
  101. # Test Grouping
  102. source_group(Headers FILES ${STORM_TEST_HEADERS})
  103. source_group(Sources FILES ${STORM_TEST_SOURCES})
  104. # Add base folder for better inclusion paths
  105. include_directories("${PROJECT_SOURCE_DIR}")
  106. include_directories("${PROJECT_SOURCE_DIR}/src")
  107. # Set required external packages
  108. find_package(Threads REQUIRED)
  109. find_package(Doxygen REQUIRED)
  110. set(Boost_USE_STATIC_LIBS ON)
  111. set(Boost_USE_MULTITHREADED ON)
  112. set(Boost_USE_STATIC_RUNTIME OFF)
  113. # If a custom boost root directory was specified, we set the corresponding hint for the script to find it.
  114. if(CUSTOM_BOOST_ROOT)
  115. set(BOOST_ROOT "${CUSTOM_BOOST_ROOT}")
  116. endif(CUSTOM_BOOST_ROOT)
  117. find_package(Boost REQUIRED COMPONENTS program_options)
  118. if(Boost_FOUND)
  119. if ((NOT Boost_LIBRARY_DIRS) OR ("${Boost_LIBRARY_DIRS}" STREQUAL ""))
  120. set(Boost_LIBRARY_DIRS "${Boost_INCLUDE_DIRS}/stage/lib")
  121. endif ()
  122. message(STATUS "BOOST_INCLUDE_DIRS is ${Boost_INCLUDE_DIRS}")
  123. message(STATUS "BOOST_LIBRARY_DIRS is ${Boost_LIBRARY_DIRS}")
  124. include_directories(${Boost_INCLUDE_DIRS})
  125. link_directories(${Boost_LIBRARY_DIRS})
  126. endif(Boost_FOUND)
  127. # Add Eigen to the included directories
  128. include_directories(${EIGEN3_INCLUDE_DIR})
  129. # Add GMMXX to the included directories
  130. include_directories(${GMMXX_INCLUDE_DIR})
  131. # Add custom additional include or link directories
  132. if (ADDITIONAL_INCLUDE_DIRS)
  133. message(STATUS "Using additional include directories ${ADDITIONAL_INCLUDE_DIRS}")
  134. include_directories(${ADDITIONAL_INCLUDE_DIRS})
  135. endif(ADDITIONAL_INCLUDE_DIRS)
  136. if (ADDITIONAL_LINK_DIRS)
  137. message(STATUS "Using additional link directories ${ADDITIONAL_LINK_DIRS}")
  138. link_directories(${ADDITIONAL_LINK_DIRS})
  139. endif(ADDITIONAL_LINK_DIRS)
  140. if (CUDD_INCLUDE_DIRS)
  141. include_directories(${CUDD_INCLUDE_DIRS})
  142. endif(CUDD_INCLUDE_DIRS)
  143. if (CUDD_LIBRARY_DIRS)
  144. link_directories(${CUDD_LIBRARY_DIRS})
  145. endif(CUDD_LIBRARY_DIRS)
  146. # Add the executables
  147. # Must be created *after* Boost was added because of LINK_DIRECTORIES
  148. add_executable(storm ${STORM_SOURCES} ${STORM_HEADERS})
  149. add_executable(storm-tests ${STORM_TEST_SOURCES} ${STORM_TEST_HEADERS})
  150. # Add target link deps for Boost program options
  151. target_link_libraries(storm ${Boost_LIBRARIES})
  152. target_link_libraries(storm-tests ${Boost_LIBRARIES})
  153. # Link against libc++abi if requested. May be needed to build on Linux systems using clang.
  154. if (LINK_LIBCXXABI)
  155. message (STATUS "Linking against libc++abi.")
  156. target_link_libraries(storm "c++abi")
  157. target_link_libraries(storm-tests "c++abi")
  158. endif(LINK_LIBCXXABI)
  159. # Add a target to generate API documentation with Doxygen
  160. if(DOXYGEN_FOUND)
  161. set(CMAKE_DOXYGEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
  162. string(REGEX REPLACE ";" " " CMAKE_DOXYGEN_INPUT_LIST "${PROJECT_SOURCE_DIR}/src")
  163. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  164. add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile COMMENT "Generating API documentation with Doxygen" VERBATIM)
  165. endif(DOXYGEN_FOUND)
  166. if (GTEST_INCLUDE_DIR)
  167. # For make-based builds, defines make target named test.
  168. # For Visual Studio builds, defines Visual Studio project named RUN_TESTS.
  169. enable_testing()
  170. include_directories(${GTEST_INCLUDE_DIR})
  171. target_link_libraries(storm-tests ${GTEST_LIBRARIES})
  172. add_test(NAME storm-tests COMMAND storm-tests)
  173. if(MSVC) # VS2012 doesn't support correctly the tuples yet
  174. add_definitions( /D _VARIADIC_MAX=10 )
  175. endif()
  176. endif(GTEST_INCLUDE_DIR)
  177. if (LOG4CPLUS_INCLUDE_DIR)
  178. include_directories(${LOG4CPLUS_INCLUDE_DIR})
  179. target_link_libraries(storm ${LOG4CPLUS_LIBRARIES})
  180. target_link_libraries(storm-tests ${LOG4CPLUS_LIBRARIES})
  181. # On Linux, we have to link against librt
  182. if (UNIX AND NOT APPLE)
  183. target_link_libraries(storm rt)
  184. target_link_libraries(storm-tests rt)
  185. endif(UNIX AND NOT APPLE)
  186. endif(LOG4CPLUS_INCLUDE_DIR)
  187. if (CUDD_LIBRARY_DIRS)
  188. target_link_libraries(storm "-lobj -lcudd -lmtr -lst -lutil -lepd")
  189. target_link_libraries(storm-tests "-lobj -lcudd -lmtr -lst -lutil -lepd")
  190. endif(CUDD_LIBRARY_DIRS)
  191. if (THREADS_FOUND)
  192. include_directories(${THREADS_INCLUDE_DIRS})
  193. target_link_libraries (storm ${CMAKE_THREAD_LIBS_INIT})
  194. target_link_libraries (storm-tests ${CMAKE_THREAD_LIBS_INIT})
  195. endif(THREADS_FOUND)
  196. # Configure a header file to pass some of the CMake settings to the source code
  197. configure_file (
  198. "${PROJECT_SOURCE_DIR}/storm-config.h.in"
  199. "${PROJECT_BINARY_DIR}/storm-config.h"
  200. )
  201. 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
  202. DEPENDS storm)
  203. add_custom_target(memcheck-tests valgrind --leak-check=full --show-reachable=yes ${PROJECT_BINARY_DIR}/storm-tests -v --fix-deadlocks
  204. DEPENDS storm-tests)
  205. set (CPPLINT_ARGS --filter=-whitespace/tab,-whitespace/line_length,-legal/copyright,-readability/streams)
  206. add_custom_target(style python cpplint.py ${CPPLINT_ARGS} `find ./src/ -iname "*.h" -or -iname "*.cpp"`)