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.

105 lines
3.2 KiB

  1. # This block needs to stay before the project (log4cplus) line so that
  2. # the output files placed into Android's libs directory.
  3. if (CMAKE_TOOLCHAIN_FILE)
  4. # Android: set output folder to ${CMAKE_BINARY_DIR}
  5. set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH
  6. "root for library output, set this to change where android libs are compiled to")
  7. endif ()
  8. project (log4cplus)
  9. cmake_minimum_required (VERSION 2.8.0)
  10. include (Log4CPlusUtils.cmake)
  11. log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include"
  12. log4cplus_version_major log4cplus_version_minor log4cplus_version_patch)
  13. message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}")
  14. set (log4cplus_soversion 7)
  15. set (log4cplus_postfix "")
  16. option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON)
  17. find_package (Threads)
  18. message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}")
  19. set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  20. message(STATUS "Building shared libs: ${BUILD_SHARED_LIBS}")
  21. if (WIN32)
  22. set (UNICODE_DEFAULT ON)
  23. else (WIN32)
  24. set (UNICODE_DEFAULT OFF)
  25. endif (WIN32)
  26. if (MSVC)
  27. set (LOG4CPLUS_WORKING_LOCALE_DEFAULT ON)
  28. else (MSVC)
  29. set (CMAKE_CXX_FLAGS "-std=c++11")
  30. set (LOG4CPLUS_WORKING_LOCALE_DEFAULT OFF)
  31. endif (MSVC)
  32. option(LOG4CPLUS_WORKING_LOCALE "Define for compilers/standard libraries that support more than just the C locale."
  33. ${LOG4CPLUS_WORKING_LOCALE_DEFAULT})
  34. option(LOG4CPLUS_WORKING_C_LOCALE
  35. "Define for compilers/standard libraries that have working C locale."
  36. OFF)
  37. option (LOG4CPLUS_QT4 "Build with Qt4DebugAppender" OFF)
  38. option(UNICODE "Build with tchar = wchar_t" ${UNICODE_DEFAULT})
  39. option(WITH_ICONV "Use iconv() for char->wchar_t conversion."
  40. OFF)
  41. set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.")
  42. if (NOT ${BUILD_SHARED_LIBS})
  43. # set S-prefix for static build
  44. set (log4cplus_postfix "${log4cplus_postfix}S")
  45. endif()
  46. if (UNICODE)
  47. set (log4cplus_postfix "${log4cplus_postfix}U")
  48. endif (UNICODE)
  49. if (WITH_ICONV)
  50. set(LOG4CPLUS_WITH_ICONV 1)
  51. endif ()
  52. set (log4cplus "log4cplus${log4cplus_postfix}")
  53. include(ConfigureChecks.cmake)
  54. # Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of
  55. # string manipulation.
  56. file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER)
  57. string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)"
  58. "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}")
  59. set(DEFINES_HXX_CMAKE
  60. ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake)
  61. set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx)
  62. file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER})
  63. configure_file(${DEFINES_HXX_CMAKE} ${DEFINES_HXX} @ONLY)
  64. include_directories (${log4cplus_SOURCE_DIR}/include
  65. ${log4cplus_BINARY_DIR}/include
  66. )
  67. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
  68. if (LOG4CPLUS_BUILD_TESTING)
  69. enable_testing()
  70. endif (LOG4CPLUS_BUILD_TESTING)
  71. add_subdirectory (src)
  72. add_subdirectory (loggingserver)
  73. if (LOG4CPLUS_BUILD_TESTING)
  74. add_subdirectory (tests)
  75. endif (LOG4CPLUS_BUILD_TESTING)
  76. if (LOG4CPLUS_QT4)
  77. add_subdirectory (qt4debugappender)
  78. endif (LOG4CPLUS_QT4)
  79. include(Log4CPlusCPack.cmake)