summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-20 15:15:37 -0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-01-23 18:23:40 +0100
commit76e68de5d6f8a0a7843579612e01f8a3caf564a2 (patch)
treec3186a8528dc62bb259cded5ac4f3791fefd7632
parentd9815a6837f1e06def0641da285863f87729683f (diff)
EflMacros: auto-handling of pkg-config files.
-rw-r--r--cmake/config/eina.cmake8
-rw-r--r--cmake/helpers/EflMacros.cmake134
-rw-r--r--src/lib/eina/CMakeLists.txt14
3 files changed, 146 insertions, 10 deletions
diff --git a/cmake/config/eina.cmake b/cmake/config/eina.cmake
index 17bfcc1bc6..0e760587d6 100644
--- a/cmake/config/eina.cmake
+++ b/cmake/config/eina.cmake
@@ -1,6 +1,6 @@
1SET_GLOBAL(EINA_SAFETY_CHECKS 1) 1SET_GLOBAL(EINA_SAFETY_CHECKS 1)
2SET_GLOBAL(EINA_DEBUG_THREADS OFF) 2SET_GLOBAL(EINA_DEBUG_THREADS OFF)
3SET_GLOBAL(VALGRIND OFF) 3SET_GLOBAL(ENABLE_VALGRIND OFF)
4if("${BUILD_PROFILE}" STREQUAL "dev") 4if("${BUILD_PROFILE}" STREQUAL "dev")
5 SET_GLOBAL(EINA_STRINGSHARE_USAGE ON) 5 SET_GLOBAL(EINA_STRINGSHARE_USAGE ON)
6 SET_GLOBAL(CHECK_VALGRIND ON) 6 SET_GLOBAL(CHECK_VALGRIND ON)
@@ -10,14 +10,14 @@ elseif("${BUILD_PROFILE}" STREQUAL "debug")
10 SET_GLOBAL(EINA_DEFAULT_MEMPOOL ON) 10 SET_GLOBAL(EINA_DEFAULT_MEMPOOL ON)
11 SET_GLOBAL(EINA_DEBUG_MALLOC ON) 11 SET_GLOBAL(EINA_DEBUG_MALLOC ON)
12 SET_GLOBAL(EINA_DEBUG_THREADS ON) 12 SET_GLOBAL(EINA_DEBUG_THREADS ON)
13 SET_GLOBAL(VALGRIND ON) 13 SET_GLOBAL(ENABLE_VALGRIND ON)
14elseif("${BUILD_PROFILE}" STREQUAL "release") 14elseif("${BUILD_PROFILE}" STREQUAL "release")
15 SET_GLOBAL(EINA_LOG_LEVEL_MAXIMUM 3) 15 SET_GLOBAL(EINA_LOG_LEVEL_MAXIMUM 3)
16endif() 16endif()
17 17
18EFL_OPTION(EINA_MAGIC_DEBUG "magic debug of eina structure" ON) 18EFL_OPTION(EINA_MAGIC_DEBUG "magic debug of eina structure" ON)
19EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS}) 19EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS})
20EFL_OPTION(VALGRIND "valgrind support" ${VALGRIND}) 20EFL_OPTION(ENABLE_VALGRIND "valgrind support" ${ENABLE_VALGRIND})
21 21
22EFL_OPTION(EINA_BUILD_CHAINED "Build Eina's chained mempool" "ON" CHOICE ON;OFF;STATIC) 22EFL_OPTION(EINA_BUILD_CHAINED "Build Eina's chained mempool" "ON" CHOICE ON;OFF;STATIC)
23EFL_OPTION(EINA_BUILD_ONE_BIG "Build Eina's one-big mempool" "ON" CHOICE ON;OFF;STATIC) 23EFL_OPTION(EINA_BUILD_ONE_BIG "Build Eina's one-big mempool" "ON" CHOICE ON;OFF;STATIC)
@@ -63,7 +63,7 @@ CHECK_SYMBOL_EXISTS(bswap_64 byteswap.h EINA_HAVE_BSWAP64)
63 63
64CHECK_SYMBOL_EXISTS(clock_gettime time.h HAVE_CLOCK_GETTIME) 64CHECK_SYMBOL_EXISTS(clock_gettime time.h HAVE_CLOCK_GETTIME)
65 65
66if(VALGRIND) 66if(ENABLE_VALGRIND)
67 pkg_check_modules(VG REQUIRED valgrind) 67 pkg_check_modules(VG REQUIRED valgrind)
68 SET_GLOBAL(NVALGRIND OFF) 68 SET_GLOBAL(NVALGRIND OFF)
69else() 69else()
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index 1c2c752107..941ee8902c 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -106,6 +106,14 @@ function(EFL_OPTIONS_SUMMARY)
106 endforeach() 106 endforeach()
107 unset(_m) 107 unset(_m)
108 endforeach() 108 endforeach()
109
110 if(EFL_PKG_CONFIG_MISSING_OPTIONAL)
111 message(STATUS "The following pkg-config optional modules are missing:")
112 foreach(_m ${EFL_PKG_CONFIG_MISSING_OPTIONAL})
113 message(STATUS " ${_m}")
114 endforeach()
115 unset(_m)
116 endif()
109endfunction() 117endfunction()
110 118
111set(EFL_ALL_LIBS) 119set(EFL_ALL_LIBS)
@@ -137,6 +145,115 @@ function(EFL_FILES_TO_ABSOLUTE _var _srcdir _bindir)
137 set(${_var} "${_lst}" PARENT_SCOPE) 145 set(${_var} "${_lst}" PARENT_SCOPE)
138endfunction() 146endfunction()
139 147
148# EFL_PKG_CONFIG_EVAL_TO(Var Name [module1 ... moduleN])
149#
150# Evaluate the list of of pkg-config modules and assign to variable
151# Var. If it's missing, abort with a message saying ${Name} is missing
152# the list of modules.
153#
154# OPTIONAL keyword may be used to convert the remaining elements in optional
155# packages.
156function(EFL_PKG_CONFIG_EVAL_TO _var _name)
157 set(_found "")
158 set(_missing "")
159 set(_missing_optional "")
160 set(_optional OFF)
161 foreach(f ${ARGN})
162 if(${f} STREQUAL "OPTIONAL")
163 set(_optional ON)
164 else()
165 pkg_check_modules(PKG_CONFIG_DEP_${f} ${f})
166 if(PKG_CONFIG_DEP_${f}_FOUND)
167 list(APPEND _found ${f})
168 elseif(_optional)
169 list(APPEND _missing_optional ${f})
170 LIST_APPEND_GLOBAL(EFL_PKG_CONFIG_MISSING_OPTIONAL ${f})
171 else()
172 list(APPEND _missing ${f})
173 else()
174 endif()
175 endif()
176 endforeach()
177 if(NOT _missing)
178 SET_GLOBAL(${_var} "${_found}")
179 SET_GLOBAL(${_var}_MISSING "${_missing_optional}")
180 else()
181 message(FATAL_ERROR "${_name} missing required pkg-config modules: ${_missing}")
182 endif()
183endfunction()
184
185# EFL_PKG_CONFIG_EVAL(Name Private_List Public_List)
186#
187# Evaluates both lists and creates ${Name}_PKG_CONFIG_REQUIRES as well as
188# ${Name}_PKG_CONFIG_REQUIRES_PRIVATE with found elements.
189#
190# OPTIONAL keyword may be used to convert the remaining elements in optional
191# packages.
192function(EFL_PKG_CONFIG_EVAL _target _private _public)
193 EFL_PKG_CONFIG_EVAL_TO(${_target}_PKG_CONFIG_REQUIRES ${_target} ${_public})
194 EFL_PKG_CONFIG_EVAL_TO(${_target}_PKG_CONFIG_REQUIRES_PRIVATE ${_target} ${_private})
195
196 set(_lst ${${_target}_PKG_CONFIG_REQUIRES_MISSING})
197 foreach(_e ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_MISSING})
198 list(APPEND _lst ${_e})
199 endforeach()
200 if(_lst)
201 message(STATUS "${_target} missing optional pkg-config: ${_lst}")
202 endif()
203endfunction()
204
205function(EFL_PKG_CONFIG_LIB_WRITE)
206 set(_pkg_config_requires)
207 set(_pkg_config_requires_private)
208 set(_libraries)
209 set(_public_libraries)
210
211 foreach(_e ${${EFL_LIB_CURRENT}_PKG_CONFIG_REQUIRES})
212 set(_pkg_config_requires "${_pkg_config_requires} ${_e}")
213 endforeach()
214
215 foreach(_e ${${EFL_LIB_CURRENT}_PKG_CONFIG_REQUIRES_PRIVATE})
216 set(_pkg_config_requires_private "${_pkg_config_requires_private} ${_e}")
217 endforeach()
218
219 foreach(_e ${LIBRARIES})
220 set(_libraries "${_libraries} -l${_e}")
221 endforeach()
222
223 foreach(_e ${PUBLIC_LIBRARIES})
224 set(_public_libraries "${_public_libraries} -l${_e}")
225 endforeach()
226
227 if(NOT ${EFL_LIB_CURRENT} STREQUAL "efl")
228 set(_cflags " -I\${includedir}/${EFL_LIB_CURRENT}-${PROJECT_VERSION_MAJOR}")
229 endif()
230
231 # TODO: handle eolian needs
232
233 set(_contents
234"prefix=${CMAKE_INSTALL_PREFIX}
235exec_prefix=\${prefix}
236libdir=\${exec_prefix}/lib
237includedir=\${prefix}/include
238datarootdir=\${prefix}/share
239datadir=\${datarootdir}
240pkgdatadir=\${datadir}/${EFL_LIB_CURRENT}
241modules=\${libdir}/${EFL_LIB_CURRENT}/modules
242
243Name: ${EFL_LIB_CURRENT}
244Description: ${DESCRIPTION}
245Version: ${VERSION}
246Requires:${_pkg_config_requires}
247Requires.private:${_pkg_config_requires_private}
248Libs: -L\${libdir} -l${EFL_LIB_CURRENT}${_public_libraries}
249Libs.private:${_libraries}
250Cflags: -I\${includedir}/efl-${PROJECT_VERSION_MAJOR}${_cflags}
251")
252 file(WRITE "${CMAKE_BINARY_DIR}/lib/pkgconfig/${EFL_LIB_CURRENT}.pc" "${_contents}")
253 install(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/${EFL_LIB_CURRENT}.pc"
254 DESTINATION "lib/pkgconfig")
255endfunction()
256
140# _EFL_INCLUDE_OR_DETECT(Name Source_Dir) 257# _EFL_INCLUDE_OR_DETECT(Name Source_Dir)
141# 258#
142# Internal macro that will include(${Source_Dir}/CMakeLists.txt) if 259# Internal macro that will include(${Source_Dir}/CMakeLists.txt) if
@@ -258,6 +375,13 @@ endfunction()
258# 375#
259# adds a library ${Name} automatically setting object/target 376# adds a library ${Name} automatically setting object/target
260# properties based on script-modifiable variables: 377# properties based on script-modifiable variables:
378# - DESCRIPTION: results in ${Name}_DESCRIPTION and fills pkg-config files.
379# - PKG_CONFIG_REQUIRES: results in ${Name}_PKG_CONFIG_REQUIRES and
380# fills pkg-config files. Elements after 'OPTIONAL' keyword are
381# optional.
382# - PKG_CONFIG_REQUIRES_PRIVATE: results in
383# ${Name}_PKG_CONFIG_REQUIRES_PRIVATE and fills pkg-config
384# files. Elements after 'OPTIONAL' keyword are optional.
261# - INCLUDE_DIRECTORIES: results in target_include_directories 385# - INCLUDE_DIRECTORIES: results in target_include_directories
262# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM) 386# - SYSTEM_INCLUDE_DIRECTORIES: results in target_include_directories(SYSTEM)
263# - OUTPUT_NAME 387# - OUTPUT_NAME
@@ -322,6 +446,9 @@ function(EFL_LIB _target)
322 set(EFL_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/${_target}) 446 set(EFL_TESTS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/tests/${_target})
323 set(EFL_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/tests/${_target}) 447 set(EFL_TESTS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/tests/${_target})
324 448
449 set(DESCRIPTION)
450 set(PKG_CONFIG_REQUIRES)
451 set(PKG_CONFIG_REQUIRES_PRIVATE)
325 set(INCLUDE_DIRECTORIES) 452 set(INCLUDE_DIRECTORIES)
326 set(SYSTEM_INCLUDE_DIRECTORIES) 453 set(SYSTEM_INCLUDE_DIRECTORIES)
327 set(OUTPUT_NAME) 454 set(OUTPUT_NAME)
@@ -349,6 +476,8 @@ function(EFL_LIB _target)
349 EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR} 476 EFL_FILES_TO_ABSOLUTE(_obj_deps ${EFL_LIB_SOURCE_DIR} ${EFL_LIB_BINARY_DIR}
350 ${OBJECT_DEPENDS}) 477 ${OBJECT_DEPENDS})
351 478
479 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}")
480
352 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers}) 481 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers})
353 set_target_properties(${_target} PROPERTIES 482 set_target_properties(${_target} PROPERTIES
354 FRAMEWORK TRUE 483 FRAMEWORK TRUE
@@ -389,6 +518,8 @@ function(EFL_LIB _target)
389 SOVERSION ${SOVERSION}) 518 SOVERSION ${SOVERSION})
390 endif() 519 endif()
391 520
521 EFL_PKG_CONFIG_LIB_WRITE()
522
392 install(TARGETS ${_target} 523 install(TARGETS ${_target}
393 PUBLIC_HEADER DESTINATION include/${_target}-${PROJECT_VERSION_MAJOR} 524 PUBLIC_HEADER DESTINATION include/${_target}-${PROJECT_VERSION_MAJOR}
394 RUNTIME DESTINATION bin 525 RUNTIME DESTINATION bin
@@ -412,6 +543,9 @@ function(EFL_LIB _target)
412 unset(LIBRARIES) 543 unset(LIBRARIES)
413 unset(PUBLIC_LIBRARIES) 544 unset(PUBLIC_LIBRARIES)
414 unset(DEFINITIONS) 545 unset(DEFINITIONS)
546 unset(DESCRIPTION)
547 unset(PKG_CONFIG_REQUIRES)
548 unset(PKG_CONFIG_REQUIRES_PRIVATE)
415 549
416 _EFL_LIB_PROCESS_BINS_INTERNAL() 550 _EFL_LIB_PROCESS_BINS_INTERNAL()
417 _EFL_LIB_PROCESS_MODULES_INTERNAL() 551 _EFL_LIB_PROCESS_MODULES_INTERNAL()
diff --git a/src/lib/eina/CMakeLists.txt b/src/lib/eina/CMakeLists.txt
index b1981c801b..74dfed5cae 100644
--- a/src/lib/eina/CMakeLists.txt
+++ b/src/lib/eina/CMakeLists.txt
@@ -1,15 +1,17 @@
1 1set(DESCRIPTION "A Library that implements fast data types and miscellaneous tools")
2set(INCLUDE_DIRECTORIES 2set(PKG_CONFIG_REQUIRES_PRIVATE OPTIONAL libsystemd)
3 ${VG_INCLUDE_DIRS})
4
5set(LIBRARIES
6 ${VG_LIBRARIES})
7 3
8set(PUBLIC_LIBRARIES 4set(PUBLIC_LIBRARIES
9 m 5 m
10 dl 6 dl
11 pthread) 7 pthread)
12 8
9if(ENABLE_VALGRIND)
10 list(APPEND PKG_CONFIG_REQUIRES_PRIVATE valgrind)
11 list(APPEND INCLUDE_DIRECTORIES ${VG_INCLUDE_DIRS})
12 list(APPEND LIBRARIES ${VG_LIBRARIES})
13endif()
14
13set(PUBLIC_HEADERS 15set(PUBLIC_HEADERS
14 Eina.h 16 Eina.h
15 eina_accessor.h 17 eina_accessor.h