1

I am trying to install Log4Cplus using Cmake.

First I downloaded log4cplus into a directory called 3rdparty

git clone https://github.com/log4cplus/log4cplus.git --recursive

Later in the common CMakeLists.txt I did the following

cmake_minimum_required (VERSION 3.4)
enable_testing()
include(USR_macros_and_functions.cmake)

project (unixpackages)
USR_init_project(unixpackages)
#other packages ...
add_subdirectory(3rdParty/log4cplus)
 #other packages ...
USR_add_build_repo_targets()

The problem is that when I try build I get the following error:

-- Installing: /home/compilation/UnixPackagesFareShopping/Output_API/Lib/libvalidator.so
-- Removed runtime path from "/home/compilation/UnixPackagesFareShopping/Output_API/Lib/libvalidator.so"
CMake Error at 3rdParty/log4cplus/src/cmake_install.cmake:36 (file):
  file cannot create directory: /usr/local/lib64/cmake/log4cplus.  Maybe need
  administrative privileges.
Call Stack (most recent call first):
  3rdParty/log4cplus/cmake_install.cmake:37 (include)
  cmake_install.cmake:48 (include)

I understand that I don't have the right to install it into /usr/local/lib64/cmake/ but the problem is that i don't know where I should change the path to point it to a directory where I have the rights to install it into.

I tried looking to see if i can find lib64 in all the configue and cmake files I only found this

./configure:  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
./configure:  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
./m4/libtool.m4:  # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,

I am new to cmake so sorry for the question

gringo
  • 373
  • 2
  • 4
  • 15
  • Do you mean during installation? Can you set the [CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) while configuration to a location where you have write privileges and try again? – compor Aug 29 '18 at 10:31
  • I added SET(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/3rdparty/log4cplus) in the CMakeLists.txt file of log4cplus but didn't work. I also found something like ./configure --prefix=/usr/local/httpd but I don't know iwhere should place it. I don't want to add anything in the command line – gringo Aug 29 '18 at 11:05
  • Variable `CMAKE_INSTALL_PREFIX` affects on a **whole project**, including the subprojects. (That is, you cannot install your files under `/usr/local`, but files related to log4cplus into non-system location). See [that question](https://stackoverflow.com/questions/6241922/how-to-use-cmake-install-prefix) about proper setting `CMAKE_INSTALL_PREFIX` variable. (Referenced question has answers both for command line and for `CMakeLists.txt` file's modifications.) – Tsyvarev Aug 29 '18 at 11:39
  • Annnd it workeddd Thank you @Tsyvarev i did the following: set (CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/3rdParty/log4cplusclea CACHE PATH "Cmake prefix" FORCE) – gringo Aug 29 '18 at 11:57

1 Answers1

1

As commented, you can adjust the installation location using CMake, just use the CMAKE_INSTALL_PREFIX variable (see answers to this question). You can set this variable to somewhere you have access to, so the software is eventually installed in that location instead.

You can set the CMAKE_INSTALL_PREFIX variable on the command line when calling cmake, or in the CMake file itself before any calls to project, as you have done:

set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/3rdParty/log4cplusclea)
Kevin
  • 16,549
  • 8
  • 60
  • 74