From c720814e48a99370c3c1a2928bb82d9ce66c9f05 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 19 Dec 2024 16:15:54 -0800 Subject: [PATCH] respect custom cmake install path for bin/lib/include --- CMakeLists.txt | 4 ++-- bin/system_info/CMakeLists.txt | 2 -- cmake/AwsSharedLibSetup.cmake | 22 +++++++++------------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bdff043cc..2dbddad2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,7 +247,7 @@ foreach(HEADER_SRCPATH IN ITEMS ${AWS_COMMON_HEADERS} ${AWS_COMMON_OS_HEADERS} $ unset(HEADER_DSTDIR) - foreach(POTENTIAL_PREFIX IN ITEMS ${GENERATED_ROOT_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + foreach(POTENTIAL_PREFIX IN ITEMS "${GENERATED_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/include") string(LENGTH ${POTENTIAL_PREFIX} _prefixlen) string(SUBSTRING ${HEADER_DIR} 0 ${_prefixlen} _actual_prefix) if(${_actual_prefix} STREQUAL ${POTENTIAL_PREFIX}) @@ -261,7 +261,7 @@ foreach(HEADER_SRCPATH IN ITEMS ${AWS_COMMON_HEADERS} ${AWS_COMMON_OS_HEADERS} $ endif() install(FILES ${HEADER_SRCPATH} - DESTINATION ${HEADER_DSTDIR} + DESTINATION "${INCLUDE_DIRECTORY}/${HEADER_DSTDIR}" COMPONENT Development) endforeach() diff --git a/bin/system_info/CMakeLists.txt b/bin/system_info/CMakeLists.txt index cb4ca0081..79f0c0acd 100644 --- a/bin/system_info/CMakeLists.txt +++ b/bin/system_info/CMakeLists.txt @@ -1,7 +1,5 @@ project(print-sys-info C) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake") - file(GLOB SI_SRC "*.c" ) diff --git a/cmake/AwsSharedLibSetup.cmake b/cmake/AwsSharedLibSetup.cmake index 856b1c8a5..404a373ee 100644 --- a/cmake/AwsSharedLibSetup.cmake +++ b/cmake/AwsSharedLibSetup.cmake @@ -1,22 +1,18 @@ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: Apache-2.0. -set(LIBRARY_DIRECTORY lib) -set(RUNTIME_DIRECTORY bin) -# Set the default lib installation path on GNU systems with GNUInstallDirs -if (UNIX AND NOT APPLE) - include(GNUInstallDirs) - set(LIBRARY_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) - set(RUNTIME_DIRECTORY ${CMAKE_INSTALL_BINDIR}) +# NOTE: GNUInstallDirs is also fine for Windows and Mac. It sets reasonable defaults like "lib" and "bin" +include(GNUInstallDirs) +set(LIBRARY_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) +set(RUNTIME_DIRECTORY ${CMAKE_INSTALL_BINDIR}) +set(INCLUDE_DIRECTORY ${CMAKE_INSTALL_INCLUDEDIR}) - # this is the absolute dumbest thing in the world, but find_package won't work without it - # also I verified this is correctly NOT "lib64" when CMAKE_C_FLAGS includes "-m32" - if (${LIBRARY_DIRECTORY} STREQUAL "lib64") - set(FIND_LIBRARY_USE_LIB64_PATHS true) - endif() +# this is the absolute dumbest thing in the world, but find_package won't work without it +# also I verified this is correctly NOT "lib64" when CMAKE_C_FLAGS includes "-m32" +if (${LIBRARY_DIRECTORY} STREQUAL "lib64") + set(FIND_LIBRARY_USE_LIB64_PATHS true) endif() - function(aws_prepare_shared_lib_exports target) if (BUILD_SHARED_LIBS) install(TARGETS ${target}