cmake: do not set the install directories in the cache

When these variables are set in the cache, changing the
CMAKE_INSTALL_PREFIX does not change the directories that actually get
used. Instead, use them if the user provided them via -D, otherwise use
the default based on CMAKE_INSTALL_PREFIX.
This commit is contained in:
Ben Boeckel 2016-10-20 11:42:44 -04:00
parent 5089329162
commit 0692a54158
1 changed files with 15 additions and 5 deletions

View File

@ -8,11 +8,21 @@ set(VERSION "1.2.8")
option(ASM686 "Enable building i686 assembly implementation")
option(AMD64 "Enable building amd64 assembly implementation")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
if (NOT INSTALL_BIN_DIR)
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
endif ()
if (NOT INSTALL_LIB_DIR)
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
endif ()
if (NOT INSTALL_INC_DIR)
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include")
endif ()
if (NOT INSTALL_MAN_DIR)
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
endif ()
if (NOT INSTALL_PKGCONFIG_DIR)
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig")
endif ()
include(CheckTypeSize)
include(CheckFunctionExists)