GAVD
GAVD

Reputation: 2134

Using Log4cxx in CMake

I try to use log4cxx in my project. I installed log4cxx:

sudo apt-get install liblog4cxx-dev

But, when I use CMakeLists.txt:

find_package(log4cxx)

It gives an error:

Could not find a package configuration file provided by "log4cxx" with any
of the following names:

log4cxxConfig.cmake
log4cxx-config.cmake

I think it is missing log4cxxConfig.cmake, but I don't know how to fix it.

Upvotes: 3

Views: 4313

Answers (3)

Patrick Callahan
Patrick Callahan

Reputation: 11

I found the same thing but was confused about what exactly to do with the file.

Here is additional detail with instructions for linux

cd myproject
mkdir -p CMakeModules
cd CMakeModules
wget https://raw.githubusercontent.com/Kitware/vibrant/master/CMake/FindLog4cxx.cmake

Then add these two lines to your top level CMakeLists.txt:

set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
find_package(Log4cxx REQUIRED)

Upvotes: 1

Achmad Fathoni
Achmad Fathoni

Reputation: 103

cmake_minimum_required(VERSION 3.0.0)    
project(test_log4cxx VERSION 0.1.0)         
                                                                                              
set(CMAKE_CXX_STANDARD 20)                                        
find_package(Log4cxx QUIET)                                                                                          
                                                                                       
add_executable(main main.cpp)                                                                                        
include_directories(${LOG4CXX_INCLUDE_DIRS})                                                                         
target_link_libraries(main ${LOG4CXX_LIBRARIES})  

Upvotes: 0

geipel
geipel

Reputation: 405

I think you need a file named "FindLog4cxx.cmake".

I found the following on at Kitware's GitHub repository: https://github.com/Kitware/vibrant/blob/master/CMake/FindLog4cxx.cmake

Upvotes: 1

Related Questions