We have a C++ library which provides a CMakeList.txt
file, and it leads with the following:
cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR)
project(cryptopp)
set(cryptopp_VERSION_MAJOR 5)
set(cryptopp_VERSION_MINOR 6)
set(cryptopp_VERSION_PATCH 5)
include(GNUInstallDirs)
...
According to the CMake manual at GNUInstallDirs
:
Provides install directory variables as defined for GNU software...
... INCLUDEDIR - C header files (include) OLDINCLUDEDIR - C header files for non-gcc (/usr/include) ...
Our policy is install into /usr/local
; and don't install into /usr
. Installing the library into /usr
on some platforms breaks the library because the compiler treats all headers in /usr/include
as C files, and not C++ header files. OpenBSD is one that breaks us, but it handles the library header files as expected when they are installed into /usr/local/include
.
I perform a lot of cross-platform testing, and I don't know of any Unix compatible distributions that fail to support software installations into /usr/local
. I know we are safe to install into /usr/local
when its available.
I visited CMake modules, but I don't see a choice for something other than GNUInstallDirs
. How do we specify something similar to include(LocalInstallDirs)
instead of include(GNUInstallDirs)
?