summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
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 /cmake/helpers/EflMacros.cmake
parentd9815a6837f1e06def0641da285863f87729683f (diff)
EflMacros: auto-handling of pkg-config files.
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake134
1 files changed, 134 insertions, 0 deletions
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()