Hello I would like to discuss three points
1. naming conventions 2. what if pkg-config sends an error 3. protect already defined variables ------------------------------------ 1. naming conventions: The interface will get a prefix like pkg_check_modules(LIBNAME ...) I would prefer to stick close to the command names, so since INCLUDE_DIRECTORIES -> LIBNAME_INCLUDE_DIRECTORIES since LINK_DIRECTORIES -> LIBNAME_LINK_DIRECTORIES since LINK_LIBRARIES / TARGET_LINK_LIBRARIES -> LIBNAME_LINK_LIBRARIES since ADD_DEFINITIONS -> LIBNAME_DEFINITIONS rather than LIBNAME_INCLUDE_DIRS and LIBNAME_LINK_LIBS ... ---------------------------------- 2. what if the lib isn't found This regards the pkg_check_modules interface. If the lib(s) wasn't/weren't found or version(s) to low the developer should be able to react. IMHO there are two possible solution first: pkg_config(MYPREFIX found "lib1 >= ??? lib2 >= ??? ...") if(NOT found) # FATAL_ERROR of looking for alternatives ... endif(NOT found) second: pkg_config(MYPREFIX "lib1 >= ??? lib2 >= ??? ...") if(NOT MYPREFIX_FOUND) # FATAL_ERROR of looking for alternatives ... endif(NOT MYPREFIX_FOUND) What do you're like more? ---------------------------------- 3. protect already defined variables How can we ensure that variables of the module-user won't be overwritten Just a random example... set(varname ...) pkg_module_macro(...) #... # using varname If inside the macro a SET(varname ...) happens, the module user will be in trouble. Is it possible to set variables being private? If not, we can use a prefix like PKGCONFIG_PRIVATE_* for all internal variables. For more complex tasks this may be a little to verbose. So I played around doing something like this: MACRO(...) SET(PKGCONFIG_PRIVATE_list_of_used_vars version_number_1_digits version_number_2_digits version_number_1_digits_count version_number_2_digits_count to digit_is digit_min digits_count_min ) PKGCONFIG_PRIVATE_VARS_SAVE( PKGCONFIG_PRIVATE_list_of_already_used_vars PKGCONFIG_PRIVATE_list_of_values_of_already_used_vars ${PKGCONFIG_PRIVATE_list_of_used_vars} ) # ... do the work .... # PKGCONFIG_PRIVATE_VARS_RESTORE( PKGCONFIG_PRIVATE_list_of_already_used_vars PKGCONFIG_PRIVATE_list_of_values_of_already_used_vars ) ENDMACRO(...) where the extra macros are MACRO(PKGCONFIG_PRIVATE_VARS_SAVE list_of_vars list_of_var_values) FOREACH(item ${ARGN}) IF(DEFINED ${item}) LIST(APPEND ${list_of_vars} ${item}) LIST(APPEND ${list_of_var_values} ${${item}} ) ENDIF(DEFINED ${item}) ENDFOREACH(item) ENDMACRO(PKGCONFIG_PRIVATE_VARS_SAVE) MACRO(PKGCONFIG_PRIVATE_VARS_RESTORE list_of_vars list_of_var_values) LIST(LENGTH ${list_of_vars} PKGCONFIG_PRIVATE_VAR_1 ) LIST(LENGTH ${list_of_var_values} PKGCONFIG_PRIVATE_VAR_2 ) IF(NOT ${PKGCONFIG_PRIVATE_VAR_1} EQUAL ${PKGCONFIG_PRIVATE_VAR_2} ) MESSAGE(FATAL_ERROR "PKGCONFIG_PRIVATE_VARS_RESTORE: lists got different length" ) ENDIF(NOT ${PKGCONFIG_PRIVATE_VAR_1} EQUAL ${PKGCONFIG_PRIVATE_VAR_2} ) MATH(EXPR PKGCONFIG_PRIVATE_VAR_1 "${PKGCONFIG_PRIVATE_VAR_1} - 1") FOREACH(index RANGE ${PKGCONFIG_PRIVATE_VAR_1} ) LIST(GET ${list_of_vars} ${index} PKGCONFIG_PRIVATE_VAR_1 ) LIST(GET ${list_of_var_values} ${index} PKGCONFIG_PRIVATE_VAR_2 ) set(${PKGCONFIG_PRIVATE_VAR_1} ${PKGCONFIG_PRIVATE_VAR_2}) ENDFOREACH(index) ENDMACRO(PKGCONFIG_PRIVATE_VARS_RESTORE) ---------------------------------- please spend your 2cents Regards, Maik _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake