mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
CMake: Don't shadow the cache entry ENABLE_THREADS with a normal variable.
Using set(ENABLE_THREADS "posix") is confusing because it sets a new normal variable and leaves the cache entry with the same name unchanged. The intent wasn't to change the cache entry so this switches to a different variable name.
This commit is contained in:
parent
fa1609eb93
commit
91c435cf1c
1 changed files with 7 additions and 3 deletions
|
@ -351,6 +351,11 @@ set_property(CACHE ENABLE_THREADS
|
||||||
# compiler supporting attribute __constructor__.
|
# compiler supporting attribute __constructor__.
|
||||||
set(USE_WIN95_THREADS OFF)
|
set(USE_WIN95_THREADS OFF)
|
||||||
|
|
||||||
|
# This is a flag variable set when posix threads (pthreads) are used.
|
||||||
|
# It's needed when creating liblzma-config.cmake where dependency on
|
||||||
|
# Threads::Threads is only needed with pthreads.
|
||||||
|
set(USE_POSIX_THREADS OFF)
|
||||||
|
|
||||||
if(NOT ENABLE_THREADS IN_LIST SUPPORTED_THREADING_METHODS)
|
if(NOT ENABLE_THREADS IN_LIST SUPPORTED_THREADING_METHODS)
|
||||||
message(FATAL_ERROR "'${ENABLE_THREADS}' is not a supported "
|
message(FATAL_ERROR "'${ENABLE_THREADS}' is not a supported "
|
||||||
"threading method")
|
"threading method")
|
||||||
|
@ -380,11 +385,10 @@ if(ENABLE_THREADS)
|
||||||
endif()
|
endif()
|
||||||
elseif(CMAKE_USE_PTHREADS_INIT)
|
elseif(CMAKE_USE_PTHREADS_INIT)
|
||||||
if(ENABLE_THREADS STREQUAL "posix" OR ENABLE_THREADS STREQUAL "ON")
|
if(ENABLE_THREADS STREQUAL "posix" OR ENABLE_THREADS STREQUAL "ON")
|
||||||
# Overwrite ENABLE_THREADS in case it was set to "ON".
|
|
||||||
# The threading library only needs to be explicitly linked
|
# The threading library only needs to be explicitly linked
|
||||||
# for posix threads, so this is needed for creating
|
# for posix threads, so this is needed for creating
|
||||||
# liblzma-config.cmake later.
|
# liblzma-config.cmake later.
|
||||||
set(ENABLE_THREADS "posix")
|
set(USE_POSIX_THREADS ON)
|
||||||
|
|
||||||
target_link_libraries(liblzma Threads::Threads)
|
target_link_libraries(liblzma Threads::Threads)
|
||||||
add_compile_definitions(MYTHREAD_POSIX)
|
add_compile_definitions(MYTHREAD_POSIX)
|
||||||
|
@ -951,7 +955,7 @@ if(NOT TARGET LibLZMA::LibLZMA)
|
||||||
endif()
|
endif()
|
||||||
")
|
")
|
||||||
|
|
||||||
if(ENABLE_THREADS STREQUAL "posix")
|
if(USE_POSIX_THREADS)
|
||||||
set(LZMA_CONFIG_CONTENTS
|
set(LZMA_CONFIG_CONTENTS
|
||||||
"include(CMakeFindDependencyMacro)
|
"include(CMakeFindDependencyMacro)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
|
|
Loading…
Reference in a new issue