X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=CMake%2FInstallPublicHeaders.cmake;h=7943ddb2eb03be2912d5f93fc1135d3b6442af21;hb=92d18858b417309f6bdee6bce464a4f3d6a375fd;hp=ae2fa711c53be2d26ab1a71f177778d09456747a;hpb=3ffc968aaf182bf1ff1e18157c7bde2bdb41668d;p=awesomized%2Flibmemcached diff --git a/CMake/InstallPublicHeaders.cmake b/CMake/InstallPublicHeaders.cmake index ae2fa711..7943ddb2 100644 --- a/CMake/InstallPublicHeaders.cmake +++ b/CMake/InstallPublicHeaders.cmake @@ -1,4 +1,4 @@ -function(install_public_headers DIRECTORY) +macro(install_public_headers DIRECTORY) # validate current directory string(FIND ${CMAKE_CURRENT_SOURCE_DIR} /include/ INCDIR REVERSE) string(FIND ${CMAKE_CURRENT_SOURCE_DIR} /src/ SRCDIR REVERSE) @@ -9,36 +9,41 @@ function(install_public_headers DIRECTORY) math(EXPR POSITION "${SRCDIR} + 5") endif() string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${POSITION} -1 CHKDIR) - if(NOT CHKDIR STREQUAL DIRECTORY) - message(SEND_ERROR "install_public_headers() directories do not match: ${CHKDIR} != ${DIRECTORY}") + if(NOT "${CHKDIR}" STREQUAL "${DIRECTORY}") + message(SEND_ERROR "install_public_headers() directories do not match: '${CHKDIR}' != '${DIRECTORY}'") set(ENV{INVALID_CONFIGURATION} 1) endif() endif() + string(REGEX MATCH "^[^/-]+" LIBRARY "${DIRECTORY}") + # validate public interface version - get_filename_component(TOP ${DIRECTORY} NAME) - string(FIND ${TOP} "-" DASH) + string(FIND "${DIRECTORY}" "-" DASH) if(DASH GREATER 0) - string(SUBSTRING ${TOP} 0 ${DASH} LIBRARY) - string(TOUPPER ${LIBRARY} LIBRARY_UCASE) + string(SUBSTRING "${DIRECTORY}" 0 ${DASH} LIBRARY_BASE) + string(TOUPPER ${LIBRARY_BASE} LIBRARY_UCASE) math(EXPR DASH "${DASH} + 1") - string(SUBSTRING ${TOP} ${DASH} -1 VERSION) - if(NOT ${LIBRARY_UCASE}_VERSION_MAJOR VERSION_EQUAL ${VERSION}) - message(SEND_ERROR "${LIBRARY} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_MAJOR}) + string(SUBSTRING "${DIRECTORY}" ${DASH} -1 VERSION) + if(NOT ${LIBRARY_UCASE}_VERSION_INC VERSION_EQUAL ${VERSION}) + message(SEND_ERROR "${LIBRARY_BASE} public include directory version ${VERSION} != " ${${LIBRARY_UCASE}_VERSION_INC}) set(ENV{INVALID_CONFIGURATION} 1) endif() endif() # change local includes to system includes - foreach(HEADER IN LISTS ARGN) + foreach(HEADER IN ITEMS ${ARGN}) if(HEADER MATCHES "^@") string(SUBSTRING ${HEADER} 1 -1 HEADER) configure_file(${HEADER}.in ${HEADER}) set(HEADER "${CMAKE_CURRENT_BINARY_DIR}/${HEADER}") + else() + set(HEADER "${CMAKE_CURRENT_SOURCE_DIR}/${HEADER}") endif() install(FILES ${HEADER} COMPONENT dev DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${DIRECTORY} ) + list(APPEND ${LIBRARY}_includes ${HEADER}) endforeach() -endfunction() + set(${LIBRARY}_includes "${${LIBRARY}_includes}" PARENT_SCOPE) +endmacro()