cmake: Find threads dep early as it may be needed for later checks

This commit is contained in:
James Le Cuirot 2023-09-10 13:07:49 +01:00
parent b7d56ef7f1
commit 8617d8aa10
No known key found for this signature in database
GPG Key ID: 1226415D00DD3137

View File

@ -99,6 +99,12 @@ set(PACKAGE_TARNAME "libxml2")
set(PACKAGE_URL "https://gitlab.gnome.org/GNOME/libxml2")
set(PACKAGE_VERSION ${VERSION})
if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
endif()
if (NOT MSVC)
check_c_source_compiles("
void __attribute__((destructor))
@ -395,9 +401,7 @@ if(LIBXML2_WITH_LZMA)
endif()
if(LIBXML2_WITH_THREADS)
find_package(Threads REQUIRED)
target_link_libraries(LibXml2 PRIVATE Threads::Threads)
set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
endif()
if(LIBXML2_WITH_ZLIB)