From 65d8e47cbe815875426cde24f0fd5b459552df2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 18 Oct 2019 01:40:34 +0200 Subject: [PATCH] CMake: put all binaries into a single location. Shouldn't really make any difference, since pybind redirects all libraries anyway. But since other projects set this globally, we need to ensure this won't break anything. --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 190ce43..361f921 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,5 +40,36 @@ option(WITH_PYTHON "Build Python bindings" OFF) set(MAGNUMBINDINGS_CMAKE_MODULE_INSTALL_DIR share/cmake/MagnumBindings) +# A single output location. After a decade of saying NO THIS IS A NON-SOLUTION +# TO A NON-PROBLEM I reconsidered my views and enabled this, because: +# +# - On Windows (which don't have RPATH), this makes test execution finally +# possible without having to install all the stuff first (including the +# test-only libs, which is ugh). +# - With CMake subprojects, this makes it finally possible to use dynamic +# plugins directly from the build dir (again without installing anything) --- +# all plugins are put into the same place, so PluginManager has a single +# place to look into; and thanks to the dynamic libraries being there as +# well, this location can be automagically detected as relative to +# Directory::libraryLocation(). +# - Thanks to the $ being part of the output path, you are always sure +# you never accidentally mix up debug/release libraries when switching +# CMAKE_BUILD_TYPE in an existing build dir. +# +# The runtime location is set to CMAKE_BINARY_DIR and not PROJECT_BINARY_DIR +# because have one runtime location per CMake subproject would not solve much +# either. If the user already provides CMAKE_RUNTIME_OUTPUT_DIRECTORY (even +# empty), it's respected and nothing is being done. +# +# Explicitly using a generator expression to ensure plugins are added to e.g. +# /lib/magnum/importers/ instead of lib/magnum/importers/. Also +# adding this to cache, making superprojects pick that up implicitly as well, +# without forcing them to explicitly mirror this setting. +if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/bin CACHE PATH "" FORCE) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/lib CACHE PATH "" FORCE) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/$/lib CACHE PATH "" FORCE) +endif() + add_subdirectory(modules) add_subdirectory(src)