cmake: pkg-config can have version and needs HAVE/ENABLED defines.

pkg-config names can be encoded with a version requirement, such as
zlib>=1.2.3, thus we need to remove that from the variable.

with autotools we used HAVE_XXX and ENABLED_XXX to instruct such
optional library was present, then define that just for the user
target by adding that to its CFLAGS.

This allows us to remove some defines that matches the name, only
leave those that translate from original pkg-config name, such as
libsystemd->systemd.
This commit is contained in:
Gustavo Sverzut Barbieri 2017-01-26 11:13:01 -02:00
parent 8cb493dd01
commit 8de264f597
2 changed files with 8 additions and 5 deletions

View File

@ -72,7 +72,6 @@ TYPE_CHECK(siginfo_t INCLUDE_FILES signal.h)
# TODO: move to a FindUnwind.cmake?
# or is pkg-config enough these days?
pkg_check_modules(UNWIND libunwind libunwind-generic)
CHECK_APPEND_DEFINE(HAVE_UNWIND ${UNWIND_FOUND})
CHECK_APPEND_DEFINE(EFL_BETA_API_SUPPORT 1)
if(CMAKE_THREAD_LIBS_INIT)
@ -81,7 +80,6 @@ endif()
CHECK_APPEND_DEFINE(EFL_HAVE_THREADS "${EFL_HAVE_THREADS}")
CHECK_APPEND_DEFINE(HAVE_SYSTEMD ${ENABLE_SYSTEMD})
CHECK_APPEND_DEFINE(HAVE_VALGRIND ${ENABLE_VALGRIND})
CHECK_APPEND_DEFINE(MODULE_ARCH "\"v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}\"")
CHECK_APPEND_DEFINE(SHARED_LIB_SUFFIX "\"${CMAKE_SHARED_LIBRARY_SUFFIX}\"")

View File

@ -420,13 +420,18 @@ function(EFL_PKG_CONFIG_EVAL_TO _var _name)
set(_missing "")
set(_missing_optional "")
set(_optional OFF)
set(_have_definitions "")
foreach(f ${ARGN})
if(${f} STREQUAL "OPTIONAL")
set(_optional ON)
else()
pkg_check_modules(PKG_CONFIG_DEP_${f} ${f})
if(PKG_CONFIG_DEP_${f}_FOUND)
string(REGEX REPLACE "[><=].*\$" "" v "${f}")
string(REGEX REPLACE "[^A-Za-z0-9]" "_" v "${v}")
string(TOUPPER "${v}" v)
pkg_check_modules(PKG_CONFIG_DEP_${v} ${f})
if(PKG_CONFIG_DEP_${v}_FOUND)
list(APPEND _found ${f})
list(APPEND _have_definitions "-DHAVE_${v}=1" "-DENABLE_${v}=1")
elseif(_optional)
list(APPEND _missing_optional ${f})
LIST_APPEND_GLOBAL(EFL_PKG_CONFIG_MISSING_OPTIONAL ${f})
@ -442,7 +447,7 @@ function(EFL_PKG_CONFIG_EVAL_TO _var _name)
if(_found)
pkg_check_modules(PKG_CONFIG_${_var} ${_found})
SET_GLOBAL(${_var}_CFLAGS "${PKG_CONFIG_${_var}_CFLAGS}")
SET_GLOBAL(${_var}_CFLAGS "${_have_definitions};${PKG_CONFIG_${_var}_CFLAGS}")
SET_GLOBAL(${_var}_LDFLAGS "${PKG_CONFIG_${_var}_LDFLAGS}")
endif()
else()