From 543952eb87f7b06a41dd001273a59a0dea728c39 Mon Sep 17 00:00:00 2001 From: Wander Lairson Costa Date: Tue, 20 Mar 2018 11:46:31 +0000 Subject: [PATCH] Include libxml2 and zlib as required libraries libxml2 is a required library, but we only find out that when the build fails to link against it, if it is not present. The same for zlib. We use find_library to find these two libraries and print nice fail messages if they are not found. --- CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a4f57171..979d771cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,6 +49,22 @@ option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead find_package(llvm) find_package(clang) +if(NOT MSVC) + find_library(LIBXML2 NAMES xml2 libxml2) + if(${LIBXML2} STREQUAL "LIBXML2-NOTFOUND") + message(FATAL_ERROR "Could not find libxml2") + else() + message("${LIBXML2} found") + endif() + + find_library(ZLIB NAMES z zlib libz) + if(${ZLIB} STREQUAL "ZLIB-NOTFOUND") + message(FATAL_ERROR "Could not find zlib") + else() + message("${ZLIB} found") + endif() +endif() + set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp") if(ZIG_FORCE_EXTERNAL_LLD) @@ -710,7 +726,7 @@ target_link_libraries(zig LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} ) if(NOT MSVC) - target_link_libraries(zig LINK_PUBLIC xml2) + target_link_libraries(zig LINK_PUBLIC ${LIBXML2}) endif() if(ZIG_DIA_GUIDS_LIB) target_link_libraries(zig LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})