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.

141 lines
4.5 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. get_filename_component(TOOL_CHAIN_FILE_NAME "${CMAKE_TOOLCHAIN_FILE}" NAME_WE)
  5. if("${TOOL_CHAIN_FILE_NAME}" MATCHES "android.toolchain")
  6. # Android: set output folder to ${CMAKE_BINARY_DIR}
  7. set (LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_BINARY_DIR} CACHE PATH
  8. "root for library output, set this to change where Android libs are compiled to")
  9. endif()
  10. endif ()
  11. # Remove when CMake >= 2.8.4 is required
  12. set (CMAKE_LEGACY_CYGWIN_WIN32 0)
  13. project (log4cplus)
  14. cmake_minimum_required (VERSION 2.8.4)
  15. enable_language (CXX)
  16. include(GNUInstallDirs)
  17. include (Log4CPlusUtils.cmake)
  18. log4cplus_get_version ("${PROJECT_SOURCE_DIR}/include"
  19. log4cplus_version_major log4cplus_version_minor log4cplus_version_patch)
  20. message("-- Generating build for Log4cplus version ${log4cplus_version_major}.${log4cplus_version_minor}.${log4cplus_version_patch}")
  21. set (log4cplus_soversion 9)
  22. set (log4cplus_postfix "")
  23. option(LOG4CPLUS_BUILD_TESTING "Build the test suite." ON)
  24. option(LOG4CPLUS_BUILD_LOGGINGSERVER "Build the logging server." ON)
  25. option(LOG4CPLUS_DEFINE_INSTALL_TARGET "Whether the install target should be generated." OFF)
  26. if(NOT LOG4CPLUS_SINGLE_THREADED)
  27. find_package (Threads)
  28. message (STATUS "Threads: ${CMAKE_THREAD_LIBS_INIT}")
  29. endif(NOT LOG4CPLUS_SINGLE_THREADED)
  30. set(BUILD_SHARED_LIBS TRUE CACHE BOOL "If TRUE, log4cplus is built as a shared library, otherwise as a static library")
  31. if (WIN32)
  32. set (UNICODE_DEFAULT ON)
  33. else (WIN32)
  34. set (UNICODE_DEFAULT OFF)
  35. endif (WIN32)
  36. if (MSVC)
  37. set (LOG4CPLUS_WORKING_LOCALE_DEFAULT ON)
  38. else (MSVC)
  39. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  40. set (LOG4CPLUS_WORKING_LOCALE_DEFAULT OFF)
  41. endif (MSVC)
  42. option(LOG4CPLUS_WORKING_LOCALE "Define for compilers/standard libraries that support more than just the C locale."
  43. ${LOG4CPLUS_WORKING_LOCALE_DEFAULT})
  44. option(LOG4CPLUS_WORKING_C_LOCALE
  45. "Define for compilers/standard libraries that have working C locale."
  46. OFF)
  47. option (LOG4CPLUS_QT4 "Build with Qt4DebugAppender" OFF)
  48. option(UNICODE "Build with tchar = wchar_t" ${UNICODE_DEFAULT})
  49. option(WITH_ICONV "Use iconv() for char->wchar_t conversion."
  50. OFF)
  51. option(ENABLE_SYMBOLS_VISIBILITY
  52. "Enable compiler and platform specific options for symbols visibility"
  53. ON)
  54. set(_WIN32_WINNT 0x0500 CACHE STRING "Define Windows API version to use.")
  55. if (NOT ${BUILD_SHARED_LIBS})
  56. # set S-prefix for static build
  57. set (log4cplus_postfix "${log4cplus_postfix}S")
  58. endif()
  59. if (UNICODE AND (DEFINED LOG4CPLUS_USE_UNICODE AND LOG4CPLUS_USE_UNICODE))
  60. set (log4cplus_postfix "${log4cplus_postfix}U")
  61. message(STATUS "Log4CPlus - Using Unicode: YES")
  62. else()
  63. message(STATUS "Log4CPlus - Using Unicode: NO")
  64. set(UNICODE OFF)
  65. endif()
  66. if (WITH_ICONV)
  67. set(LOG4CPLUS_WITH_ICONV 1)
  68. endif ()
  69. set (log4cplus "log4cplus${log4cplus_postfix}")
  70. if(LOG4CPLUS_CONFIGURE_CHECKS_PATH)
  71. get_filename_component(LOG4CPLUS_CONFIGURE_CHECKS_PATH "${LOG4CPLUS_CONFIGURE_CHECKS_PATH}" ABSOLUTE)
  72. endif()
  73. if(LOG4CPLUS_CONFIGURE_CHECKS_PATH AND EXISTS ${LOG4CPLUS_CONFIGURE_CHECKS_PATH})
  74. message(STATUS "Custom ConfigureChecks script found: ${LOG4CPLUS_CONFIGURE_CHECKS_PATH}")
  75. else()
  76. set(LOG4CPLUS_CONFIGURE_CHECKS_PATH "ConfigureChecks.cmake")
  77. endif()
  78. include(${LOG4CPLUS_CONFIGURE_CHECKS_PATH})
  79. # Prepare defines.hxx.cmake from defines.hxx.in by doing a bit of
  80. # string manipulation.
  81. file(READ include/log4cplus/config/defines.hxx.in FILE_BUFFER)
  82. string(REGEX REPLACE "#undef[^a-zA-Z0-9_]+([a-zA-Z0-9_]+)"
  83. "#cmakedefine \\1 @\\1@" FILE_BUFFER "${FILE_BUFFER}")
  84. set(DEFINES_HXX_CMAKE
  85. ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx.cmake)
  86. set(DEFINES_HXX ${log4cplus_BINARY_DIR}/include/log4cplus/config/defines.hxx)
  87. file(WRITE ${DEFINES_HXX_CMAKE} ${FILE_BUFFER})
  88. configure_file(${DEFINES_HXX_CMAKE} ${DEFINES_HXX} @ONLY)
  89. include_directories (${log4cplus_SOURCE_DIR}/include
  90. ${log4cplus_BINARY_DIR}/include
  91. )
  92. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
  93. if (LOG4CPLUS_BUILD_TESTING)
  94. enable_testing()
  95. endif (LOG4CPLUS_BUILD_TESTING)
  96. add_subdirectory (src)
  97. if (LOG4CPLUS_BUILD_LOGGINGSERVER)
  98. add_subdirectory (loggingserver)
  99. endif (LOG4CPLUS_BUILD_LOGGINGSERVER)
  100. if (LOG4CPLUS_BUILD_TESTING)
  101. add_subdirectory (tests)
  102. endif (LOG4CPLUS_BUILD_TESTING)
  103. if (LOG4CPLUS_QT4)
  104. add_subdirectory (qt4debugappender)
  105. endif (LOG4CPLUS_QT4)
  106. if (LOG4CPLUS_DEFINE_INSTALL_TARGET)
  107. include(Log4CPlusCPack.cmake)
  108. endif()