diff --git a/CMakeLists.txt b/CMakeLists.txt index 27397bcf..44931e24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,13 @@ SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) SET (PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package) +# Destinations for installing different kinds of targets (pass to install command). +SET (TARGETS_INST_DEST + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + # Look for dependent/required libraries CHECK_LIBRARY_EXISTS (resolv res_servicename "" HAVE_RES_SERVICENAME_IN_LIBRESOLV) IF (HAVE_RES_SERVICENAME_IN_LIBRESOLV) @@ -544,7 +551,7 @@ IF (CARES_SHARED) IF (CARES_INSTALL) INSTALL (TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR} + ${TARGETS_INST_DEST} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ENDIF () @@ -563,7 +570,7 @@ IF (CARES_STATIC) SET_TARGET_PROPERTIES (${LIBNAME} PROPERTIES EXPORT_NAME cares${STATIC_SUFFIX} - OUTPUT_NAME cares + OUTPUT_NAME cares${STATIC_SUFFIX} ) IF (CARES_STATIC_PIC) @@ -581,7 +588,7 @@ IF (CARES_STATIC) TARGET_LINK_LIBRARIES (${LIBNAME} PUBLIC ${CARES_DEPENDENT_LIBS}) IF (CARES_INSTALL) INSTALL (TARGETS ${LIBNAME} EXPORT ${PROJECT_NAME}-targets - DESTINATION ${CMAKE_INSTALL_LIBDIR} + ${TARGETS_INST_DEST} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) ENDIF () @@ -625,7 +632,7 @@ ADD_EXECUTABLE (ahost ahost.c ${SAMPLESOURCES}) TARGET_COMPILE_DEFINITIONS (ahost PRIVATE HAVE_CONFIG_H=1) TARGET_LINK_LIBRARIES (ahost PRIVATE ${PROJECT_NAME}) IF (CARES_INSTALL) - INSTALL (TARGETS ahost RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + INSTALL (TARGETS ahost ${TARGETS_INST_DEST}) ENDIF () @@ -634,7 +641,7 @@ ADD_EXECUTABLE (adig adig.c ${SAMPLESOURCES}) TARGET_COMPILE_DEFINITIONS (adig PRIVATE HAVE_CONFIG_H=1) TARGET_LINK_LIBRARIES (adig PRIVATE ${PROJECT_NAME}) IF (CARES_INSTALL) - INSTALL (TARGETS adig RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + INSTALL (TARGETS adig ${TARGETS_INST_DEST}) ENDIF () @@ -643,5 +650,5 @@ ADD_EXECUTABLE (acountry acountry.c ${SAMPLESOURCES}) TARGET_COMPILE_DEFINITIONS (acountry PRIVATE HAVE_CONFIG_H=1) TARGET_LINK_LIBRARIES (acountry PRIVATE ${PROJECT_NAME}) IF (CARES_INSTALL) - INSTALL (TARGETS acountry RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + INSTALL (TARGETS acountry ${TARGETS_INST_DEST}) ENDIF ()