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