authorgravatar for wander.lairson@gmail.comWander Lairson Costa <wander.lairson@gmail.com> 2018-03-20 11:46:31+00:00
committergravatar for wander.lairson@gmail.comWander Lairson Costa <wander.lairson@gmail.com> 2018-03-20 18:15:02+00:00
log543952eb87f7b06a41dd001273a59a0dea728c39
tree387f3d5f43e26cc2ce024364d65bcc09fbe84ef3
parente966d375fb0c221a83b3262cedf46c895e8ab17d

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.

1 files changed, 17 insertions(+), 1 deletions(-)

CMakeLists.txt+17-1
...@@ -49,6 +49,22 @@ option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead...@@ -49,6 +49,22 @@ option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead
49find_package(llvm)49find_package(llvm)
50find_package(clang)50find_package(clang)
5151
52if(NOT MSVC)
53 find_library(LIBXML2 NAMES xml2 libxml2)
54 if(${LIBXML2} STREQUAL "LIBXML2-NOTFOUND")
55 message(FATAL_ERROR "Could not find libxml2")
56 else()
57 message("${LIBXML2} found")
58 endif()
59
60 find_library(ZLIB NAMES z zlib libz)
61 if(${ZLIB} STREQUAL "ZLIB-NOTFOUND")
62 message(FATAL_ERROR "Could not find zlib")
63 else()
64 message("${ZLIB} found")
65 endif()
66endif()
67
52set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp")68set(ZIG_CPP_LIB_DIR "${CMAKE_BINARY_DIR}/zig_cpp")
5369
54if(ZIG_FORCE_EXTERNAL_LLD)70if(ZIG_FORCE_EXTERNAL_LLD)
...@@ -710,7 +726,7 @@ target_link_libraries(zig LINK_PUBLIC...@@ -710,7 +726,7 @@ target_link_libraries(zig LINK_PUBLIC
710 ${CMAKE_THREAD_LIBS_INIT}726 ${CMAKE_THREAD_LIBS_INIT}
711)727)
712if(NOT MSVC)728if(NOT MSVC)
713 target_link_libraries(zig LINK_PUBLIC xml2)729 target_link_libraries(zig LINK_PUBLIC ${LIBXML2})
714endif()730endif()
715if(ZIG_DIA_GUIDS_LIB)731if(ZIG_DIA_GUIDS_LIB)
716 target_link_libraries(zig LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})732 target_link_libraries(zig LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})