From: =?utf-8?q?Timo_R=C3=B6hling?= <timo@gaussglocke.de>
Date: Sat, 5 Dec 2020 00:55:26 +0100
Subject: Install header with arch-specific data to arch-specific location

---
 CMakeLists.txt                                           |  3 ++-
 include/foonathan/memory/detail/container_node_sizes.hpp |  6 +++---
 src/CMakeLists.txt                                       | 10 +++++-----
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 624510a..c5fab35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,8 @@ set(CMAKE_DEBUG_POSTFIX "-dbg")
 if(UNIX OR VXWORKS)
     include(GNUInstallDirs)
 
-    set(FOONATHAN_MEMORY_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
+    set(FOONATHAN_MEMORY_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/foonathan_memory")
+    set(FOONATHAN_MEMORY_ARCH_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${HOST_TRIPLET}/foonathan_memory")
     set(FOONATHAN_MEMORY_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
     set(FOONATHAN_MEMORY_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
     set(FOONATHAN_MEMORY_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
diff --git a/include/foonathan/memory/detail/container_node_sizes.hpp b/include/foonathan/memory/detail/container_node_sizes.hpp
index d561a46..3814665 100644
--- a/include/foonathan/memory/detail/container_node_sizes.hpp
+++ b/include/foonathan/memory/detail/container_node_sizes.hpp
@@ -1,10 +1,10 @@
-// Copyright (C) 2015-2025 Jonathan Müller and foonathan/memory contributors
+// Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
 // SPDX-License-Identifier: Zlib
 
 #ifndef FOONATHAN_MEMORY_DETAIL_CONTAINER_NODE_SIZES_HPP_INCLUDED
 #define FOONATHAN_MEMORY_DETAIL_CONTAINER_NODE_SIZES_HPP_INCLUDED
 
-#include "align.hpp"
-#include "container_node_sizes_impl.hpp"
+#include <foonathan/memory/detail/align.hpp>
+#include <foonathan/memory/detail/container_node_sizes_impl.hpp>
 
 #endif //FOONATHAN_MEMORY_DETAIL_CONTAINER_NODE_SIZES_HPP_INCLUDED
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 653b7eb..08e1744 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -47,8 +47,7 @@ set(header
         ${header_path}/temporary_allocator.hpp
         ${header_path}/threading.hpp
         ${header_path}/tracking.hpp
-        ${header_path}/virtual_memory.hpp
-        ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp)
+        ${header_path}/virtual_memory.hpp)
 
 set(src
         detail/align.cpp
@@ -76,14 +75,15 @@ set(src
 configure_file("config.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/config_impl.hpp")
 
 # generate container_node_sizes.hpp if necessary
-if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp)
-    get_container_node_sizes(${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp)
+if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/foonathan/memory/detail/container_node_sizes_impl.hpp)
+    get_container_node_sizes(${CMAKE_CURRENT_BINARY_DIR}/foonathan/memory/detail/container_node_sizes_impl.hpp)
 endif()
 
 add_library(foonathan_memory ${detail_header} ${header} ${src})
 target_include_directories(foonathan_memory PUBLIC $<BUILD_INTERFACE:${FOONATHAN_MEMORY_SOURCE_DIR}/include/> # for client in subdirectory
                                                    $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> # for generated files in build mode
                                                    $<INSTALL_INTERFACE:${FOONATHAN_MEMORY_INC_INSTALL_DIR}> # for client in install mode
+                                                   $<INSTALL_INTERFACE:${FOONATHAN_MEMORY_ARCH_INC_INSTALL_DIR}> # for arch-specific generated headers
                                             PRIVATE ${header_path}) # for source files
 target_compile_definitions(foonathan_memory PUBLIC
                             FOONATHAN_MEMORY=1
@@ -128,7 +128,7 @@ write_basic_package_version_file(${version_file}
                                  COMPATIBILITY AnyNewerVersion)
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config_impl.hpp DESTINATION ${FOONATHAN_MEMORY_INC_INSTALL_DIR}/foonathan/memory/)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/container_node_sizes_impl.hpp DESTINATION ${FOONATHAN_MEMORY_INC_INSTALL_DIR}/foonathan/memory/detail)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/foonathan/memory/detail/container_node_sizes_impl.hpp DESTINATION ${FOONATHAN_MEMORY_ARCH_INC_INSTALL_DIR}/foonathan/memory/detail)
 install(FILES ${header}                                   DESTINATION ${FOONATHAN_MEMORY_INC_INSTALL_DIR}/foonathan/memory)
 install(FILES ${detail_header}                            DESTINATION ${FOONATHAN_MEMORY_INC_INSTALL_DIR}/foonathan/memory/detail)
 install(FILES ${version_file}                             DESTINATION ${FOONATHAN_MEMORY_CMAKE_CONFIG_INSTALL_DIR})
