barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8de264f597ba28dea688dfe318dc2e863cc76f4f

commit 8de264f597ba28dea688dfe318dc2e863cc76f4f
Author: Gustavo Sverzut Barbieri <[email protected]>
Date:   Thu Jan 26 11:13:01 2017 -0200

    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.
---
 cmake/config/common.cmake     |  2 --
 cmake/helpers/EflMacros.cmake | 11 ++++++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/cmake/config/common.cmake b/cmake/config/common.cmake
index 5056928..8a9ab47 100644
--- a/cmake/config/common.cmake
+++ b/cmake/config/common.cmake
@@ -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}\"")
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index 95decbe..c081ed1 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -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()

-- 


Reply via email to