 diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 194485a..99e3066 100644
+index 194485a..b876084 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -13,6 +13,7 @@ PROJECT (c-ares LANGUAGES C VERSION "1.18.0" )

 	INCLUDE (CMakePackageConfigHelpers)
 	CONFIGURE_PACKAGE_CONFIG_FILE (${PROJECT_NAME}-config.cmake.in ${PROJECT_NAME}-config.cmake
 		INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}

 INCLUDE (GNUInstallDirs) # include this *AFTER* PROJECT(), otherwise paths are wrong.
 
 # This is for libtool compatibility, and specified in a form that is easily
@@ -626,10 +627,15 @@ IF (CARES_BUILD_TESTS OR CARES_BUILD_CONTAINER_TESTS)
 	ADD_SUBDIRECTORY (test)
 ENDIF ()
 
+if(DEFINED XP_INSTALL_CMAKEDIR)
+  set(XP_OPT_INSTALL EXCLUDE_FROM_ALL)
+else()
+  set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
+endif()
 
