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.

109 lines
3.4 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 "Log4CPlus - 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 "${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 AND (DEFINED LOG4CPLUS_USE_UNICODE AND LOG4CPLUS_USE_UNICODE))
  47. set (log4cplus_postfix "${log4cplus_postfix}U")
  48. message(STATUS "Log4CPlus - Using Unicode: YES")
  49. else()
  50. message(STATUS "Log4CPlus - Using Unicode: NO")
  51. set(UNICODE OFF)
  52. endif()
  53. if (WITH_ICONV)
  54. set(LOG4CPLUS_WITH_ICONV 1)
  55. endif ()
  56. set (log4cplus "log4cplus${log4cplus_postfix}")
  57. include(ConfigureChecks.cmake)
  58. # Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of
  59. # string manipulation.
  60. file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER)
  61. string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)"
  62. "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}")
  63. set(DEFINES_HXX_CMAKE
  64. ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake)
  65. set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx)
  66. file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER})
  67. configure_file(${DEFINES_HXX_CMAKE} ${DEFINES_HXX} @ONLY)
  68. include_directories (${log4cplus_SOURCE_DIR}/include
  69. ${log4cplus_BINARY_DIR}/include
  70. )
  71. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
  72. if (LOG4CPLUS_BUILD_TESTING)
  73. enable_testing()
  74. endif (LOG4CPLUS_BUILD_TESTING)
  75. add_subdirectory (src)
  76. #add_subdirectory (loggingserver)
  77. if (LOG4CPLUS_BUILD_TESTING)
  78. add_subdirectory (tests)
  79. endif (LOG4CPLUS_BUILD_TESTING)
  80. if (LOG4CPLUS_QT4)
  81. add_subdirectory (qt4debugappender)
  82. endif (LOG4CPLUS_QT4)
  83. include(Log4CPlusCPack.cmake)