summaryrefslogtreecommitdiff
path: root/cmake/helpers/EflMacros.cmake
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-23 23:55:33 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-01-23 23:55:33 -0200
commitfa92926469881cdff7eda4627747fc964c2fa1a4 (patch)
tree9f2b5f016bef28ea01a1eabf05b127c899086eac /cmake/helpers/EflMacros.cmake
parentff0d88b7bae8fa14140210c5161beb944828bab5 (diff)
cmake: major rework of check and pkg-config dependencies.
make FUNC_CHECK(), TYPE_CHECK() and HEADER_CHECK() more general and they can be set to a scope, like "eina", then all symbols are prefixed with that. The scope is created with CHECK_INIT(), and EFL_HEADER_CHECKS_FINALIZE() will finish that. This makes it possible for cmake/config/eina.cmake + cmake/post/eina.cmake to add stuff to the generated file, better than hand edit the template. CHECK_APPEND_DEFINE(name val) is now the base to add symbols to the generated file in the current scope. Then convert cmake/config/eina.cmake to use that and match the autotools values (were a bit off). This exposed enabling valgrind was broken due incorrect pkg-config usage with cmake (it's not obvious), it was using just the libraries, while LDFLAGS are needed to get -L/usr/lib/valgrind. Then also convert to CFLAGS provided by pkg-config and make that automatic for PKG_CONFIG_REQUIRES and PKG_CONFIG_REQUIRES_PRIVATE. Also, eina-mempool modules use valgrind and must use that now that's propagating correctly.
Diffstat (limited to 'cmake/helpers/EflMacros.cmake')
-rw-r--r--cmake/helpers/EflMacros.cmake186
1 files changed, 156 insertions, 30 deletions
diff --git a/cmake/helpers/EflMacros.cmake b/cmake/helpers/EflMacros.cmake
index e320fb5f82..2f91e8a63a 100644
--- a/cmake/helpers/EflMacros.cmake
+++ b/cmake/helpers/EflMacros.cmake
@@ -132,7 +132,66 @@ function(EFL_FINALIZE)
132 add_custom_target(all-tests DEPENDS ${EFL_ALL_TESTS}) 132 add_custom_target(all-tests DEPENDS ${EFL_ALL_TESTS})
133endfunction() 133endfunction()
134 134
135unset(HEADER_FILE_CONTENT CACHE) 135set(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT CACHE INTERNAL "")
136unset(${VAR_HEADER_FILE_CONTENT} CACHE)
137unset(CHECK_SCOPE CACHE)
138unset(CHECK_SCOPE_UPPERCASE CACHE)
139
140# CHECK_INIT(scope)
141#
142# Initialize the scope for the following FUNC_CHECK, TYPE_CHECK,
143# HEADER_CHECK... calls.
144function(CHECK_INIT scope)
145 set(CHECK_SCOPE scope CACHE INTERNAL "Scope of current *_CHECK functions")
146 if(scope)
147 string(TOUPPER ${scope} scope_uc)
148 SET_GLOBAL(CHECK_SCOPE_UPPERCASE ${scope_uc})
149 set(_suffix "_${scope_uc}")
150 else()
151 set(_suffix "")
152 endif()
153 SET_GLOBAL(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT${_suffix})
154 SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "")
155endfunction()
156
157# CHECK_APPEND_DEFINE(name value)
158#
159# If value evaluates to true:
160# #define ${name} ${value}
161# otherwise:
162# /* #undef ${name} */
163#
164# NOTE: ${name} is not modified at all, if it must include
165# CHECK_SCOPE_UPPERCASE or CHECK_SCOPE, do it yourself.
166function(CHECK_APPEND_DEFINE name value)
167 SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}#ifdef ${name}\n#undef ${name}\n#endif\n")
168 if(value)
169 if(value STREQUAL ON OR value STREQUAL TRUE)
170 set(value 1)
171 endif()
172 SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}#define ${name} ${value}\n\n")
173 else()
174 SET_GLOBAL(${VAR_HEADER_FILE_CONTENT} "${${VAR_HEADER_FILE_CONTENT}}/* #undef ${name} */\n\n")
175 endif()
176endfunction()
177
178# CHECK_NAME_DEFAULT(name variable)
179#
180# Create the default name based on ${name}
181# and stores in ${variable}.
182#
183# This will automatically prepend ${CHECK_SCOPE_UPPERCASE} if it's
184# defined, will translate everything to uppercase and fix it to be a
185# valid C-symbol.
186function(CHECK_NAME_DEFAULT name var)
187 string(TOUPPER ${name} v)
188 string(REGEX REPLACE "[^a-zA-Z0-9]" "_" v "${v}")
189 string(REGEX REPLACE "_{2,}" "_" v "${v}")
190 if(CHECK_SCOPE_UPPERCASE)
191 set(v "${CHECK_SCOPE_UPPERCASE}_${v}")
192 endif()
193 set(${var} ${v} PARENT_SCOPE)
194endfunction()
136 195
137# HEADER_CHECK(header [NAME variable] [INCLUDE_FILES extra1.h .. extraN.h]) 196# HEADER_CHECK(header [NAME variable] [INCLUDE_FILES extra1.h .. extraN.h])
138# 197#
@@ -145,9 +204,7 @@ unset(HEADER_FILE_CONTENT CACHE)
145# 204#
146# To include extra files, then use INCLUDE_FILES keyword. 205# To include extra files, then use INCLUDE_FILES keyword.
147function(HEADER_CHECK header) 206function(HEADER_CHECK header)
148 string(TOUPPER HAVE_${header} var) 207 CHECK_NAME_DEFAULT(HAVE_${header} var)
149 string(REGEX REPLACE "[^a-zA-Z0-9]" "_" var "${var}")
150 string(REGEX REPLACE "_{2,}" "_" var "${var}")
151 208
152 cmake_parse_arguments(PARAMS "" "NAME" "INCLUDE_FILES" ${ARGN}) 209 cmake_parse_arguments(PARAMS "" "NAME" "INCLUDE_FILES" ${ARGN})
153 210
@@ -158,12 +215,7 @@ function(HEADER_CHECK header)
158 set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}") 215 set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}")
159 216
160 CHECK_INCLUDE_FILE(${header} ${var}) 217 CHECK_INCLUDE_FILE(${header} ${var})
161 218 CHECK_APPEND_DEFINE(${var} "${${var}}")
162 if(${${var}})
163 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n")
164 else()
165 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n")
166 endif()
167endfunction() 219endfunction()
168 220
169# FUNC_CHECK(func [NAME variable] 221# FUNC_CHECK(func [NAME variable]
@@ -184,8 +236,7 @@ endfunction()
184# 236#
185# To use C++ compiler, use CXX keyword 237# To use C++ compiler, use CXX keyword
186function(FUNC_CHECK func) 238function(FUNC_CHECK func)
187 string(TOUPPER HAVE_${func} var) 239 CHECK_NAME_DEFAULT(HAVE_${func} var)
188 string(REGEX REPLACE "_{2,}" "_" var "${var}")
189 240
190 cmake_parse_arguments(PARAMS "CXX" "NAME" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN}) 241 cmake_parse_arguments(PARAMS "CXX" "NAME" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN})
191 242
@@ -193,20 +244,20 @@ function(FUNC_CHECK func)
193 set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}") 244 set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}")
194 set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}") 245 set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}")
195 246
247 if(PARAMS_NAME)
248 set(var ${PARAMS_NAME})
249 endif()
250
196 if(PARAMS_CXX) 251 if(PARAMS_CXX)
197 check_cxx_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var}) 252 check_cxx_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var})
198 else() 253 else()
199 check_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var}) 254 check_symbol_exists(${func} "${PARAMS_INCLUDE_FILES}" ${var})
200 endif() 255 endif()
201 256
202 if(${${var}} ) 257 CHECK_APPEND_DEFINE(${var} "${${var}}")
203 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n")
204 else()
205 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n")
206 endif()
207endfunction() 258endfunction()
208 259
209# TYPE_CHECK(type [NAME variable] 260# TYPE_CHECK(type [NAME variable] [SIZEOF variable]
210# [INCLUDE_FILES file1.h ... fileN.h] 261# [INCLUDE_FILES file1.h ... fileN.h]
211# [LIBRARIES lib1 ... libN] 262# [LIBRARIES lib1 ... libN]
212# [DEFINITIONS -DA=1 .. -DN=123] 263# [DEFINITIONS -DA=1 .. -DN=123]
@@ -224,16 +275,24 @@ endfunction()
224# 275#
225# To use C++ compiler, use CXX keyword 276# To use C++ compiler, use CXX keyword
226function(TYPE_CHECK type) 277function(TYPE_CHECK type)
227 string(TOUPPER HAVE_${type} var) 278 CHECK_NAME_DEFAULT(HAVE_${type} var)
228 string(REGEX REPLACE "_{2,}" "_" var "${var}") 279 CHECK_NAME_DEFAULT(SIZEOF_${type} sizeof)
229 280
230 cmake_parse_arguments(PARAMS "CXX" "NAME" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN}) 281 cmake_parse_arguments(PARAMS "CXX" "NAME;SIZEOF" "INCLUDE_FILES;LIBRARIES;DEFINITIONS;FLAGS" ${ARGN})
231 282
232 set(CMAKE_REQUIRED_LIBRARIES "${PARAMS_LIBRARIES}") 283 set(CMAKE_REQUIRED_LIBRARIES "${PARAMS_LIBRARIES}")
233 set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}") 284 set(CMAKE_REQUIRED_DEFINITIONS "${PARAMS_DEFINITIONS}")
234 set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}") 285 set(CMAKE_REQUIRED_FLAGS "${PARAMS_FLAGS}")
235 set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}") 286 set(CMAKE_EXTRA_INCLUDE_FILES "${PARAMS_INCLUDE_FILES}")
236 287
288 if(PARAMS_NAME)
289 set(var ${PARAMS_NAME})
290 endif()
291
292 if(PARAMS_SIZEOF)
293 set(sizeof ${PARAMS_SIZEOF})
294 endif()
295
237 if(PARAMS_CXX) 296 if(PARAMS_CXX)
238 set(lang CXX) 297 set(lang CXX)
239 else() 298 else()
@@ -241,12 +300,8 @@ function(TYPE_CHECK type)
241 endif() 300 endif()
242 301
243 CHECK_TYPE_SIZE(${type} ${var} LANGUAGE ${lang}) 302 CHECK_TYPE_SIZE(${type} ${var} LANGUAGE ${lang})
244 303 CHECK_APPEND_DEFINE(${var} "${HAVE_${var}}")
245 if(HAVE_${var}) 304 CHECK_APPEND_DEFINE(${sizeof} "${${var}}")
246 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#define ${var} 1\n")
247 else()
248 SET_GLOBAL(HEADER_FILE_CONTENT "${HEADER_FILE_CONTENT}#undef ${var}\n")
249 endif()
250endfunction() 305endfunction()
251 306
252# EFL_HEADER_CHECKS_FINALIZE(file) 307# EFL_HEADER_CHECKS_FINALIZE(file)
@@ -254,7 +309,11 @@ endfunction()
254# Write the configuration gathered with HEADER_CHECK(), TYPE_CHECK() 309# Write the configuration gathered with HEADER_CHECK(), TYPE_CHECK()
255# and FUNC_CHECK() to the given file. 310# and FUNC_CHECK() to the given file.
256function(EFL_HEADER_CHECKS_FINALIZE file) 311function(EFL_HEADER_CHECKS_FINALIZE file)
257 file(WRITE ${file}.new ${HEADER_FILE_CONTENT}) 312 get_filename_component(filename ${file} NAME)
313 string(TOUPPER _${filename}_ file_sym)
314 string(REGEX REPLACE "[^a-zA-Z0-9]" "_" file_sym "${file_sym}")
315
316 file(WRITE ${file}.new "#ifndef ${file_sym}\n#define ${file_sym} 1\n\n${${VAR_HEADER_FILE_CONTENT}}\n#endif /* ${file_sym} */\n")
258 if (NOT EXISTS ${file}) 317 if (NOT EXISTS ${file})
259 file(RENAME ${file}.new ${file}) 318 file(RENAME ${file}.new ${file})
260 message(STATUS "${file} was generated.") 319 message(STATUS "${file} was generated.")
@@ -269,7 +328,10 @@ function(EFL_HEADER_CHECKS_FINALIZE file)
269 message(STATUS "${file} was updated.") 328 message(STATUS "${file} was updated.")
270 endif() 329 endif()
271 endif() 330 endif()
272 unset(HEADER_FILE_CONTENT CACHE) # allow to reuse with an empty contents 331 unset(${VAR_HEADER_FILE_CONTENT} CACHE) # allow to reuse with an empty contents
332 unset(CHECK_SCOPE CACHE)
333 unset(CHECK_SCOPE_UPPERCASE CACHE)
334 set(VAR_HEADER_FILE_CONTENT HEADER_FILE_CONTENT CACHE INTERNAL "")
273endfunction() 335endfunction()
274 336
275# EFL_FILES_TO_ABSOLUTE(Var Source_Dir Binary_Dir [file1 ... fileN]) 337# EFL_FILES_TO_ABSOLUTE(Var Source_Dir Binary_Dir [file1 ... fileN])
@@ -322,6 +384,12 @@ function(EFL_PKG_CONFIG_EVAL_TO _var _name)
322 if(NOT _missing) 384 if(NOT _missing)
323 SET_GLOBAL(${_var} "${_found}") 385 SET_GLOBAL(${_var} "${_found}")
324 SET_GLOBAL(${_var}_MISSING "${_missing_optional}") 386 SET_GLOBAL(${_var}_MISSING "${_missing_optional}")
387
388 if(_found)
389 pkg_check_modules(PKG_CONFIG_${_var} ${_found})
390 SET_GLOBAL(${_var}_CFLAGS "${PKG_CONFIG_${_var}_CFLAGS}")
391 SET_GLOBAL(${_var}_LDFLAGS "${PKG_CONFIG_${_var}_LDFLAGS}")
392 endif()
325 else() 393 else()
326 message(FATAL_ERROR "${_name} missing required pkg-config modules: ${_missing}") 394 message(FATAL_ERROR "${_name} missing required pkg-config modules: ${_missing}")
327 endif() 395 endif()
@@ -669,6 +737,13 @@ function(EFL_LIB _target)
669 737
670 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}") 738 EFL_PKG_CONFIG_EVAL(${_target} "${PKG_CONFIG_REQUIRES_PRIVATE}" "${PKG_CONFIG_REQUIRES}")
671 739
740 set(_link_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_LDFLAGS})
741 set(__compile_flags ${${_target}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS} ${${_target}_PKG_CONFIG_REQUIRES_CFLAGS} -DPACKAGE_DATA_DIR=\\"${CMAKE_INSTALL_FULL_DATADIR}/${_target}/\\")
742 set(_compile_flags)
743 # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/
744 foreach(_c ${__compile_flags})
745 set(_compile_flags "${_compile_flags} ${_c}")
746 endforeach()
672 747
673 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers}) 748 add_library(${_target} ${LIBRARY_TYPE} ${_sources} ${_headers})
674 set_target_properties(${_target} PROPERTIES 749 set_target_properties(${_target} PROPERTIES
@@ -677,7 +752,8 @@ function(EFL_LIB _target)
677 OBJECT_DEPENDS "${_obj_deps}" 752 OBJECT_DEPENDS "${_obj_deps}"
678 EFL_EO_PRIVATE "${_eo_files}" 753 EFL_EO_PRIVATE "${_eo_files}"
679 EFL_EO_PUBLIC "${_public_eo_files}" 754 EFL_EO_PUBLIC "${_public_eo_files}"
680 COMPILE_FLAGS -DPACKAGE_DATA_DIR=\\"${CMAKE_INSTALL_FULL_DATADIR}/${_target}/\\") 755 LINK_FLAGS "${_link_flags}"
756 COMPILE_FLAGS "${_compile_flags}")
681 757
682 if(DEPENDENCIES) 758 if(DEPENDENCIES)
683 add_dependencies(${_target} ${DEPENDENCIES}) 759 add_dependencies(${_target} ${DEPENDENCIES})
@@ -793,6 +869,8 @@ function(EFL_BIN _binname)
793 set(DEFINITIONS) 869 set(DEFINITIONS)
794 set(INSTALL ON) 870 set(INSTALL ON)
795 set(INSTALL_DIR bin) 871 set(INSTALL_DIR bin)
872 set(PKG_CONFIG_REQUIRES)
873 set(PKG_CONFIG_REQUIRES_PRIVATE)
796 874
797 if(_binname STREQUAL ${EFL_LIB_CURRENT}) 875 if(_binname STREQUAL ${EFL_LIB_CURRENT})
798 set(_binsrcdir "${EFL_BIN_SOURCE_DIR}") 876 set(_binsrcdir "${EFL_BIN_SOURCE_DIR}")
@@ -813,10 +891,15 @@ function(EFL_BIN _binname)
813 if(PUBLIC_HEADERS) 891 if(PUBLIC_HEADERS)
814 message(WARNING "${_binsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") 892 message(WARNING "${_binsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.")
815 endif() 893 endif()
894 if(PKG_CONFIG_REQUIRES)
895 message(WARNING "${_binsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead")
896 endif()
816 897
817 EFL_FILES_TO_ABSOLUTE(_sources ${_binsrcdir} ${_binbindir} ${SOURCES}) 898 EFL_FILES_TO_ABSOLUTE(_sources ${_binsrcdir} ${_binbindir} ${SOURCES})
818 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_binsrcdir} ${_binbindir} ${OBJECT_DEPENDS}) 899 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_binsrcdir} ${_binbindir} ${OBJECT_DEPENDS})
819 900
901 EFL_PKG_CONFIG_EVAL(${_bintarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "")
902
820 add_executable(${_bintarget} ${_sources}) 903 add_executable(${_bintarget} ${_sources})
821 904
822 if(_obj_deps) 905 if(_obj_deps)
@@ -848,6 +931,16 @@ function(EFL_BIN _binname)
848 set_target_properties(${_bintarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) 931 set_target_properties(${_bintarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
849 endif() 932 endif()
850 933
934 # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/
935 set(_compile_flags)
936 foreach(_c ${${_bintarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS})
937 set(_compile_flags "${_compile_flags} ${_c}")
938 endforeach()
939
940 set_target_properties(${_bintarget} PROPERTIES
941 LINK_FLAGS "${${_bintarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}"
942 COMPILE_FLAGS "${_compile_flags}")
943
851 if(INSTALL_DIR) 944 if(INSTALL_DIR)
852 install(TARGETS ${_bintarget} RUNTIME DESTINATION ${INSTALL_DIR}) 945 install(TARGETS ${_bintarget} RUNTIME DESTINATION ${INSTALL_DIR})
853 endif() 946 endif()
@@ -889,6 +982,8 @@ function(EFL_TEST _testname)
889 endif() 982 endif()
890 set(LIBRARIES) 983 set(LIBRARIES)
891 set(DEFINITIONS) 984 set(DEFINITIONS)
985 set(PKG_CONFIG_REQUIRES)
986 set(PKG_CONFIG_REQUIRES_PRIVATE)
892 987
893 if(_testname STREQUAL ${EFL_LIB_CURRENT}) 988 if(_testname STREQUAL ${EFL_LIB_CURRENT})
894 set(_testsrcdir "${EFL_TESTS_SOURCE_DIR}") 989 set(_testsrcdir "${EFL_TESTS_SOURCE_DIR}")
@@ -910,10 +1005,15 @@ function(EFL_TEST _testname)
910 if(PUBLIC_HEADERS) 1005 if(PUBLIC_HEADERS)
911 message(WARNING "${_testsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") 1006 message(WARNING "${_testsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.")
912 endif() 1007 endif()
1008 if(PKG_CONFIG_REQUIRES)
1009 message(WARNING "${_testsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead")
1010 endif()
913 1011
914 EFL_FILES_TO_ABSOLUTE(_sources ${_testsrcdir} ${_testbindir} ${SOURCES}) 1012 EFL_FILES_TO_ABSOLUTE(_sources ${_testsrcdir} ${_testbindir} ${SOURCES})
915 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_testsrcdir} ${_testbindir} ${OBJECT_DEPENDS}) 1013 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_testsrcdir} ${_testbindir} ${OBJECT_DEPENDS})
916 1014
1015 EFL_PKG_CONFIG_EVAL(${_testtarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "")
1016
917 add_executable(${_testtarget} EXCLUDE_FROM_ALL ${_sources}) 1017 add_executable(${_testtarget} EXCLUDE_FROM_ALL ${_sources})
918 1018
919 if(_obj_deps) 1019 if(_obj_deps)
@@ -949,7 +1049,15 @@ function(EFL_TEST _testname)
949 set_target_properties(${_testtarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) 1049 set_target_properties(${_testtarget} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
950 endif() 1050 endif()
951 1051
1052 # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/
1053 set(_compile_flags)
1054 foreach(_c ${${_testtarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS})
1055 set(_compile_flags "${_compile_flags} ${_c}")
1056 endforeach()
1057
952 set_target_properties(${_testtarget} PROPERTIES 1058 set_target_properties(${_testtarget} PROPERTIES
1059 LINK_FLAGS "${${_testtarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}"
1060 COMPILE_FLAGS "${_compile_flags}"
953 LIBRARY_OUTPUT_DIRECTORY "${_testbindir}" 1061 LIBRARY_OUTPUT_DIRECTORY "${_testbindir}"
954 RUNTIME_OUTPUT_DIRECTORY "${_testbindir}") 1062 RUNTIME_OUTPUT_DIRECTORY "${_testbindir}")
955 1063
@@ -978,6 +1086,9 @@ endfunction()
978# - INSTALL_DIR: defaults to 1086# - INSTALL_DIR: defaults to
979# lib/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${Name}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}/. 1087# lib/${EFL_LIB_CURRENT}/modules/${EFL_MODULE_SCOPE}/${Name}/v-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}/.
980# If empty, won't install. 1088# If empty, won't install.
1089# - PKG_CONFIG_REQUIRES_PRIVATE: results in
1090# ${Name}_PKG_CONFIG_REQUIRES_PRIVATE. Elements after 'OPTIONAL'
1091# keyword are optional.
981# 1092#
982# NOTE: since the file will be included it shouldn't mess with global variables! 1093# NOTE: since the file will be included it shouldn't mess with global variables!
983function(EFL_MODULE _modname) 1094function(EFL_MODULE _modname)
@@ -1011,6 +1122,8 @@ function(EFL_MODULE _modname)
1011 set(DEFINITIONS) 1122 set(DEFINITIONS)
1012 set(MODULE_TYPE "${${_modoptionname}}") 1123 set(MODULE_TYPE "${${_modoptionname}}")
1013 set(INSTALL_DIR ${_modoutdir}) 1124 set(INSTALL_DIR ${_modoutdir})
1125 set(PKG_CONFIG_REQUIRES)
1126 set(PKG_CONFIG_REQUIRES_PRIVATE)
1014 1127
1015 _EFL_INCLUDE_OR_DETECT("Module ${_modtarget}" ${_modsrcdir}) 1128 _EFL_INCLUDE_OR_DETECT("Module ${_modtarget}" ${_modsrcdir})
1016 1129
@@ -1021,6 +1134,9 @@ function(EFL_MODULE _modname)
1021 if(PUBLIC_HEADERS) 1134 if(PUBLIC_HEADERS)
1022 message(WARNING "${_modsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.") 1135 message(WARNING "${_modsrcdir}/CMakeLists.txt should not define PUBLIC_HEADERS, it's not to be installed.")
1023 endif() 1136 endif()
1137 if(PKG_CONFIG_REQUIRES)
1138 message(WARNING "${_modsrcdir}/CMakeLists.txt should not define PKG_CONFIG_REQUIRES. Use PKG_CONFIG_REQUIRES_PRIVATE instead")
1139 endif()
1024 1140
1025 if("${MODULE_TYPE}" STREQUAL "OFF") 1141 if("${MODULE_TYPE}" STREQUAL "OFF")
1026 return() 1142 return()
@@ -1033,6 +1149,8 @@ function(EFL_MODULE _modname)
1033 EFL_FILES_TO_ABSOLUTE(_sources ${_modsrcdir} ${_modbindir} ${SOURCES}) 1149 EFL_FILES_TO_ABSOLUTE(_sources ${_modsrcdir} ${_modbindir} ${SOURCES})
1034 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_modsrcdir} ${_modbindir} ${OBJECT_DEPENDS}) 1150 EFL_FILES_TO_ABSOLUTE(_obj_deps ${_modsrcdir} ${_modbindir} ${OBJECT_DEPENDS})
1035 1151
1152 EFL_PKG_CONFIG_EVAL(${_modtarget} "${PKG_CONFIG_REQUIRES_PRIVATE}" "")
1153
1036 add_library(${_modtarget} ${_modtype} ${_sources}) 1154 add_library(${_modtarget} ${_modtype} ${_sources})
1037 set_target_properties(${_modtarget} PROPERTIES 1155 set_target_properties(${_modtarget} PROPERTIES
1038 OBJECT_DEPENDS "${_obj_deps}" 1156 OBJECT_DEPENDS "${_obj_deps}"
@@ -1049,7 +1167,15 @@ function(EFL_MODULE _modname)
1049 1167
1050 target_compile_definitions(${_modtarget} PRIVATE ${DEFINITIONS}) 1168 target_compile_definitions(${_modtarget} PRIVATE ${DEFINITIONS})
1051 1169
1170 # CMake uses string for COMPILE_FLAGS but list for LINK_FLAGS... :-/
1171 set(_compile_flags)
1172 foreach(_c ${${_modtarget}_PKG_CONFIG_REQUIRES_PRIVATE_CFLAGS})
1173 set(_compile_flags "${_compile_flags} ${_c}")
1174 endforeach()
1175
1052 set_target_properties(${_modtarget} PROPERTIES 1176 set_target_properties(${_modtarget} PROPERTIES
1177 LINK_FLAGS "${${_modtarget}_PKG_CONFIG_REQUIRES_PRIVATE_LDFLAGS}"
1178 COMPILE_FLAGS "${_compile_flags}"
1053 LIBRARY_OUTPUT_DIRECTORY "${_modoutdir}" 1179 LIBRARY_OUTPUT_DIRECTORY "${_modoutdir}"
1054 ARCHIVE_OUTPUT_DIRECTORY "${_modoutdir}" 1180 ARCHIVE_OUTPUT_DIRECTORY "${_modoutdir}"
1055 RUNTIME_OUTPUT_DIRECTORY "${_modoutdir}") 1181 RUNTIME_OUTPUT_DIRECTORY "${_modoutdir}")