From 6956f4aa1982b66b234026b46f7bb2dd44c67894 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 24 Jul 2021 11:06:40 -0400 Subject: [PATCH] cmake: use CMAKE_INSTALL_LIBDIR instead of hardcoding "lib", etc. These came from HaikuPorts, specifically this patchset: https://github.com/haikuports/haikuports/blob/462947dd4f285a885d8011cade7cd0f7151cfe74/media-libs/libsdl2/patches/libsdl2-2.0.14.patchset This is just the part that is _not_ Haiku-specific. I wanted this in a separate commit though, since I'm not really a CMake expert; if this causes problems and we need to bisect to it, we won't be confused about it being a Haiku issue when we get here. Fixes #4092. (and probably others.) --- CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e65d2cbd..ee7da4154 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2346,9 +2346,9 @@ if(NOT WINDOWS OR CYGWIN OR MINGW) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") - set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") - set(bindir "\${exec_prefix}/bin") - set(includedir "\${prefix}/include") + set(libdir "${CMAKE_INSTALL_LIBDIR}") + set(bindir "${CMAKE_INSTALL_BINDIR}") + set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") if(SDL_STATIC) set(ENABLE_STATIC_TRUE "") set(ENABLE_STATIC_FALSE "#") @@ -2538,7 +2538,7 @@ if(NOT WINDOWS_STORE) add_library(SDL2main STATIC ${SDLMAIN_SOURCES}) # alias target for in-tree builds add_library(SDL2::SDL2main ALIAS SDL2main) -target_include_directories(SDL2main PUBLIC "$" $ $) +target_include_directories(SDL2main PUBLIC "$" $ $) set(_INSTALL_LIBS "SDL2main") if (NOT ANDROID) set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}") @@ -2582,7 +2582,7 @@ if(SDL_SHARED) endif() set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS}) target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS}) - target_include_directories(SDL2 PUBLIC "$" $ $) + target_include_directories(SDL2 PUBLIC "$" $ $) if(ANDROID) target_include_directories(SDL2 PRIVATE ${ANDROID_NDK}/sources/android/cpufeatures) else() @@ -2656,15 +2656,15 @@ endif() ##### Installation targets ##### install(TARGETS ${_INSTALL_LIBS} EXPORT SDL2Targets - LIBRARY DESTINATION "lib${LIB_SUFFIX}" - ARCHIVE DESTINATION "lib${LIB_SUFFIX}" - RUNTIME DESTINATION bin) + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") ##### Export files ##### if (WINDOWS) set(PKG_PREFIX "cmake") else () - set(PKG_PREFIX "lib${LIB_SUFFIX}/cmake/SDL2") + set(PKG_PREFIX "${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}/cmake/SDL2") endif () include(CMakePackageConfigHelpers) @@ -2693,7 +2693,7 @@ foreach(_FNAME ${BIN_INCLUDE_FILES}) list(REMOVE_ITEM INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/${_INCNAME}) endforeach() list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES}) -install(FILES ${INCLUDE_FILES} DESTINATION include/SDL2) +install(FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2) string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE) if (UPPER_BUILD_TYPE MATCHES DEBUG) @@ -2711,7 +2711,7 @@ if(NOT (WINDOWS OR CYGWIN OR MINGW)) execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \"lib${SONAME}${SOPOSTFIX}${SOEXT}\" \"libSDL2${SOPOSTFIX}${SOEXT}\" WORKING_DIRECTORY \"${SDL2_BINARY_DIR}\")") - install(FILES ${SDL2_BINARY_DIR}/libSDL2${SOPOSTFIX}${SOEXT} DESTINATION "lib${LIB_SUFFIX}") + install(FILES ${SDL2_BINARY_DIR}/libSDL2${SOPOSTFIX}${SOEXT} DESTINATION "${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}") endif() endif() if(FREEBSD) @@ -2719,9 +2719,9 @@ if(NOT (WINDOWS OR CYGWIN OR MINGW)) install(FILES ${SDL2_BINARY_DIR}/sdl2.pc DESTINATION "libdata/pkgconfig") else() install(FILES ${SDL2_BINARY_DIR}/sdl2.pc - DESTINATION "lib${LIB_SUFFIX}/pkgconfig") + DESTINATION "${CMAKE_INSTALL_LIBDIR}${LIB_SUFFIX}/pkgconfig") endif() - install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION bin) + install(PROGRAMS ${SDL2_BINARY_DIR}/sdl2-config DESTINATION "${CMAKE_INSTALL_BINDIR}") # TODO: what about the .spec file? Is it only needed for RPM creation? install(FILES "${SDL2_SOURCE_DIR}/sdl2.m4" DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/aclocal") endif()