Merge pull request #254 from BtbN/cmake-fix

CMake fixes for iconv and Freetype finding
master
Jim 2014-08-21 08:57:19 -07:00
commit 83853a3e34
14 changed files with 101 additions and 69 deletions

View File

@ -11,6 +11,7 @@ else()
set(AppKit_LIBRARIES ${APPKIT_FRAMEWORK} CACHE STRING "AppKit framework")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(AppKit DEFAULT_MSG APPKIT_FRAMEWORK)
mark_as_advanced(APPKIT_FRAMEWORK)
endif()

View File

@ -13,7 +13,6 @@ if(CXX11_FLAGS)
endif()
include(CheckCXXSourceCompiles)
include(FindPackageHandleStandardArgs)
if(MSVC)
set(CXX11_FLAG_CANDIDATES
@ -64,5 +63,6 @@ endforeach(FLAG ${CXX11_FLAG_CANDIDATES})
set(CXX11_FLAGS "${CXX11_FLAGS_INTERNAL}" CACHE STRING "C++11 Flags")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CXX11 DEFAULT_MSG CXX11_FLAGS)
mark_as_advanced(CXX11_FLAGS)

View File

@ -1,16 +1,12 @@
# Once done these will be defined:
#
# LIBFREETYPE_FOUND
# LIBFREETYPE_INCLUDE_DIRS
# LIBFREETYPE_LIBRARIES
#
# For use in OBS:
#
# FREETYPE_INCLUDE_DIR
# FREETYPE_FOUND
# FREETYPE_INCLUDE_DIRS
# FREETYPE_LIBRARIES
#
if(LIBFREETYPE_INCLUDE_DIRS AND LIBFREETYPE_LIBRARIES)
set(LIBFREETYPE_FOUND TRUE)
if(FREETYPE_INCLUDE_DIRS AND FREETYPE_LIBRARIES)
set(FREETYPE_FOUND TRUE)
else()
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
@ -23,38 +19,63 @@ else()
set(_lib_suffix 32)
endif()
set(FREETYPE_PATH_ARCH FreetypePath${_lib_suffix})
find_path(FREETYPE_INCLUDE_DIR_ft2build
NAMES
ft2build.h
HINTS
${_FREETYPE_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV FreetypePath${_lib_suffix}
ENV FreetypePath
ENV FREETYPE_DIR
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include
PATH_SUFFIXES
include/freetype2 include)
if (NOT _FREETYPE_INCLUDE_DIRS STREQUAL "")
set (FREETYPE_INCLUDE_DIR ${_FREETYPE_INCLUDE_DIRS})
else()
find_path(FREETYPE_INCLUDE_DIR
NAMES ft2build.h
HINTS
${_FREETYPE_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV FreetypePath
ENV ${FREETYPE_PATH_ARCH}
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include)
endif()
find_path(FREETYPE_INCLUDE_DIR_freetype2
NAMES
freetype/config/ftheader.h
config/ftheader.h
HINTS
${_FREETYPE_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV FreetypePath${_lib_suffix}
ENV FreetypePath
ENV FREETYPE_DIR
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include
PATH_SUFFIXES
include/freetype2 include)
find_library(FREETYPE_LIB
NAMES ${_FREETYPE_LIBRARIES} freetype libfreetype
HINTS
${_FREETYPE_LIBRARY_DIRS}
"${FREETYPE_INCLUDE_DIR}/../lib"
"${FREETYPE_INCLUDE_DIR}/../lib${_lib_suffix}"
"${FREETYPE_INCLUDE_DIR}/../libs${_lib_suffix}"
"${FREETYPE_INCLUDE_DIR}/lib"
"${FREETYPE_INCLUDE_DIR}/lib${_lib_suffix}"
"${FREETYPE_INCLUDE_DIR_ft2build}/../lib"
"${FREETYPE_INCLUDE_DIR_ft2build}/../lib${_lib_suffix}"
"${FREETYPE_INCLUDE_DIR_ft2build}/../libs${_lib_suffix}"
"${FREETYPE_INCLUDE_DIR_ft2build}/lib"
"${FREETYPE_INCLUDE_DIR_ft2build}/lib${_lib_suffix}"
ENV FREETYPE_DIR
PATHS
/usr/lib /usr/local/lib /opt/local/lib /sw/lib)
/usr/lib /usr/local/lib /opt/local/lib /sw/lib
PATH_SUFFIXES
lib${_lib_suffix} lib)
set(LIBFREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR} CACHE PATH "freetype include dir")
set(LIBFREETYPE_LIBRARIES ${FREETYPE_LIB} CACHE STRING "freetype libraries")
if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2)
set(FREETYPE_INCLUDE_DIR "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}")
list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIR)
else()
unset(FREETYPE_INCLUDE_DIR)
endif()
find_package_handle_standard_args(Libfreetype DEFAULT_MSG FREETYPE_LIB FREETYPE_INCLUDE_DIR)
mark_as_advanced(FREETYPE_INCLUDE_DIR FREETYPE_LIB)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR} CACHE PATH "freetype include dirs")
set(FREETYPE_LIBRARIES ${FREETYPE_LIB} CACHE STRING "freetype libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Freetype DEFAULT_MSG FREETYPE_LIB FREETYPE_INCLUDE_DIR_ft2build FREETYPE_INCLUDE_DIR_freetype2)
mark_as_advanced(FREETYPE_INCLUDE_DIR FREETYPE_INCLUDE_DIR_ft2build FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_LIB)
endif()

View File

@ -1,16 +1,12 @@
# Once done these will be defined:
#
# LIBICONV_FOUND
# LIBICONV_INCLUDE_DIRS
# LIBICONV_LIBRARIES
#
# For use in OBS:
#
# ICONV_INCLUDE_DIR
# ICONV_FOUND
# ICONV_INCLUDE_DIRS
# ICONV_LIBRARIES
#
if(LIBICONV_INCLUDE_DIRS AND LIBICONV_LIBRARIES)
set(LIBICONV_FOUND TRUE)
if(ICONV_INCLUDE_DIRS AND ICONV_LIBRARIES)
set(ICONV_FOUND TRUE)
else()
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
@ -23,7 +19,7 @@ else()
set(_lib_suffix 32)
endif()
set(ICONV_PATH_ARCH IConvPath${_lib_suffix})
set(ICONV_PATH_ARCH IconvPath${_lib_suffix})
find_path(ICONV_INCLUDE_DIR
NAMES iconv.h
@ -31,7 +27,7 @@ else()
${_ICONV_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/additional_install_files/include"
"$ENV{obsAdditionalInstallFiles}/include"
ENV IConvPath
ENV IconvPath
ENV ${ICONV_PATH_ARCH}
PATHS
/usr/include /usr/local/include /opt/local/include /sw/include)
@ -40,17 +36,18 @@ else()
NAMES ${_ICONV_LIBRARIES} iconv libiconv
HINTS
${_ICONV_LIBRARY_DIRS}
"${ICONV_INCLUDE_DIR}/../lib"
"${ICONV_INCLUDE_DIR}/../lib${_lib_suffix}"
"${ICONV_INCLUDE_DIR}/../lib"
"${ICONV_INCLUDE_DIR}/../libs${_lib_suffix}"
"${ICONV_INCLUDE_DIR}/lib"
"${ICONV_INCLUDE_DIR}/lib${_lib_suffix}"
PATHS
/usr/lib /usr/local/lib /opt/local/lib /sw/lib)
set(LIBICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR} CACHE PATH "iconv include dir")
set(LIBICONV_LIBRARIES ${ICONV_LIB} CACHE STRING "iconv libraries")
set(ICONV_INCLUDE_DIRS ${ICONV_INCLUDE_DIR} CACHE PATH "iconv include dir")
set(ICONV_LIBRARIES ${ICONV_LIB} CACHE STRING "iconv libraries")
find_package_handle_standard_args(Libiconv DEFAULT_MSG ICONV_LIB ICONV_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_LIB ICONV_INCLUDE_DIR)
mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIB)
endif()

