1

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.

GAVD
  • 1,977
  • 3
  • 22
  • 40

3 Answers3

1

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

geipel
  • 395
  • 1
  • 3
  • 9
0

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)'''
0
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})