title: What's the ideal cmake installation directory structure for a relocatable multiple platform installation?
body: <p>CMake install takes destination dirs, often using GNUInstallDirs to load standard values for the destination names. For example:</p>
  
  <pre><code>include(GNUInstallDirs)
  install(TARGETS Foo
      EXPORT Foo
      INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
      RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  )
  </code></pre>
  
  <p>However it doesn't provide different paths built for different platforms, or architectures. I've been installing to a platform specific folder within my project via <code>CMAKE_INSTALL_PREFIX</code> like this:</p>
  
  <pre><code>CMAKE_INSTALL_PREFIX=dist/${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}
  </code></pre>
  
  <p>This has some problems though:</p>
  
  <ul>
  <li>It duplicates the includes which are the same across platforms.</li>
  <li>If I install the different platforms to the same root but change the lib dir, cmake wouldn't find the cmake config targets in lib/non/standard/path/cmake/FooConfig.cmake</li>
  <li>And Module mode searches also don't find the libraries properly, which is problematic when MODULE mode searches are done. This can happen if the library happens to also have a cmake module which requires every find_package to have to specify "CONFIG" which starts to get weird, especially when 3rd party libraries are told to consider this installation directory for a common dependency, and don't specify CONFIG in the find_package, because why would they?</li>
  </ul>
  
  <p>I'm looking for a structure that works with find_package module mode and config mode; something like this:</p>
  
  <pre><code>&lt;install_prefix&gt;/
    include/
      foo/
        foo.h
    lib/
      &lt;PLAT x ARCH x CONFIG&gt;/
        cmake/
          foo/
            FooConfig.cmake
        libFoo.a
  </code></pre>
  
  <p>Goal is:</p>
  
  <ul>
  <li>libs can be co-installed for different platforms, architectures and configs</li>
  <li>includes can be shared</li>
  <li>finding the includes should work in typical module mode searches</li>
  <li>should just work with vanilla find_package(Foo REQUIRED), but for the appropriate platform and arch.</li>
  </ul>
  
  <p>Considering I'd be installing mostly 3rd party libraries here, if this can be done by overriding the vars from GNUInstallDirs, it'd probably work for many libraries. The rest I guess would either have to be edited or I just give up and use separate installation dirs that include platform and arch.</p>