CMakeLists.txt 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
  2. PROJECT(ARTIS CXX C)
  3. ENABLE_TESTING()
  4. SET(ARTIS_MAJOR 1)
  5. SET(ARTIS_MINOR 0)
  6. SET(ARTIS_PATCH 0)
  7. SET(ARTIS_EXTRA "")
  8. SET(ARTIS_VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}")
  9. SET(ARTIS_VERSION_SHORT "${ARTIS_MAJOR}.${ARTIS_MINOR}")
  10. SET(ARTIS_NAME "artis")
  11. SET(ARTIS_NAME_VERSION "${ARTIS_NAME}-${ARTIS_VERSION}")
  12. SET(ARTIS_LOCALE_NAME "${ARTIS_NAME}-${ARTIS_MAJOR}-${ARTIS_MINOR}")
  13. IF ("${ARTIS_EXTRA}" STREQUAL "")
  14. SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}")
  15. ELSE ("${ARTIS_EXTRA}" STREQUAL "")
  16. SET(ARTIS_COMPLETE "${ARTIS_MAJOR}.${ARTIS_MINOR}.${ARTIS_PATCH}-${ARTIS_EXTRA}")
  17. ENDIF ("${ARTIS_EXTRA}" STREQUAL "")
  18. SET(ARTIS_NAME_COMPLETE "${ARTIS_NAME}-${ARTIS_COMPLETE}")
  19. #
  20. # Installation variables
  21. #
  22. SET(ARTIS_LIBRARY_DIRS "lib/artis-${ARTIS_VERSION_SHORT}")
  23. SET(ARTIS_INCLUDE_DIRS "include/artis-${ARTIS_VERSION_SHORT}/artis")
  24. SET(ARTIS_INCLUDE_DIR "include/artis-${ARTIS_VERSION_SHORT}")
  25. SET(ARTIS_MANPAGE_PATH "share/man/man1")
  26. SET(ARTIS_SHARE_DIRS "share/artis-${ARTIS_VERSION_SHORT}")
  27. #
  28. # Append the library version information to the library target
  29. # properties.
  30. #
  31. SET (ARTIS_LIBRARY_PROPERTIES VERSION 0)
  32. SET (ARTIS_APP_PROPERTIES SOVERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}"
  33. VERSION "${ARTIS_MAJOR}.${ARTIS_MINOR}")
  34. #
  35. # CPack configuration
  36. #
  37. INCLUDE(CMakeCPack.cmake)
  38. #
  39. # Append debug mode when compiler is GNU.
  40. #
  41. if (CMAKE_BUILD_TYPE STREQUAL "")
  42. SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
  43. endif ()
  44. if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
  45. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
  46. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11")
  47. if ("${CMAKE_BUILD_TYPE}" EQUAL "Debug" OR "${CMAKE_BUILD_TYPE}" EQUAL "RelWithDebInfo")
  48. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb3")
  49. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb3")
  50. endif ()
  51. endif ()
  52. if (CMAKE_BUILD_TYPE STREQUAL "")
  53. SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build" FORCE)
  54. endif ()
  55. #
  56. # Modules
  57. #
  58. INCLUDE(CheckIncludeFileCXX)
  59. INCLUDE(CheckIncludeFile)
  60. INCLUDE(CheckLibraryExists)
  61. INCLUDE(CMakeDetermineCCompiler)
  62. #
  63. # Check libraries with pkgconfig
  64. #
  65. FIND_PACKAGE(PkgConfig REQUIRED)
  66. # FIXME use old-style link directories for now
  67. IF (COMMAND CMAKE_POLICY)
  68. CMAKE_POLICY(SET CMP0003 OLD)
  69. ENDIF (COMMAND CMAKE_POLICY)
  70. #
  71. # Test the libboost header and libboost-text library.
  72. #
  73. OPTION(WITH_TEST "use the libboost test unit library [default: on]" ON)
  74. SET(Boost_USE_MULTITHREADED ON)
  75. SET(Boost_USE_STATIC_LIBS OFF)
  76. SET(Boost_NO_SYSTEM_PATHS OFF)
  77. SET(Boost_USE_STATIC_RUNTIME ON)
  78. IF (WIN32)
  79. SET(Boost_THREADAPI "win32")
  80. ENDIF (WIN32)
  81. SET(Boost_DETAILED_FAILURE_MSG FALSE)
  82. SET(Boost_DEBUG FALSE)
  83. FIND_PACKAGE(Boost COMPONENTS serialization)
  84. #
  85. # Generate the config.h
  86. #
  87. CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
  88. CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
  89. CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
  90. INCLUDE_DIRECTORIES(${ARTIS_BINARY_DIR})
  91. #
  92. # Generate the vle.pc pkg-config file.
  93. # Build some variable to build a correct Win32 pkg config file with:
  94. # prefix=/target to detect the DIRNAME
  95. # cflag=-Iboost_1_34_1 for the directory
  96. #
  97. SET(ARTIS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
  98. SET(ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
  99. SET(ARTIS_PKGCONFIG_LIBDIR "lib")
  100. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis.pc.in
  101. ${ARTIS_BINARY_DIR}/artis-${ARTIS_VERSION_SHORT}.pc @ONLY)
  102. INSTALL(FILES ${ARTIS_BINARY_DIR}/artis-${ARTIS_VERSION_SHORT}.pc
  103. DESTINATION lib/pkgconfig)
  104. #
  105. # Install the README
  106. #
  107. IF(UNIX)
  108. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}")
  109. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}")
  110. ELSE(UNIX)
  111. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "Readme.txt")
  112. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "CopyRight.txt")
  113. ENDIF(UNIX)
  114. #
  115. # Add sources for a target
  116. # add_sources(<target> <source1> [<source2> ...])
  117. #
  118. function(add_sources target)
  119. get_property(prop_defined GLOBAL PROPERTY ${target}_SRCS DEFINED)
  120. if(NOT prop_defined)
  121. define_property(GLOBAL PROPERTY ${target}_SRCS
  122. BRIEF_DOCS "Sources for the ${target} target"
  123. FULL_DOCS "List of source files for the ${target} target")
  124. endif()
  125. set(SRCS)
  126. foreach(src ${ARGN})
  127. if(NOT IS_ABSOLUTE "${src}")
  128. get_filename_component(src "${src}" ABSOLUTE)
  129. endif()
  130. list(APPEND SRCS "${src}")
  131. endforeach()
  132. set_property(GLOBAL APPEND PROPERTY "${target}_SRCS" "${SRCS}")
  133. endfunction()
  134. #
  135. # Browse the src subdirectory
  136. #
  137. ADD_SUBDIRECTORY(src)
  138. #
  139. # Status
  140. #
  141. MESSAGE(STATUS "- - - -")
  142. MESSAGE(STATUS "${ARTIS_NAME_COMPLETE} configured successfully")
  143. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  144. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  145. IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  146. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  147. ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  148. IF (ARTIS_HAVE_EXECINFO)
  149. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  150. ENDIF (ARTIS_HAVE_EXECINFO)
  151. IF (Boost_FOUND)
  152. MESSAGE(STATUS "Build with boost..............: yes")
  153. ENDIF (Boost_FOUND)
  154. MESSAGE(STATUS "- - - -")
  155. # vim:tw=0:ts=8:tw=0:sw=2:sts=2