|
|
@ -1,4 +1,11 @@ |
|
|
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8) |
|
|
|
CMAKE_MINIMUM_REQUIRED (VERSION 2.8.12) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Fix for CMake policy warning when building with CMake >= 3.0. |
|
|
|
|
|
|
|
# TODO: remove this fix once minimum version is updated to 3.0 or newer. |
|
|
|
|
|
|
|
IF (NOT CMAKE_VERSION VERSION_LESS 3.0) |
|
|
|
|
|
|
|
CMAKE_POLICY (SET CMP0048 NEW) |
|
|
|
|
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
INCLUDE (CheckIncludeFiles) |
|
|
|
INCLUDE (CheckIncludeFiles) |
|
|
|
INCLUDE (CheckTypeSize) |
|
|
|
INCLUDE (CheckTypeSize) |
|
|
|
INCLUDE (CheckFunctionExists) |
|
|
|
INCLUDE (CheckFunctionExists) |
|
|
@ -48,17 +55,6 @@ IF (NOT DEFINED CARES_INSTALL_LOCATION_BIN) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# When chain building C-Ares, we should set some of the same variables that a |
|
|
|
|
|
|
|
# standard Find_Package(CAres) would set. It just references the internal |
|
|
|
|
|
|
|
# build paths rather than an already-installed version. |
|
|
|
|
|
|
|
SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND") |
|
|
|
|
|
|
|
SET (CARES_INCLUDE_DIRS "${PROJECT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "CARES INCLUDE DIRECTORIES") |
|
|
|
|
|
|
|
SET (CARES_LIBRARIES ${PROJECT_NAME} CACHE INTERNAL "CARES LIBRARIES") |
|
|
|
|
|
|
|
IF (CARES_STATIC AND NOT CARES_SHARED) |
|
|
|
|
|
|
|
SET (CARES_DEFINITIONS "-DCARES_STATICLIB" CACHE INTERNAL "CARES DEFINITIONS") |
|
|
|
|
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Look for dependent/required libraries |
|
|
|
# Look for dependent/required libraries |
|
|
|
CHECK_LIBRARY_EXISTS (resolv res_servicename "" HAVE_RES_SERVICENAME_IN_LIBRESOLV) |
|
|
|
CHECK_LIBRARY_EXISTS (resolv res_servicename "" HAVE_RES_SERVICENAME_IN_LIBRESOLV) |
|
|
|
IF (HAVE_RES_SERVICENAME_IN_LIBRESOLV) |
|
|
|
IF (HAVE_RES_SERVICENAME_IN_LIBRESOLV) |
|
|
@ -493,11 +489,6 @@ CONFIGURE_FILE (ares_build.h.cmake ${PROJECT_BINARY_DIR}/ares_build.h) |
|
|
|
CONFIGURE_FILE (ares_config.h.cmake ${PROJECT_BINARY_DIR}/ares_config.h) |
|
|
|
CONFIGURE_FILE (ares_config.h.cmake ${PROJECT_BINARY_DIR}/ares_config.h) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES ( |
|
|
|
|
|
|
|
${CARES_INCLUDE_DIRS} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TRANSFORM_MAKEFILE_INC |
|
|
|
# TRANSFORM_MAKEFILE_INC |
|
|
|
# |
|
|
|
# |
|
|
|
# This function consumes the "Makefile.inc" autotools file, and converts it into |
|
|
|
# This function consumes the "Makefile.inc" autotools file, and converts it into |
|
|
@ -538,7 +529,6 @@ include(${PROJECT_BINARY_DIR}/Makefile.inc.cmake) |
|
|
|
# Build the dynamic/shared library |
|
|
|
# Build the dynamic/shared library |
|
|
|
IF (CARES_SHARED) |
|
|
|
IF (CARES_SHARED) |
|
|
|
ADD_LIBRARY (${PROJECT_NAME} SHARED ${CSOURCES}) |
|
|
|
ADD_LIBRARY (${PROJECT_NAME} SHARED ${CSOURCES}) |
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 -DCARES_BUILDING_LIBRARY" OUTPUT_NAME cares) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Convert CARES_LIB_VERSIONINFO libtool version format into VERSION and SOVERSION |
|
|
|
# Convert CARES_LIB_VERSIONINFO libtool version format into VERSION and SOVERSION |
|
|
|
# Convert from ":" separated into CMake list format using ";" |
|
|
|
# Convert from ":" separated into CMake list format using ";" |
|
|
@ -549,26 +539,57 @@ IF (CARES_SHARED) |
|
|
|
MATH (EXPR CARES_LIB_VERSION_MAJOR "${CARES_LIB_VERSION_CURRENT} - ${CARES_LIB_VERSION_AGE}") |
|
|
|
MATH (EXPR CARES_LIB_VERSION_MAJOR "${CARES_LIB_VERSION_CURRENT} - ${CARES_LIB_VERSION_AGE}") |
|
|
|
SET (CARES_LIB_VERSION_MINOR "${CARES_LIB_VERSION_AGE}") |
|
|
|
SET (CARES_LIB_VERSION_MINOR "${CARES_LIB_VERSION_AGE}") |
|
|
|
SET (CARES_LIB_VERSION_RELEASE "${CARES_LIB_VERSION_REVISION}") |
|
|
|
SET (CARES_LIB_VERSION_RELEASE "${CARES_LIB_VERSION_REVISION}") |
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES VERSION "${CARES_LIB_VERSION_MAJOR}.${CARES_LIB_VERSION_MINOR}.${CARES_LIB_VERSION_RELEASE}") |
|
|
|
|
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES SOVERSION "${CARES_LIB_VERSION_MAJOR}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_LINK_LIBRARIES (${PROJECT_NAME} ${CARES_DEPENDENT_LIBS}) |
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME} PROPERTIES |
|
|
|
|
|
|
|
OUTPUT_NAME cares |
|
|
|
|
|
|
|
VERSION "${CARES_LIB_VERSION_MAJOR}.${CARES_LIB_VERSION_MINOR}.${CARES_LIB_VERSION_RELEASE}" |
|
|
|
|
|
|
|
SOVERSION "${CARES_LIB_VERSION_MAJOR}" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_INCLUDE_DIRECTORIES (${PROJECT_NAME} PUBLIC "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_COMPILE_DEFINITIONS (${PROJECT_NAME} PRIVATE HAVE_CONFIG_H=1 CARES_BUILDING_LIBRARY) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_LINK_LIBRARIES (${PROJECT_NAME} PUBLIC ${CARES_DEPENDENT_LIBS}) |
|
|
|
|
|
|
|
|
|
|
|
IF (CARES_INSTALL) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
INSTALL (TARGETS ${PROJECT_NAME} DESTINATION ${CARES_INSTALL_LOCATION_LIBS}) |
|
|
|
INSTALL (TARGETS ${PROJECT_NAME} DESTINATION ${CARES_INSTALL_LOCATION_LIBS}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
SET (STATIC_SUFFIX "_static") |
|
|
|
SET (STATIC_SUFFIX "_static") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For chain building: add alias targets that look like import libs that would be returned by find_package(Cares). |
|
|
|
|
|
|
|
ADD_LIBRARY (Cares::cares_shared ALIAS ${PROJECT_NAME}) |
|
|
|
|
|
|
|
ADD_LIBRARY (Cares::cares ALIAS ${PROJECT_NAME}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
# Build the static library |
|
|
|
# Build the static library |
|
|
|
IF (CARES_STATIC) |
|
|
|
IF (CARES_STATIC) |
|
|
|
ADD_LIBRARY (${PROJECT_NAME}${STATIC_SUFFIX} STATIC ${CSOURCES}) |
|
|
|
SET (LIBNAME ${PROJECT_NAME}${STATIC_SUFFIX}) |
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME}${STATIC_SUFFIX} PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 -DCARES_STATICLIB" OUTPUT_NAME cares) |
|
|
|
|
|
|
|
|
|
|
|
ADD_LIBRARY (${LIBNAME} STATIC ${CSOURCES}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES OUTPUT_NAME cares) |
|
|
|
IF (CARES_STATIC_PIC) |
|
|
|
IF (CARES_STATIC_PIC) |
|
|
|
SET_TARGET_PROPERTIES (${PROJECT_NAME}${STATIC_SUFFIX} PROPERTIES POSITION_INDEPENDENT_CODE True) |
|
|
|
SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES POSITION_INDEPENDENT_CODE True) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
TARGET_LINK_LIBRARIES (${PROJECT_NAME}${STATIC_SUFFIX} ${CARES_DEPENDENT_LIBS}) |
|
|
|
|
|
|
|
|
|
|
|
TARGET_INCLUDE_DIRECTORIES (${LIBNAME} PUBLIC "${PROJECT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_COMPILE_DEFINITIONS (${LIBNAME} |
|
|
|
|
|
|
|
PUBLIC CARES_STATICLIB |
|
|
|
|
|
|
|
PRIVATE HAVE_CONFIG_H=1 |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TARGET_LINK_LIBRARIES (${LIBNAME} PUBLIC ${CARES_DEPENDENT_LIBS}) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
INSTALL (TARGETS ${PROJECT_NAME}${STATIC_SUFFIX} DESTINATION ${CARES_INSTALL_LOCATION_LIBS}) |
|
|
|
INSTALL (TARGETS ${LIBNAME} DESTINATION ${CARES_INSTALL_LOCATION_LIBS}) |
|
|
|
|
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For chain building: add alias targets that look like import libs that would be returned by find_package(Cares). |
|
|
|
|
|
|
|
ADD_LIBRARY (Cares::cares_static ALIAS ${LIBNAME}) |
|
|
|
|
|
|
|
IF (NOT TARGET Cares::cares) |
|
|
|
|
|
|
|
# Only use static for the generic alias if shared lib wasn't built. |
|
|
|
|
|
|
|
ADD_LIBRARY (Cares::cares ALIAS ${LIBNAME}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
@ -580,10 +601,16 @@ IF (CARES_INSTALL) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Legacy chain-building variables (provided for compatibility with old code). |
|
|
|
|
|
|
|
# Don't use these, external code should be updated to refer to the aliases directly (e.g., Cares::cares). |
|
|
|
|
|
|
|
SET (CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND") |
|
|
|
|
|
|
|
SET (CARES_LIBRARIES Cares::cares CACHE INTERNAL "CARES LIBRARIES") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Build ahost |
|
|
|
# Build ahost |
|
|
|
ADD_EXECUTABLE (ahost ahost.c ${SAMPLESOURCES}) |
|
|
|
ADD_EXECUTABLE (ahost ahost.c ${SAMPLESOURCES}) |
|
|
|
SET_TARGET_PROPERTIES(ahost PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}") |
|
|
|
TARGET_COMPILE_DEFINITIONS (ahost PRIVATE HAVE_CONFIG_H=1) |
|
|
|
TARGET_LINK_LIBRARIES (ahost ${CARES_LIBRARIES} ${CARES_DEPENDENT_LIBS}) |
|
|
|
TARGET_LINK_LIBRARIES (ahost PRIVATE ${PROJECT_NAME}) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
INSTALL (TARGETS ahost RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
INSTALL (TARGETS ahost RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
@ -591,8 +618,8 @@ ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
# Build adig |
|
|
|
# Build adig |
|
|
|
ADD_EXECUTABLE (adig adig.c ${SAMPLESOURCES}) |
|
|
|
ADD_EXECUTABLE (adig adig.c ${SAMPLESOURCES}) |
|
|
|
SET_TARGET_PROPERTIES(adig PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}") |
|
|
|
TARGET_COMPILE_DEFINITIONS (adig PRIVATE HAVE_CONFIG_H=1) |
|
|
|
TARGET_LINK_LIBRARIES (adig ${CARES_LIBRARIES} ${CARES_DEPENDENT_LIBS}) |
|
|
|
TARGET_LINK_LIBRARIES (adig PRIVATE ${PROJECT_NAME}) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
INSTALL (TARGETS adig RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
INSTALL (TARGETS adig RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
@ -600,8 +627,8 @@ ENDIF () |
|
|
|
|
|
|
|
|
|
|
|
# Build acountry |
|
|
|
# Build acountry |
|
|
|
ADD_EXECUTABLE (acountry acountry.c ${SAMPLESOURCES}) |
|
|
|
ADD_EXECUTABLE (acountry acountry.c ${SAMPLESOURCES}) |
|
|
|
SET_TARGET_PROPERTIES(acountry PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}") |
|
|
|
TARGET_COMPILE_DEFINITIONS (acountry PRIVATE HAVE_CONFIG_H=1) |
|
|
|
TARGET_LINK_LIBRARIES (acountry ${CARES_LIBRARIES} ${CARES_DEPENDENT_LIBS}) |
|
|
|
TARGET_LINK_LIBRARIES (acountry PRIVATE ${PROJECT_NAME}) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
IF (CARES_INSTALL) |
|
|
|
INSTALL (TARGETS acountry RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
INSTALL (TARGETS acountry RUNTIME DESTINATION ${CARES_INSTALL_LOCATION_BIN}) |
|
|
|
ENDIF () |
|
|
|
ENDIF () |
|
|
|