### Integrate Log4Qt Shared into CMake Project Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Add this to your CMakeLists.txt to find, include, and link the Log4Qt shared library. Ensure Log4Qt is installed and discoverable by CMake. ```cmake find_package(log4qt REQUIRED HINTS "${QT_MKSPECS_DIR}/cmake/Log4Qt" NO_DEFAULT_PATHS) include_directories(${LOG4QT_INCLUDE_DIRS}) target_link_libraries(main ${QT_LIBRARIES} log4qt) ``` -------------------------------- ### Build Log4Qt Static on *NIX Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Use this command to build Log4Qt in static mode on *NIX systems. Ensure QT_USE_QTSQL and QT_USE_QTNETWORK are defined if SQL and network features are required. ```bash cmake -DQT_USE_QTSQL=TRUE -DQT_USE_QTNETWORK=TRUE -DMAKE_BUILD_TYPE=Release -DLOG4QT_BUILD_STATIC=True . make make install ``` -------------------------------- ### Build Log4Qt Static on Windows (MinGW) Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Use this command to build Log4Qt in static mode on Windows using MinGW Makefiles. Ensure QT_USE_QTSQL and QT_USE_QTNETWORK are defined if SQL and network features are required. ```bash cmake -DQT_USE_QTSQL=TRUE -DQT_USE_QTNETWORK=TRUE -DMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" -DLOG4QT_BUILD_STATIC=True . mingw32-make mingw32-make install ``` -------------------------------- ### Build Log4Qt Shared on *NIX Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Use this command to build Log4Qt in shared mode on *NIX systems. Ensure QT_USE_QTSQL and QT_USE_QTNETWORK are defined if SQL and network features are required. ```bash cmake -DQT_USE_QTSQL=TRUE -DQT_USE_QTNETWORK=TRUE -DMAKE_BUILD_TYPE=Release . make make install ``` -------------------------------- ### Build Log4Qt Shared on Windows (MinGW) Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Use this command to build Log4Qt in shared mode on Windows using MinGW Makefiles. Ensure QT_USE_QTSQL and QT_USE_QTNETWORK are defined if SQL and network features are required. ```bash cmake -DQT_USE_QTSQL=TRUE -DQT_USE_QTNETWORK=TRUE -DMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" . mingw32-make mingw32-make install ``` -------------------------------- ### Set Project Version Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Defines the major, minor, and release versions of the Log4Qt project and constructs the full version string. These variables are used for internal configuration and defining preprocessor macros. ```cmake set(LOG4QT_VERSION_MAJOR 1) set(LOG4QT_VERSION_MINOR 0) set(LOG4QT_VERSION_RELEASE 0) set(LOG4QT_VERSION "${LOG4QT_VERSION_MAJOR}.${LOG4QT_VERSION_MINOR}.${LOG4QT_VERSION_RELEASE}") set(VERSION ${LOG4QT_VERSION}) set(SOVERSION ${LOG4QT_VERSION}) ``` -------------------------------- ### Add Log4Qt Library Target Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Defines the Log4Qt library target, specifying whether it's static or shared, and lists all source files, headers, and generated moc files required for the build. ```cmake add_library(${PROJECT_NAME} ${LOG4QT_BUILD_CONFIGURATION} ${LOG4QT_SOURCES} ${LOG4QT_Q_SOURCES} ${LOG4QT_MOC_SOURCES} ${LOG4QT_HEADERS} ${LOG4QT_Q_HEADERS}) ``` -------------------------------- ### Define Version Macros Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Defines preprocessor macros for the Log4Qt version, both as a numerical representation and a string. These are useful for compile-time checks and information. ```cmake add_definitions(-DLOG4QT_VERSION=${LOG4QT_VERSION_MAJOR}*65536+${LOG4QT_VERSION_MINOR}*256+${LOG4QT_VERSION_RELEASE}) add_definitions(-DLOG4QT_VERSION_STR="${LOG4QT_VERSION}") ``` -------------------------------- ### Set Library Build Configuration Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Determines whether to build a static or shared library based on the LOG4QT_BUILD_STATIC variable. The result is stored in LOG4QT_BUILD_CONFIGURATION. ```cmake if (LOG4QT_BUILD_STATIC) set(LOG4QT_BUILD_CONFIGURATION STATIC) # BUILD SHARED LIBRARY else (LOG4QT_BUILD_STATIC) set(LOG4QT_BUILD_CONFIGURATION SHARED) endif (LOG4QT_BUILD_STATIC) ``` -------------------------------- ### Configure Static Build Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Ensures that the LOG4QT_BUILD_STATIC variable is defined. If not explicitly set, it defaults to FALSE, indicating a shared library build. ```cmake if (NOT DEFINED LOG4QT_BUILD_STATIC) set (LOG4QT_BUILD_STATIC FALSE) endif (NOT DEFINED LOG4QT_BUILD_STATIC) ``` -------------------------------- ### Integrate Log4Qt Static into CMake Project Source: https://github.com/smokku/log4qt/blob/master/Readme.txt Add this to your CMakeLists.txt to include Log4Qt's source directory and link the static library. This method is suitable for static linking. ```cmake add_subdirectory(../log4qt ${CMAKE_CURRENT_BINARY_DIR}/log4qt) include_directories(../log4qt/src) target_link_libraries(main ${QT_LIBRARIES} log4qt) ``` -------------------------------- ### Include Qt Configuration Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Sets a CMake variable to prevent the use of the QtGUI module and then includes the Qt configuration file. This is typically used when building libraries that do not require a graphical interface. ```cmake set(QT_DONT_USE_QTGUI TRUE) include(${QT_USE_FILE}) ``` -------------------------------- ### Include Source Directory Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Adds the 'src' directory to the include path for the project. This allows header files within 'src' to be included without specifying the full path. ```cmake include_directories(src) ``` -------------------------------- ### Qt Meta-Object Compilation Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Uses CMake's Qt4 support to process C++ files that use Qt's meta-object system (e.g., with Q_OBJECT macro) and to automatically handle moc (Meta-Object Compiler) for Qt source files. ```cmake qt4_wrap_cpp(LOG4QT_MOC_SOURCES ${LOG4QT_Q_HEADERS}) qt4_automoc(${LOG4QT_Q_SOURCES}) ``` -------------------------------- ### Conditional Compilation for Qt Modules Source: https://github.com/smokku/log4qt/blob/master/CMakeLists.txt Conditionally compiles specific appenders and layouts based on whether Qt SQL or Qt Network modules are enabled. This allows for modular inclusion of features. ```cmake if (QT_USE_QTSQL) message("With QT_USE_QTSQL DatabaseAppender, DatabaseLayout compiled") list(APPEND LOG4QT_Q_HEADERS src/databaseappender.h src/databaselayout.h) list(APPEND LOG4QT_SOURCES src/databaseappender.cpp src/databaselayout.cpp) endif (QT_USE_QTSQL) if (QT_USE_QTNETWORK) message("With QT_USE_QTNETWORK TelnetAppender compiled") list(APPEND LOG4QT_Q_HEADERS src/telnetappender.h ) list(APPEND LOG4QT_SOURCES src/telnetappender.cpp) endif (QT_USE_QTNETWORK) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.