Skip to content

Commit

Permalink
Using a different library name should be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Aug 4, 2023
1 parent c0335ac commit c3ca1c4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
19 changes: 9 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include(CTest)

# Allow option based library naming.
# This is the default name.
set(LOG4CXX_LIB_NAME log4cxx)
set(LOG4CXX_LIB_NAME "log4cxx${LOG4CXX_LIBRARY_SUFFIX}")

# If you are including log4cxx from a higher-level CMake file(perhaps as a submodule?)
# CMAKE_SOURCE_DIR will refer to the first CMakeLists.txt. Since we need some files
Expand Down Expand Up @@ -74,7 +74,6 @@ endif()
option(LOG4CXX_QT_SUPPORT "Qt support/integration" OFF)
if(LOG4CXX_QT_SUPPORT)
find_package(Qt5 COMPONENTS Core REQUIRED)
set(LOG4CXX_LIB_NAME log4cxx-qt)
endif(LOG4CXX_QT_SUPPORT)

option(LOG4CXX_ENABLE_ODBC "Support logging via ODBC" OFF)
Expand Down Expand Up @@ -136,12 +135,12 @@ if(WIN32)
endif()
include(GNUInstallDirs)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src/main/include/log4cxx
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LOG4CXX_LIBRARY_SUFFIX}"
FILES_MATCHING PATTERN "*.h"
PATTERN "Private" EXCLUDE
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/main/include/log4cxx
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LOG4CXX_LIBRARY_SUFFIX}"
FILES_MATCHING PATTERN "*.h"
PATTERN "Private" EXCLUDE
)
Expand All @@ -150,7 +149,6 @@ install(TARGETS ${LOG4CXX_LIB_NAME} EXPORT log4cxxTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

IF(WIN32 AND BUILD_SHARED_LIBS AND LOG4CXX_INSTALL_PDB)
Expand All @@ -164,14 +162,15 @@ if(UNIX)
# Support for pkg-config in consuming projects
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libsuffix "${LOG4CXX_LIBRARY_SUFFIX}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}/${LOG4CXX_LIBRARY_SUFFIX}")
set(VERSION "${log4cxx_VERSION_MAJOR}.${log4cxx_VERSION_MINOR}.${log4cxx_VERSION_PATCH}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/liblog4cxx.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx.pc"
"${CMAKE_CURRENT_BINARY_DIR}/lib${LOG4CXX_LIB_NAME}.pc"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/liblog4cxx.pc"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LOG4CXX_LIB_NAME}.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif(UNIX)

Expand All @@ -180,7 +179,7 @@ endif(UNIX)
# target_link_libraries( myApplication PRIVATE log4cxx)
install(EXPORT log4cxxTargets
FILE log4cxxConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/log4cxx
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LOG4CXX_LIB_NAME}
)
# Support for find_package(log4cxx 0.11) in consuming CMake projects
include(CMakePackageConfigHelpers)
Expand All @@ -189,7 +188,7 @@ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/log4cxxConfigVersi
COMPATIBILITY SameMinorVersion
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/log4cxxConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/log4cxx
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LOG4CXX_LIB_NAME}
)

#
Expand Down
4 changes: 2 additions & 2 deletions liblog4cxx.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: log4cxx
Name: log4cxx@libsuffix@
Description: log4cxx C++ logging framework
Version: @VERSION@
Libs: -L${libdir} -llog4cxx
Libs: -L${libdir} -llog4cxx@libsuffix@
Cflags: -I${includedir}
Requires.private: apr-1 apr-util-1

1 change: 1 addition & 0 deletions src/site/doxy/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2347,6 +2347,7 @@ INCLUDE_FILE_PATTERNS =

PREDEFINED = LOG4CXX_WCHAR_T_API \
LOG4CXX_UNICHAR_API \
LOG4CXX_CFSTRING_API \
LOG4CXX_QSTRING_API

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
Expand Down
1 change: 1 addition & 0 deletions src/site/markdown/development/build-cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ $ cmake --build buildtrees/Log4cxx --target install --config Release
| -DAPR_STATIC=yes | Link to the APR static library. By default, the Log4cxx shared library is linked to the APR shared library. If BUILD_SHARED_LIBS=off, the static APR library is always used. |
|-DLOG4CXX_TEST_PROGRAM_PATH=path| An extra path to prepend to the PATH for test programs. Log4cxx requires zip, sed, and grep on the PATH in order for the tests to work properly. |
| -DPREFER_BOOST=on | Prefer the Boost version of dependent libraries over standard library |
|-DLOG4CXX_LIBRARY_SUFFIX=qt| Change the Log4cxx library name. Allows side by side installation when using non-standard options (a different ABI). |

## A note on C++ version and Boost

Expand Down

0 comments on commit c3ca1c4

Please sign in to comment.