CMakeLists.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  2. PROJECT(PARADEVS CXX C)
  3. ENABLE_TESTING()
  4. SET(PARADEVS_MAJOR 1)
  5. SET(PARADEVS_MINOR 0)
  6. SET(PARADEVS_PATCH 0)
  7. SET(PARADEVS_EXTRA "")
  8. SET(PARADEVS_VERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}")
  9. SET(PARADEVS_VERSION_SHORT "${PARADEVS_MAJOR}.${PARADEVS_MINOR}")
  10. SET(PARADEVS_NAME "paradevs")
  11. SET(PARADEVS_NAME_VERSION "${PARADEVS_NAME}-${PARADEVS_VERSION}")
  12. SET(PARADEVS_LOCALE_NAME "${PARADEVS_NAME}-${PARADEVS_MAJOR}-${PARADEVS_MINOR}")
  13. IF ("${PARADEVS_EXTRA}" STREQUAL "")
  14. SET(PARADEVS_COMPLETE "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}")
  15. ELSE ("${PARADEVS_EXTRA}" STREQUAL "")
  16. SET(PARADEVS_COMPLETE "${PARADEVS_MAJOR}.${PARADEVS_MINOR}.${PARADEVS_PATCH}-${PARADEVS_EXTRA}")
  17. ENDIF ("${PARADEVS_EXTRA}" STREQUAL "")
  18. SET(PARADEVS_NAME_COMPLETE "${PARADEVS_NAME}-${PARADEVS_COMPLETE}")
  19. #
  20. # Installation variables
  21. #
  22. SET(PARADEVS_LIBRARY_DIRS "lib/vle-${PARADEVS_VERSION_SHORT}")
  23. SET(PARADEVS_INCLUDE_DIRS "include/vle-${PARADEVS_VERSION_SHORT}/vle")
  24. SET(PARADEVS_INCLUDE_DIR "include/vle-${PARADEVS_VERSION_SHORT}")
  25. SET(PARADEVS_MANPAGE_PATH "share/man/man1")
  26. SET(PARADEVS_SHARE_DIRS "share/vle-${PARADEVS_VERSION_SHORT}")
  27. #
  28. # Append the library version information to the library target
  29. # properties.
  30. #
  31. SET (PARADEVS_LIBRARY_PROPERTIES VERSION 0)
  32. SET (PARADEVS_APP_PROPERTIES SOVERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}"
  33. VERSION "${PARADEVS_MAJOR}.${PARADEVS_MINOR}")
  34. #
  35. # CPack configuration
  36. #
  37. INCLUDE(CMakeCPack.cmake)
  38. #
  39. # Debug mode
  40. #
  41. IF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
  42. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
  43. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
  44. IF (UNIX)
  45. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
  46. SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  47. ENDIF (UNIX)
  48. ENDIF (CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
  49. if (CMAKE_BUILD_TYPE STREQUAL "")
  50. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  51. endif ()
  52. #
  53. # Modules
  54. #
  55. INCLUDE(CheckIncludeFileCXX)
  56. INCLUDE(CheckIncludeFile)
  57. INCLUDE(CheckLibraryExists)
  58. INCLUDE(CMakeDetermineCCompiler)
  59. #
  60. # Check libraries with pkgconfig
  61. #
  62. FIND_PACKAGE(PkgConfig REQUIRED)
  63. # FIXME use old-style link directories for now
  64. IF (COMMAND CMAKE_POLICY)
  65. CMAKE_POLICY(SET CMP0003 OLD)
  66. ENDIF (COMMAND CMAKE_POLICY)
  67. PKG_CHECK_MODULES(GLIBMM REQUIRED glibmm-2.4)
  68. PKG_CHECK_MODULES(LIBXML REQUIRED libxml-2.0)
  69. #
  70. # Test the libboost header and libboost-text library.
  71. #
  72. OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
  73. SET(Boost_USE_MULTITHREADED ON)
  74. SET(Boost_USE_STATIC_LIBS OFF)
  75. SET(Boost_NO_SYSTEM_PATHS OFF)
  76. SET(Boost_USE_STATIC_RUNTIME ON)
  77. IF (WIN32)
  78. SET(Boost_THREADAPI "win32")
  79. ENDIF (WIN32)
  80. SET(Boost_DETAILED_FAILURE_MSG FALSE)
  81. SET(Boost_DEBUG FALSE)
  82. FIND_PACKAGE(Boost COMPONENTS unit_test_framework serialization filesystem
  83. system date_time regex thread)
  84. IF (NOT Boost_SERIALIZATION_FOUND)
  85. MESSAGE(FATAL_ERROR "The boost serialization library is required")
  86. ENDIF (NOT Boost_SERIALIZATION_FOUND)
  87. IF (NOT Boost_FILESYSTEM_FOUND)
  88. MESSAGE(FATAL_ERROR "The boost filesystem library is required")
  89. ENDIF (NOT Boost_FILESYSTEM_FOUND)
  90. IF (NOT Boost_REGEX_FOUND)
  91. MESSAGE(FATAL_ERROR "The boost regex library is required")
  92. ENDIF (NOT Boost_REGEX_FOUND)
  93. IF (NOT Boost_DATE_TIME_FOUND)
  94. MESSAGE(FATAL_ERROR "The boost date_time library is required")
  95. ENDIF (NOT Boost_DATE_TIME_FOUND)
  96. IF (NOT Boost_THREAD_FOUND)
  97. MESSAGE(FATAL_ERROR "The boost thread library is required")
  98. ENDIF (NOT Boost_THREAD_FOUND)
  99. IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
  100. SET(Boost_SYSTEM_LIBRARY "")
  101. ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "35")
  102. IF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
  103. SET(PARADEVS_HAVE_BOOST_SPIRIT2 0 CACHE INTERNAL "" FORCE)
  104. ELSE (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
  105. SET(PARADEVS_HAVE_BOOST_SPIRIT2 1 CACHE INTERNAL "" FORCE)
  106. ENDIF (Boost_MINOR_VERSION AND ${Boost_MINOR_VERSION} LESS "41")
  107. IF (WITH_TEST)
  108. IF (Boost_UNIT_TEST_FRAMEWORK_FOUND)
  109. SET(HAVE_UNITTESTFRAMEWORK 1 CACHE INTERNAL "" FORCE)
  110. ENDIF (Boost_UNIT_TEST_FRAMEWORK_FOUND)
  111. ENDIF (WITH_TEST)
  112. #
  113. # Generate the config.h
  114. #
  115. CHECK_INCLUDE_FILE_CXX(cxxabi.h PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  116. CHECK_INCLUDE_FILE_CXX(execinfo.h PARADEVS_HAVE_EXECINFO)
  117. CHECK_INCLUDE_FILE_CXX(signal.h PARADEVS_HAVE_SIGNAL)
  118. INCLUDE_DIRECTORIES(${PARADEVS_BINARY_DIR})
  119. #
  120. # Generate the vle.pc pkg-config file.
  121. # Build some variable to build a correct Win32 pkg config file with:
  122. # prefix=/target to detect the DIRNAME
  123. # cflag=-Iboost_1_34_1 for the directory
  124. #
  125. SET(PARADEVS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
  126. SET(PARADEVS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
  127. SET(PARADEVS_PKGCONFIG_LIBDIR "lib")
  128. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/paradevs.pc.in
  129. ${PARADEVS_BINARY_DIR}/paradevs-${PARADEVS_VERSION_SHORT}.pc @ONLY)
  130. INSTALL(FILES ${PARADEVS_BINARY_DIR}/paradevs-${PARADEVS_VERSION_SHORT}.pc
  131. DESTINATION lib/pkgconfig)
  132. #
  133. # Install the README
  134. #
  135. IF(UNIX)
  136. INSTALL(FILES "README" DESTINATION "${PARADEVS_SHARE_DIRS}")
  137. INSTALL(FILES "COPYING" DESTINATION "${PARADEVS_SHARE_DIRS}")
  138. ELSE(UNIX)
  139. INSTALL(FILES "README" DESTINATION "${PARADEVS_SHARE_DIRS}" RENAME "Readme.txt")
  140. INSTALL(FILES "COPYING" DESTINATION "${PARADEVS_SHARE_DIRS}" RENAME "CopyRight.txt")
  141. ENDIF(UNIX)
  142. #
  143. # Browse the src subdirectory
  144. #
  145. ADD_SUBDIRECTORY(src)
  146. #
  147. # Status
  148. #
  149. MESSAGE(STATUS "- - - -")
  150. MESSAGE(STATUS "${PARADEVS_NAME_COMPLETE} configured successfully")
  151. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  152. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  153. IF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  154. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  155. ENDIF (PARADEVS_HAVE_GCC_ABI_DEMANGLE)
  156. IF (PARADEVS_HAVE_EXECINFO)
  157. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  158. ENDIF (PARADEVS_HAVE_EXECINFO)
  159. IF (Boost_FOUND)
  160. MESSAGE(STATUS "Build with boost..............: yes")
  161. ENDIF (Boost_FOUND)
  162. IF (HAVE_UNITTESTFRAMEWORK)
  163. MESSAGE(STATUS "Build unit test...............: yes")
  164. ENDIF (HAVE_UNITTESTFRAMEWORK)
  165. MESSAGE(STATUS "- - - -")
  166. # vim:tw=0:ts=8:tw=0:sw=2:sts=2