From 712e7d3de087dad03dd4a1129d8cadbc44f72c9e Mon Sep 17 00:00:00 2001 From: Yupeng Zhang Date: Mon, 10 May 2021 12:01:03 -0400 Subject: [PATCH] [CMake] Respect CMAKE_INSTALL_PREFIX at install time The standard way of cmake install to a destination folder is the following pattern: ```shell cd cmake cmake --build cmake --install --prefix ``` Right now, the `` folder passed in cmake --install command is ignored, and always installed into `C:/Program Files(x86)/...`, which is the default `CMAKE_INSTALL_PREFIX` value passed at the `cmake ` call. Thus, it is not possible to install the binaries into different folders without rerun the cmake/build process. The important thing here is, the cmake variable `CMAKE_INSTALL_PREFIX` is supposed to be passed at `cmake --install` time with the `--prefix` argument. In cmake file, `install` with relative path will use that prefix automaticlly. And it is the best practice to not include CMAKE_INSTALL_PREFIX in the `install(... DESTINATION )` argument: ``` In particular, there is no need to make paths absolute by prepending CMAKE_INSTALL_PREFIX; this prefix is used by default if the DESTINATION is a relative path. ``` referenced from: https://cmake.org/cmake/help/latest/command/install.html --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f708e75a..36cb7b2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,9 +208,9 @@ endif() # ----------------------------------------------------------------------------- if (MI_INSTALL_TOPLEVEL) - set(mi_install_dir "${CMAKE_INSTALL_PREFIX}") + set(mi_install_dir "") else() - set(mi_install_dir "${CMAKE_INSTALL_PREFIX}/lib/mimalloc-${mi_version}") + set(mi_install_dir "lib/mimalloc-${mi_version}") endif() if(MI_SECURE)