Use find_package(FOO REQUIRED)

Using more cmake-way finding packages for shared system libraries
where it is possible.
This commit is contained in:
Azamat H. Hackimov 2016-03-26 14:26:22 +05:00
parent 7934c975ca
commit 75f908b45e

View File

@ -157,10 +157,7 @@ endif()
# zlib
if(USE_SHARED_ZLIB)
find_package(ZLIB)
if(NOT ZLIB_FOUND)
message(FATAL_ERROR "zlib not found")
endif()
find_package(ZLIB REQUIRED)
else()
set(ZLIB_LIBRARIES zlib)
set(ZLIB_INCLUDE_DIR ${ZLIB_DIR})
@ -171,10 +168,7 @@ include_directories(${ZLIB_INCLUDE_DIR})
# libpng
if(USE_SHARED_LIBPNG)
find_package(PNG)
if(NOT PNG_FOUND)
message(FATAL_ERROR "libpng not found")
endif()
find_package(PNG REQUIRED)
add_definitions(${PNG_DEFINITIONS})
else()
set(PNG_LIBRARIES libpng)
@ -222,8 +216,7 @@ include_directories(${PIXMAN_INCLUDE_DIR})
# freetype
if(USE_SHARED_FREETYPE)
find_library(FREETYPE_LIBRARY NAMES freetype)
find_path(FREETYPE_INCLUDE_DIR NAMES freetype.h)
find_package(Freetype REQUIRED)
else()
set(FREETYPE_LIBRARY freetype)
set(FREETYPE_INCLUDE_DIR ${FREETYPE_DIR}/include)
@ -232,9 +225,6 @@ include_directories(${FREETYPE_INCLUDE_DIR})
if(USE_SHARED_GIFLIB)
find_package(GIF REQUIRED)
if(NOT GIF_FOUND)
message(FATAL_ERROR "giflib not found")
endif()
else()
set(GIF_LIBRARIES giflib)
set(GIF_INCLUDE_DIR ${GIFLIB_DIR}/lib)
@ -242,10 +232,7 @@ endif()
include_directories(${GIF_INCLUDE_DIR})
if(USE_SHARED_JPEGLIB)
find_package(JPEG)
if(NOT JPEG_FOUND)
message(FATAL_ERROR "jpeg not found")
endif()
find_package(JPEG REQUIRED)
else()
set(JPEG_LIBRARIES jpeg)
set(JPEG_INCLUDE_DIR ${LIBJPEG_DIR})
@ -264,8 +251,7 @@ if(USE_ALLEG4_BACKEND)
endif()
if(USE_SHARED_CURL)
find_library(LIBCURL_LIBRARY NAMES curl)
find_path(LIBCURL_INCLUDE_DIR NAMES curl/curl.h)
find_package(CURL REQUIRED)
else()
set(LIBCURL_LIBRARY libcurl)
set(LIBCURL_INCLUDE_DIR ${CURL_DIR}/include)
@ -323,17 +309,11 @@ endif()
if(UNIX AND NOT APPLE AND NOT BEOS)
# Pthreads
find_package(Threads)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR "Unix port requires pthreads support.")
endif()
find_package(Threads REQUIRED)
list(APPEND PLATFORM_LIBS m ${CMAKE_THREAD_LIBS_INIT})
# X11
find_package(X11)
if(NOT X11_FOUND)
message(FATAL_ERROR "Unix port requires X11 (e.g. libx11-dev).")
endif()
find_package(X11 REQUIRED)
include_directories(SYSTEM ${X11_INCLUDE_DIR})
list(APPEND PLATFORM_LIBS ${X11_LIBRARIES})