abedra / libvault

A C++ library for Hashicorp Vault
MIT License
34 stars 25 forks source link

Installation directory is set as CMAKE_INSTALL_DIR, not CMAKE_INSTALL_LIBDIR #104

Closed markus456 closed 3 weeks ago

markus456 commented 2 years ago

Here's the relevant part of the CMakeLists.txt:

  install(TARGETS vault
      EXPORT libvaultTargets
      LIBRARY DESTINATION ${CMAKE_INSTALL_DIR}
      PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libvault)

I'm assuming that this is an oversight as the project uses GNUInstallDirs for other installation paths. Oddly enough, the behavior seems to be correct as long as CMAKE_INSTALL_PREFIX is not /usr:

LIBDIR

object code libraries (lib or lib64)

On Debian, this may be lib/<multiarch-tuple> when CMAKE_INSTALL_PREFIX is /usr.

Here's a small example CMakeLists.txt that shows that it expands to nothing:

cmake_minimum_required(VERSION 3.12)
project(vault VERSION 0.50.0 DESCRIPTION "Vault library for C++")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG --coverage)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

include(GNUInstallDirs)
message("CMAKE_INSTALL_DIR: ${CMAKE_INSTALL_DIR}")
message("CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")

This is what it generates:

-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_INSTALL_DIR: 
CMAKE_INSTALL_LIBDIR: lib
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/build

Am I misunderstanding how it works and the value of CMAKE_INSTALL_DIR is set somewhere else?