macros.cmake: Simplify SD install directories

The build system relied on overly complex logic already defined by the
GNUInstallDirs module [1], which is already included by the top-level
CMakeLists.txt.

[1]: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
This commit is contained in:
Xavier Del Campo Romero 2025-01-17 06:27:27 +01:00
parent ce1b5555cd
commit f845faad4a
Signed by: xavi
GPG key ID: 84FF3612A9BF43F2

View file

@ -68,71 +68,21 @@ ENDIF(WIN32)
SET(SD_TOOLS_EXECPREFIX "sd2-" CACHE STRING "Prefix for the tools executable names")
MARK_AS_ADVANCED(SD_TOOLS_EXECPREFIX)
# Determine the default value of the data, bin and lib (and man) folders.
IF(IN_SOURCETREE)
IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
SET(_DEFLIBDIR "lib")
ELSE()
SET(_DEFLIBDIR "lib64")
ENDIF()
IF(WIN32)
SET(SD_BINDIR bin CACHE PATH "Place where the executables should go")
SET(SD_LIBDIR ${_DEFLIBDIR} CACHE PATH "Place where the libraries should go")
SET(SD_INCLUDEDIR include CACHE PATH "Place where the include files should go")
ELSE(WIN32) #UNIX
SET(SD_BINDIR games CACHE PATH "Place where the executables should go")
SET(SD_LIBDIR ${_DEFLIBDIR}/games/speed-dreams-2 CACHE PATH "Place where the libraries should go")
SET(SD_INCLUDEDIR include/speed-dreams-2 CACHE PATH "Place where the include files should go")
SET(SD_MANDIR share/man CACHE PATH "Place where the manual pages should go")
ENDIF(WIN32)
MARK_AS_ADVANCED(SD_BINDIR)
MARK_AS_ADVANCED(SD_LIBDIR)
MARK_AS_ADVANCED(SD_INCLUDEDIR)
IF(UNIX)
MARK_AS_ADVANCED(SD_MANDIR)
ENDIF(UNIX)
ELSE(IN_SOURCETREE)
SET(SD_LIBDIR ${SD_LIBDIR_ABS})
SET(SD_BINDIR ${SD_BINDIR_ABS})
SET(SD_INCLUDEDIR ${SD_INCLUDEDIR_ABS})
IF(UNIX)
SET(SD_MANDIR ${SD_MANDIR_ABS})
ENDIF(UNIX)
ENDIF(IN_SOURCETREE)
IF(WIN32)
SET(SD_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH "Place where the executables should go")
ELSE()
SET(SD_BINDIR games CACHE PATH "Place where the executables should go")
ENDIF()
# Determine the aboslute paths of the data, bin and lib (and man) folders.
IF(IS_ABSOLUTE ${SD_LIBDIR})
GET_FILENAME_COMPONENT(SD_LIBDIR_ABS ${SD_LIBDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_LIBDIR})
GET_FILENAME_COMPONENT(SD_LIBDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_LIBDIR})
IF(IS_ABSOLUTE ${SD_BINDIR})
GET_FILENAME_COMPONENT(SD_BINDIR_ABS ${SD_BINDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_BINDIR})
GET_FILENAME_COMPONENT(SD_BINDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_BINDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_BINDIR})
IF(IS_ABSOLUTE ${SD_INCLUDEDIR})
GET_FILENAME_COMPONENT(SD_INCLUDEDIR_ABS ${SD_INCLUDEDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_INCLUDEDIR})
GET_FILENAME_COMPONENT(SD_INCLUDEDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_INCLUDEDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_INCLUDEDIR})
IF(UNIX)
IF(IS_ABSOLUTE ${SD_MANDIR})
GET_FILENAME_COMPONENT(SD_MANDIR_ABS ${SD_MANDIR} ABSOLUTE)
ELSE(IS_ABSOLUTE ${SD_MANDIR})
GET_FILENAME_COMPONENT(SD_MANDIR_ABS ${CMAKE_INSTALL_PREFIX}/${SD_MANDIR} ABSOLUTE)
ENDIF(IS_ABSOLUTE ${SD_MANDIR})
ENDIF(UNIX)
SET(SD_LIBDIR ${CMAKE_INSTALL_LIBDIR}/games/speed-dreams-2 CACHE PATH "Place where the libraries should go")
SET(SD_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/speed-dreams-2 CACHE PATH "Place where the include files should go")
SET(SD_MANDIR ${CMAKE_INSTALL_MANDIR} CACHE PATH "Place where the manual pages should go")
STRING(REGEX REPLACE "^(.*[^/])/*$" "\\1" SD_LOCALDIR_TMP ${SD_LOCALDIR})
SET(SD_LOCALDIR ${SD_LOCALDIR_TMP})
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
SET(CMAKE_INSTALL_RPATH "${SD_LIBDIR_ABS}/lib")
SET(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${SD_LIBDIR}/lib)
# Configuration options macros.
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/options.cmake)