@ -1,4 +1,11 @@
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8 )
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8.12 )
# F i x f o r C M a k e p o l i c y w a r n i n g w h e n b u i l d i n g w i t h C M a k e > = 3 . 0 .
# T O D O : r e m o v e t h i s f i x o n c e m i n i m u m v e r s i o n i s u p d a t e d t o 3 . 0 o r n e w e r .
IF ( NOT CMAKE_VERSION VERSION_LESS 3.0 )
CMAKE_POLICY ( SET CMP0048 NEW )
ENDIF ( )
INCLUDE ( CheckIncludeFiles )
INCLUDE ( CheckTypeSize )
INCLUDE ( CheckFunctionExists )
@ -48,17 +55,6 @@ IF (NOT DEFINED CARES_INSTALL_LOCATION_BIN)
ENDIF ( )
# W h e n c h a i n b u i l d i n g C - A r e s , w e s h o u l d s e t s o m e o f t h e s a m e v a r i a b l e s t h a t a
# s t a n d a r d Find_Package ( CAres ) w o u l d s e t . I t j u s t r e f e r e n c e s t h e i n t e r n a l
# b u i l d p a t h s r a t h e r t h a n a n a l r e a d y - i n s t a l l e d v e r s i o n .
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 ( )
# L o o k f o r d e p e n d e n t / r e q u i r e d l i b r a r i e s
CHECK_LIBRARY_EXISTS ( resolv res_servicename "" 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 )
INCLUDE_DIRECTORIES (
$ { C A R E S _ I N C L U D E _ D I R S }
)
# T R A N S F O R M _ M A K E F I L E _ I N C
#
# T h i s f u n c t i o n c o n s u m e s t h e " M a k e f i l e . i n c " a u t o t o o l s f i l e , a n d c o n v e r t s i t i n t o
@ -538,7 +529,6 @@ include(${PROJECT_BINARY_DIR}/Makefile.inc.cmake)
# B u i l d t h e d y n a m i c / s h a r e d l i b r a r y
IF ( CARES_SHARED )
ADD_LIBRARY ( ${ PROJECT_NAME } SHARED ${ CSOURCES } )
SET_TARGET_PROPERTIES ( ${ PROJECT_NAME } PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 -DCARES_BUILDING_LIBRARY" OUTPUT_NAME cares )
# C o n v e r t C A R E S _ L I B _ V E R S I O N I N F O l i b t o o l v e r s i o n f o r m a t i n t o V E R S I O N a n d S O V E R S I O N
# C o n v e r t f r o m " : " s e p a r a t e d i n t o C M a k e l i s t f o r m a t u s i n g " ; "
@ -549,26 +539,57 @@ IF (CARES_SHARED)
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_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
O U T P U T _ N A M E c a r e s
V E R S I O N " $ { C A R E S _ L I B _ V E R S I O N _ M A J O R } . $ { C A R E S _ L I B _ V E R S I O N _ M I N O R } . $ { C A R E S _ L I B _ V E R S I O N _ R E L E A S E } "
S O V E R S I O N " $ { C A R E S _ L I B _ V E R S I O N _ M A J O R } "
)
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 )
INSTALL ( TARGETS ${ PROJECT_NAME } DESTINATION ${ CARES_INSTALL_LOCATION_LIBS } )
ENDIF ( )
SET ( STATIC_SUFFIX "_static" )
# F o r c h a i n b u i l d i n g : a d d a l i a s t a r g e t s t h a t l o o k l i k e i m p o r t l i b s t h a t w o u l d b e r e t u r n e d b y find_package ( Cares ) .
ADD_LIBRARY ( Cares::cares_shared ALIAS ${ PROJECT_NAME } )
ADD_LIBRARY ( Cares::cares ALIAS ${ PROJECT_NAME } )
ENDIF ( )
# B u i l d t h e s t a t i c l i b r a r y
IF ( CARES_STATIC )
ADD_LIBRARY ( ${ PROJECT_NAME } ${ STATIC_SUFFIX } STATIC ${ CSOURCES } )
SET_TARGET_PROPERTIES ( ${ PROJECT_NAME } ${ STATIC_SUFFIX } PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 -DCARES_STATICLIB" OUTPUT_NAME cares )
SET ( LIBNAME ${ PROJECT_NAME } ${ STATIC_SUFFIX } )
ADD_LIBRARY ( ${ LIBNAME } STATIC ${ CSOURCES } )
SET_TARGET_PROPERTIES ( ${ LIBNAME } PROPERTIES OUTPUT_NAME cares )
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 ( )
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 }
P U B L I C C A R E S _ S T A T I C L I B
P R I V A T E H A V E _ C O N F I G _ H = 1
)
TARGET_LINK_LIBRARIES ( ${ LIBNAME } PUBLIC ${ CARES_DEPENDENT_LIBS } )
IF ( CARES_INSTALL )
INSTALL ( TARGETS ${ PROJECT_NAME } ${ STATIC_SUFFIX } DESTINATION ${ CARES_INSTALL_LOCATION_LIBS } )
INSTALL ( TARGETS ${ LIBNAME } DESTINATION ${ CARES_INSTALL_LOCATION_LIBS } )
ENDIF ( )
# F o r c h a i n b u i l d i n g : a d d a l i a s t a r g e t s t h a t l o o k l i k e i m p o r t l i b s t h a t w o u l d b e r e t u r n e d b y find_package ( Cares ) .
ADD_LIBRARY ( Cares::cares_static ALIAS ${ LIBNAME } )
IF ( NOT TARGET Cares::cares )
# O n l y u s e s t a t i c f o r t h e g e n e r i c a l i a s i f s h a r e d l i b w a s n ' t b u i l t .
ADD_LIBRARY ( Cares::cares ALIAS ${ LIBNAME } )
ENDIF ( )
ENDIF ( )
@ -580,10 +601,16 @@ IF (CARES_INSTALL)
ENDIF ( )
# L e g a c y c h a i n - b u i l d i n g variables ( provided for compatibility with old code ) .
# D o n ' t u s e t h e s e , e x t e r n a l c o d e s h o u l d b e u p d a t e d t o r e f e r t o t h e a l i a s e s directly ( e.g., Cares::cares ) .
SET ( CARES_FOUND 1 CACHE INTERNAL "CARES LIBRARY FOUND" )
SET ( CARES_LIBRARIES Cares::cares CACHE INTERNAL "CARES LIBRARIES" )
# B u i l d a h o s t
ADD_EXECUTABLE ( ahost ahost.c ${ SAMPLESOURCES } )
SET_TARGET_PROPERTIES ( ahost PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}" )
TARGET_LINK_LIBRARIES ( ahost ${ CARES_LIBRARIES } ${ CARES_DEPENDENT_LIBS } )
TARGET_COMPILE_DEFINITIONS ( ahost PRIVATE HAVE_CONFIG_H=1 )
TARGET_LINK_LIBRARIES ( ahost PRIVATE Cares::cares )
IF ( CARES_INSTALL )
INSTALL ( TARGETS ahost RUNTIME DESTINATION ${ CARES_INSTALL_LOCATION_BIN } )
ENDIF ( )
@ -591,8 +618,8 @@ ENDIF ()
# B u i l d a d i g
ADD_EXECUTABLE ( adig adig.c ${ SAMPLESOURCES } )
SET_TARGET_PROPERTIES ( adig PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}" )
TARGET_LINK_LIBRARIES ( adig ${ CARES_LIBRARIES } ${ CARES_DEPENDENT_LIBS } )
TARGET_COMPILE_DEFINITIONS ( adig PRIVATE HAVE_CONFIG_H=1 )
TARGET_LINK_LIBRARIES ( adig PRIVATE Cares::cares )
IF ( CARES_INSTALL )
INSTALL ( TARGETS adig RUNTIME DESTINATION ${ CARES_INSTALL_LOCATION_BIN } )
ENDIF ( )
@ -600,8 +627,8 @@ ENDIF ()
# B u i l d a c o u n t r y
ADD_EXECUTABLE ( acountry acountry.c ${ SAMPLESOURCES } )
SET_TARGET_PROPERTIES ( acountry PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H=1 ${CARES_DEFINITIONS}" )
TARGET_LINK_LIBRARIES ( acountry ${ CARES_LIBRARIES } ${ CARES_DEPENDENT_LIBS } )
TARGET_COMPILE_DEFINITIONS ( acountry PRIVATE HAVE_CONFIG_H=1 )
TARGET_LINK_LIBRARIES ( acountry PRIVATE Cares::cares )
IF ( CARES_INSTALL )
INSTALL ( TARGETS acountry RUNTIME DESTINATION ${ CARES_INSTALL_LOCATION_BIN } )
ENDIF ( )