find_package (PkgConfig REQUIRED) pkg_check_modules (GLIB2 REQUIRED glib-2.0) include_directories (${GLIB2_INCLUDE_DIRS}) link_directories (${GLIB2_LIBRARY_DIRS}) if (CMAKE_COMPILER_IS_GNUCC) add_definitions (${GLIB2_CFLAGS_OTHER}) endif () # add the executable add_executable (gettextex1 gettextex1.c) target_link_libraries (gettextex1 ${GLIB2_LIBRARIES})