From 4486efa01bf8177b06714eaa36ae45b2fe6d0a5b Mon Sep 17 00:00:00 2001 From: Pei-Hsuan Hung Date: Tue, 2 Jul 2019 16:29:21 +0800 Subject: [PATCH] Avoid system environment path in find_package If the project root directory lies in user's home directory, `find_package` will search the project directory instead of the installed path. For example, if one's project directory is /home/user1/mimalloc, `find_package` will first search the prefix `$PATH`, then search `CMAKE_INSTALL_PREFIX` if no file is found in previous path. If one clones the project in `${HOME}` and added `${HOME}/bin` to `${PATH}` (which is common), the error could happen. To avoid this, we could simply add NO_SYSTEM_ENVIONMENT_PATH to the end of `find_package`. --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dd453458..86dd5280 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,7 +13,7 @@ if (NOT CMAKE_BUILD_TYPE) endif() # Import mimalloc (if installed) -find_package(mimalloc 1.0 REQUIRED) +find_package(mimalloc 1.0 REQUIRED NO_SYSTEM_ENVIRONMENT_PATH) # Tests add_executable(static-override main-override.c)