mirror of
https://github.com/rui314/mold.git
synced 2024-09-11 21:17:28 +03:00
Work around CMake CMP0077 warning
As documented by CMake [^1], prior to CMake 3.13, entries set by `option()` can override a non-cached old value. The `CMakeLists.txt` in the bundled mimalloc specifies a minimum CMake version of 3.0, so that old behaviour is expected. That means no matter whatever value of `MI_BUILD_STATIC` we set in `mold_add_mimalloc` does not really take effect (this can be seen by adding some debug messages). That didn't trouble us because it's on by default anyway. While the documented solution is to set `CMAKE_POLICY_DEFAULT_CMP0077` to `NEW`, we could actually also work around this by making them cache variables. This is fine and valid because their values are not meant to be changed anyway. (And this workaround is already being used in `mold_add_tbb`, so by doing this, we are also eliminating some inconcistency.) Fixes #874. [^1]: See `cmake --help-policy CMP0077` or https://cmake.org/cmake/help/latest/policy/CMP0077.html Signed-off-by: Zhong Ruoyu <zhongruoyu@outlook.com>
This commit is contained in:
parent
988241975f
commit
89ebf2179c
@ -159,8 +159,8 @@ if(MOLD_USE_MIMALLOC)
|
||||
target_compile_definitions(mold PRIVATE USE_SYSTEM_MIMALLOC)
|
||||
else()
|
||||
function(mold_add_mimalloc)
|
||||
set(MI_BUILD_STATIC ON)
|
||||
option(MI_BUILD_TESTS "Build test executables" OFF)
|
||||
set(MI_BUILD_STATIC ON CACHE INTERNAL "")
|
||||
set(MI_BUILD_TESTS OFF CACHE INTERNAL "")
|
||||
add_subdirectory(third-party/mimalloc EXCLUDE_FROM_ALL)
|
||||
target_compile_definitions(mimalloc-static PRIVATE MI_USE_ENVIRON=0)
|
||||
target_link_libraries(mold PRIVATE mimalloc-static)
|
||||
|
Loading…
Reference in New Issue
Block a user