View File

@ -61,6 +61,7 @@ else()
set(JANSSON_LIBRARIES ${Jansson_LIB} CACHE STRING "Jansson libraries")
set(JANSSON_VERSION "${_JANSSON_VERSION_STRING}" CACHE STRING "Jansson version")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Jansson
FOUND_VAR JANSSON_FOUND
REQUIRED_VARS Jansson_LIB Jansson_INCLUDE_DIR

View File

@ -52,6 +52,7 @@ else()
set(LIBAVCODEC_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavcodec include dir")
set(LIBAVCODEC_LIBRARIES ${AVCODEC_LIB} CACHE STRING "Libavcodec libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libavcodec DEFAULT_MSG AVCODEC_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR AVCODEC_LIB)
endif()

View File

@ -48,6 +48,7 @@ else()
set(LIBAVFORMAT_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavformat include dir")
set(LIBAVFORMAT_LIBRARIES ${AVFORMAT_LIB} CACHE STRING "Libavformat libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libavformat DEFAULT_MSG AVFORMAT_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR AVFORMAT_LIB)
endif()

View File

@ -48,6 +48,7 @@ else()
set(LIBAVUTIL_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libavutil include dir")
set(LIBAVUTIL_LIBRARIES ${AVUTIL_LIB} CACHE STRING "Libavutil libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libavutil DEFAULT_MSG AVUTIL_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR AVUTIL_LIB)
endif()

View File

@ -54,6 +54,7 @@ else()
set(LIBFDK_INCLUDE_DIRS ${Libfdk_INCLUDE_DIR} CACHE PATH "Libfdk include dir")
set(LIBFDK_LIBRARIES ${Libfdk_LIB} CACHE STRING "Libfdk libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libfdk DEFAULT_MSG Libfdk_LIB Libfdk_INCLUDE_DIR)
mark_as_advanced(Libfdk_INCLUDE_DIR Libfdk_LIB)
endif()

View File

@ -48,6 +48,7 @@ else()
set(LIBSWRESAMPLE_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libswresample include dir")
set(LIBSWRESAMPLE_LIBRARIES ${SWRESAMPLE_LIB} CACHE STRING "Libswresample libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libswresample DEFAULT_MSG SWRESAMPLE_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR SWRESAMPLE_LIB)
endif()

View File

@ -48,6 +48,7 @@ else()
set(LIBSWSCALE_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIR} CACHE PATH "Libswscale include dir")
set(LIBSWSCALE_LIBRARIES ${SWSCALE_LIB} CACHE STRING "Libswscale libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libswscale DEFAULT_MSG SWSCALE_LIB FFMPEG_INCLUDE_DIR)
mark_as_advanced(FFMPEG_INCLUDE_DIR SWSCALE_LIB)
endif()

View File

@ -15,19 +15,24 @@ else()
find_path(V4L2_INCLUDE_DIR
NAMES libv4l2.h
HINTS ${_V4L2_INCLUDE_DIRS} /usr/include /usr/local/include
/opt/local/include)
HINTS
${_V4L2_INCLUDE_DIRS}
PATHS
/usr/include /usr/local/include /opt/local/include)
find_library(V4L2_LIB
NAMES v4l2
HINTS ${_V4L2_LIBRARY_DIRS} /usr/lib /usr/local/lib
/opt/local/lib)
HINTS
${_V4L2_LIBRARY_DIRS}
PATHS
/usr/lib /usr/local/lib /opt/local/lib)
set(LIBV4L2_INCLUDE_DIRS ${V4L2_INCLUDE_DIR}
CACHE PATH "v4l2 include dir")
set(LIBV4L2_LIBRARIES "${V4L2_LIB}"
CACHE STRING "v4l2 libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibV4L2 DEFAULT_MSG V4L2_LIB
V4L2_INCLUDE_DIR)
mark_as_advanced(V4L2_INCLUDE_DIR V4L2_LIB)

View File

@ -54,6 +54,7 @@ else()
set(LIBX264_INCLUDE_DIRS ${X264_INCLUDE_DIR} CACHE PATH "x264 include dir")
set(LIBX264_LIBRARIES ${X264_LIB} CACHE STRING "x264 libraries")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libx264 DEFAULT_MSG X264_LIB X264_INCLUDE_DIR)
mark_as_advanced(X264_INCLUDE_DIR X264_LIB)
endif()

View File

@ -1,15 +1,15 @@
project(text-freetype2)
find_package(Freetype QUIET)
if(NOT LIBFREETYPE_FOUND)
if(NOT FREETYPE_FOUND)
message(STATUS "Freetype library not found, Freetype text plugin disabled")
return()
endif()
if(APPLE)
find_package(iconv QUIET)
if(NOT LIBICONV_FOUND)
message(STATUS "IConv library not found, Freetype text plugin disabled")
find_package(Iconv QUIET)
if(NOT ICONV_FOUND)
message(STATUS "Iconv library not found, Freetype text plugin disabled")
return()
endif()
@ -20,11 +20,11 @@ if(APPLE)
find-font-iconv.c)
include_directories(${COCOA}
${LIBICONV_INCLUDE_DIRS})
${ICONV_INCLUDE_DIRS})
set(text-freetype2_PLATFORM_DEPS
${COCOA}
${LIBICONV_LIBRARIES})
${ICONV_LIBRARIES})
set_source_files_properties(find-font-cocoa.m
PROPERTIES LANGUAGE C)
@ -35,20 +35,19 @@ else()
message(STATUS "Linux-specific code has yet to be written for the text plugin, just needs load_os_font_list written.. which, er, may or may not be a pain. (My apologies in advance, please don't strangle me)")
return()
find_package(iconv QUIET)
if(NOT LIBICONV_FOUND)
message(STATUS "IConv library not found, Freetype text plugin disabled")
find_package(Iconv QUIET)
if(NOT ICONV_FOUND)
message(STATUS "Iconv library not found, Freetype text plugin disabled")
return()
endif()
set(text-freetype2_PLATFORM_SOURCES
find-font-iconv.c)
include_directories(${LIBICONV_INCLUDE_DIR})
include_directories(${ICONV_INCLUDE_DIR})
endif()
include_directories(${LIBFREETYPE_INCLUDE_DIRS})
add_definitions(${LIBFREETYPE_DEFINITIONS})
include_directories(${FREETYPE_INCLUDE_DIRS})
set(text-freetype2_SOURCES
find-font.h
@ -65,9 +64,10 @@ add_library(text-freetype2 MODULE
target_link_libraries(text-freetype2
libobs
${text-freetype2_PLATFORM_DEPS}
${LIBFREETYPE_LIBRARIES})
if(UNIX AND LIBICONV_FOUND)
target_link_libraries(text-freetype2 ${LIBICONV_LIBRARIES})
${FREETYPE_LIBRARIES})
if(UNIX AND ICONV_FOUND)
target_link_libraries(text-freetype2 ${ICONV_LIBRARIES})
endif()
install_obs_plugin_with_data(text-freetype2 data)