Skip to content

Commit

Permalink
respect custom cmake install path for bin/lib/include
Browse files Browse the repository at this point in the history
  • Loading branch information
graebm committed Dec 20, 2024
1 parent ecc7614 commit c720814
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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()

Expand Down
2 changes: 0 additions & 2 deletions bin/system_info/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
project(print-sys-info C)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake")

file(GLOB SI_SRC
"*.c"
)
Expand Down
22 changes: 9 additions & 13 deletions cmake/AwsSharedLibSetup.cmake
Original file line number Diff line number Diff line change
@@ -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}
Expand Down

0 comments on commit c720814

Please sign in to comment.