CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. cmake_minimum_required(VERSION 2.8)
  2. project(libjson-rpc-cpp)
  3. # list command no longer ignores empty elements
  4. cmake_policy(SET CMP0007 NEW)
  5. cmake_policy(SET CMP0012 NEW)
  6. if (${CMAKE_MAJOR_VERSION} GREATER 2)
  7. # old policy do not use MACOSX_RPATH
  8. cmake_policy(SET CMP0042 OLD)
  9. endif()
  10. set(MAJOR_VERSION 0)
  11. set(MINOR_VERSION 7)
  12. set(PATCH_VERSION 0)
  13. set(SO_VERSION 0)
  14. set(BUILD_SHARED_LIBS YES CACHE BOOL "Build shared libraries")
  15. set(BUILD_STATIC_LIBS NO CACHE BOOL "Build static libraries")
  16. set(LIB_SUFFIX "" CACHE STRING "Suffix for library directory (32/64)")
  17. if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
  18. message(FATAL_ERROR "Both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS are disabled")
  19. endif()
  20. # defaults for modules that can be enabled/disabled
  21. if(UNIX)
  22. set(UNIX_DOMAIN_SOCKET_SERVER YES CACHE BOOL "Include Unix Domain Socket server")
  23. set(UNIX_DOMAIN_SOCKET_CLIENT YES CACHE BOOL "Include Unix Domain Socket client")
  24. endif(UNIX)
  25. set(TCP_SOCKET_SERVER NO CACHE BOOL "Include Tcp Socket server")
  26. set(TCP_SOCKET_CLIENT NO CACHE BOOL "Include Tcp Socket client")
  27. set(HTTP_SERVER YES CACHE BOOL "Include HTTP server using libmicrohttpd")
  28. set(HTTP_CLIENT YES CACHE BOOL "Include HTTP client support using curl")
  29. set(COMPILE_TESTS YES CACHE BOOL "Compile test framework")
  30. set(COMPILE_STUBGEN YES CACHE BOOL "Compile the stubgenerator")
  31. set(COMPILE_EXAMPLES YES CACHE BOOL "Compile example programs")
  32. # print actual settings
  33. if(UNIX)
  34. message(STATUS "UNIX_DOMAIN_SOCKET_SERVER: ${UNIX_DOMAIN_SOCKET_SERVER}")
  35. message(STATUS "UNIX_DOMAIN_SOCKET_CLIENT: ${UNIX_DOMAIN_SOCKET_CLIENT}")
  36. endif(UNIX)
  37. message(STATUS "TCP_SOCKET_SERVER: ${TCP_SOCKET_SERVER}")
  38. message(STATUS "TCP_SOCKET_CLIENT: ${TCP_SOCKET_CLIENT}")
  39. message(STATUS "HTTP_SERVER: ${HTTP_SERVER}")
  40. message(STATUS "HTTP_CLIENT: ${HTTP_CLIENT}")
  41. if(UNIX)
  42. message(STATUS "UNIXDOMAINSOCKET_SERVER: ${UNIX_DOMAIN_SOCKET_SERVER}")
  43. message(STATUS "UNIXDOMAINSOCKET_CLIENT: ${UNIX_DOMAIN_SOCKET_CLIENT}")
  44. endif(UNIX)
  45. message(STATUS "COMPILE_TESTS: ${COMPILE_TESTS}")
  46. message(STATUS "COMPILE_STUBGEN: ${COMPILE_STUBGEN}")
  47. message(STATUS "COMPILE_EXAMPLES: ${COMPILE_EXAMPLES}")
  48. # setup directory where we should look for cmake files
  49. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
  50. # setup compiler settings && dependencies
  51. include(CMakeCompilerSettings)
  52. include(CMakeDependencies)
  53. # setup output directories
  54. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
  55. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
  56. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
  57. if (WIN32)
  58. set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/dist)
  59. endif()
  60. # setup global include_directories (for backwards compatibility)
  61. include_directories("${CMAKE_BINARY_DIR}/gen/")
  62. include_directories("${CMAKE_BINARY_DIR}/gen/jsonrpccpp/common")
  63. # the core framework
  64. add_subdirectory(src/jsonrpccpp)
  65. #the stubgenerator
  66. if (COMPILE_STUBGEN)
  67. add_subdirectory(src/stubgenerator)
  68. endif ()
  69. # setup examples
  70. if (COMPILE_EXAMPLES)
  71. add_subdirectory(src/examples)
  72. endif()
  73. # setup test suite
  74. if (COMPILE_TESTS)
  75. enable_testing(true)
  76. add_subdirectory(src/test)
  77. endif()
  78. # create documentation
  79. if (DOXYGEN_FOUND)
  80. file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/doc)
  81. message(STATUS "Found doxygen: ${DOXYGEN_EXECUTABLE}")
  82. configure_file("${PROJECT_SOURCE_DIR}/doc/doxyfile.in" "${CMAKE_BINARY_DIR}/Doxyfile" @ONLY)
  83. add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc COMMENT "Generating API documentation")
  84. endif(DOXYGEN_FOUND)
  85. # setup uninstall target
  86. configure_file(
  87. "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
  88. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  89. IMMEDIATE @ONLY
  90. )
  91. add_custom_target(
  92. uninstall
  93. COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
  94. )
  95. # packaging stuff
  96. include(CMakePackaging)