cmake: improve some include related code (#680)

* cmake: avoid warning about non-existing include dir

In the Debian build logs I noticed the following warning:
cc1: warning: /build/c-ares-1.25.0/test/include: No such file or directory [-Wmissing-include-dirs]

This happened because ${CMAKE_INSTALL_INCLUDEDIR} had been added to
caresinternal. I believe it has been copied from the "real" lib
where it's used in the INSTALL_INTERFACE context. But because
caresinternal is never installed we don't need that include here.

* cmake: drop CARES_TOPLEVEL_DIR variable

The CARES_TOPLEVEL_DIR variable is the same as the automatically
created PROJECT_SOURCE_DIR variable. Let's stick to the official
one. Also because it is already used at places where CARES_TOPLEVEL_DIR
is used as well.

Fix By: Gregor Jasny (@gjasny)
pull/684/head
Gregor Jasny 11 months ago committed by GitHub
parent 4f5767ed69
commit 2a6a420cb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CMakeLists.txt
  2. 4
      src/lib/CMakeLists.txt
  3. 4
      src/tools/CMakeLists.txt
  4. 3
      test/CMakeLists.txt

@ -655,10 +655,6 @@ IF (HAVE_ARPA_NAMESER_COMPAT_H)
SET (CARES_HAVE_ARPA_NAMESER_COMPAT_H 1)
ENDIF()
# Record toplevel CMakeLists.txt path
set(CARES_TOPLEVEL_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# TRANSFORM_MAKEFILE_INC
#
# This function consumes the "Makefile.inc" autotools file, and converts it into

@ -47,7 +47,7 @@ IF (CARES_SHARED)
TARGET_INCLUDE_DIRECTORIES (${PROJECT_NAME}
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)
@ -99,7 +99,7 @@ IF (CARES_STATIC)
TARGET_INCLUDE_DIRECTORIES (${LIBNAME}
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)

@ -11,7 +11,7 @@ IF (CARES_BUILD_TOOLS)
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/lib>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)
@ -32,7 +32,7 @@ IF (CARES_BUILD_TOOLS)
PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/lib>"
"$<BUILD_INTERFACE:${CARES_TOPLEVEL_DIR}/include>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}"
)

@ -18,8 +18,7 @@ target_include_directories(caresinternal
"${PROJECT_BINARY_DIR}/src/lib"
"${PROJECT_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}/src/lib"
"${CARES_TOPLEVEL_DIR}/include"
"${CMAKE_INSTALL_INCLUDEDIR}"
"${PROJECT_SOURCE_DIR}/include"
)
IF (CARES_STATIC)

Loading…
Cancel
Save