aboutsummaryrefslogtreecommitdiffstats
path: root/functions.cmake
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@yahoo-inc.com>2016-07-26 09:24:44 +0200
committerArnstein Ressem <aressem@yahoo-inc.com>2016-07-26 09:24:44 +0200
commit899d7437ff3b56b5a91edac170a55a1525d224d3 (patch)
tree59d0ecc98108cc36ff5020e5f57d85386ba8490b /functions.cmake
parent3d6d980b6c86e1d101bb224ab57f24cae9009551 (diff)
Fix install of headerfiles when src/vespa/name does not match modulename.
Diffstat (limited to 'functions.cmake')
-rw-r--r--functions.cmake28
1 files changed, 18 insertions, 10 deletions
diff --git a/functions.cmake b/functions.cmake
index 9c9898bb6f4..362e029ea32 100644
--- a/functions.cmake
+++ b/functions.cmake
@@ -182,7 +182,7 @@ function(vespa_add_library TARGET)
if(ARG_INSTALL)
install(TARGETS ${TARGET} DESTINATION ${ARG_INSTALL})
- __install_header_files(${TARGET})
+ __install_header_files()
endif()
if(ARG_OUTPUT_NAME)
@@ -193,15 +193,23 @@ function(vespa_add_library TARGET)
__export_include_directories(${TARGET})
endfunction()
-function(__install_header_files TARGET)
- # Only install header files for main libraries (that does not contain underscore).
- # Currently all header files are installed as they are not explicitly listed for each library.
- if (NOT ${TARGET} MATCHES "_")
- file(GLOB_RECURSE HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
- foreach(HEADER ${HEADERS})
- get_filename_component(RELDIR ${HEADER} DIRECTORY)
- install(FILES ${HEADER} DESTINATION include/vespa/${TARGET}/${RELDIR})
- endforeach()
+function(__install_header_files)
+ # Currently all header files are installed as they are not explicitly listed for each library. The
+ # proper way would be for each module to list its header files to install.
+
+ # Only install header for targets in */src/vespa/*.
+ string(REPLACE "/" ";" PATH_COMPONENTS ${CMAKE_CURRENT_SOURCE_DIR})
+ list(REVERSE PATH_COMPONENTS)
+ list(GET PATH_COMPONENTS 1 SECOND_ELEMENT)
+ list(GET PATH_COMPONENTS 2 THIRD_ELEMENT)
+ if (${SECOND_ELEMENT} STREQUAL "vespa" AND ${THIRD_ELEMENT} STREQUAL "src")
+ # Preserve the name */src/vespa/<name> as not every module has <name>=module name (e.g. vespalog)
+ get_filename_component(RELATIVE_TO ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
+ file(GLOB_RECURSE HEADERS RELATIVE ${RELATIVE_TO} "*.h")
+ foreach(HEADER ${HEADERS})
+ get_filename_component(RELDIR ${HEADER} DIRECTORY)
+ install(FILES ${RELATIVE_TO}/${HEADER} DESTINATION include/vespa/${RELDIR})
+ endforeach()
endif()
endfunction()