CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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++14")
  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. 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 serialization)
  83. #
  84. # Generate the config.h
  85. #
  86. CHECK_INCLUDE_FILE_CXX(cxxabi.h ARTIS_HAVE_GCC_ABI_DEMANGLE)
  87. CHECK_INCLUDE_FILE_CXX(execinfo.h ARTIS_HAVE_EXECINFO)
  88. CHECK_INCLUDE_FILE_CXX(signal.h ARTIS_HAVE_SIGNAL)
  89. INCLUDE_DIRECTORIES(${ARTIS_BINARY_DIR})
  90. #
  91. # Generate the vle.pc pkg-config file.
  92. #
  93. SET(ARTIS_PKGCONFIG_PREFIXPATH "${CMAKE_INSTALL_PREFIX}")
  94. SET(ARTIS_PKGCONFIG_BOOSTINCLUDE_DIRS "${Boost_INCLUDE_DIRS}")
  95. SET(ARTIS_PKGCONFIG_LIBDIR "lib")
  96. CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/artis.pc.in
  97. ${ARTIS_BINARY_DIR}/artis-${ARTIS_VERSION_SHORT}.pc @ONLY)
  98. INSTALL(FILES ${ARTIS_BINARY_DIR}/artis-${ARTIS_VERSION_SHORT}.pc
  99. DESTINATION lib/pkgconfig)
  100. #
  101. # Install the README
  102. #
  103. IF(UNIX)
  104. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}")
  105. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}")
  106. ELSE(UNIX)
  107. INSTALL(FILES "README" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "Readme.txt")
  108. INSTALL(FILES "COPYING" DESTINATION "${ARTIS_SHARE_DIRS}" RENAME "CopyRight.txt")
  109. ENDIF(UNIX)
  110. #
  111. # Add sources for a target
  112. # add_sources(<target> <source1> [<source2> ...])
  113. #
  114. function(add_sources target)
  115. get_property(prop_defined GLOBAL PROPERTY ${target}_SRCS DEFINED)
  116. if(NOT prop_defined)
  117. define_property(GLOBAL PROPERTY ${target}_SRCS
  118. BRIEF_DOCS "Sources for the ${target} target"
  119. FULL_DOCS "List of source files for the ${target} target")
  120. endif()
  121. set(SRCS)
  122. foreach(src ${ARGN})
  123. if(NOT IS_ABSOLUTE "${src}")
  124. get_filename_component(src "${src}" ABSOLUTE)
  125. endif()
  126. list(APPEND SRCS "${src}")
  127. endforeach()
  128. set_property(GLOBAL APPEND PROPERTY "${target}_SRCS" "${SRCS}")
  129. endfunction()
  130. #
  131. # Browse the src subdirectory
  132. #
  133. ADD_SUBDIRECTORY(src)
  134. #
  135. # Status
  136. #
  137. MESSAGE(STATUS "- - - -")
  138. MESSAGE(STATUS "${ARTIS_NAME_COMPLETE} configured successfully")
  139. MESSAGE(STATUS "Using ${CMAKE_INSTALL_PREFIX} for installation")
  140. MESSAGE(STATUS "Build type ${CMAKE_BUILD_TYPE}")
  141. IF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  142. MESSAGE(STATUS "Build with GCC ABI Demangle...: yes")
  143. ENDIF (ARTIS_HAVE_GCC_ABI_DEMANGLE)
  144. IF (ARTIS_HAVE_EXECINFO)
  145. MESSAGE(STATUS "Build with execinfo.h.........: yes")
  146. ENDIF (ARTIS_HAVE_EXECINFO)
  147. IF (Boost_FOUND)
  148. MESSAGE(STATUS "Build with boost..............: yes")
  149. ENDIF (Boost_FOUND)
  150. MESSAGE(STATUS "- - - -")
  151. # vim:tw=0:ts=8:tw=0:sw=2:sts=2