From: Dominique Belhachemi <domibel@debian.org>
Date: Fri, 19 Oct 2012 11:35:52 -0400
Subject: remove custom ExportHeader function, use install instead

---
 src/CMakeLists.txt         |  5 +----
 src/ExportHeader.cmake     | 27 ---------------------------
 src/api/CMakeLists.txt     | 42 +++++++++++++++++++-----------------------
 src/toolkit/CMakeLists.txt |  3 +++
 4 files changed, 23 insertions(+), 54 deletions(-)
 delete mode 100644 src/ExportHeader.cmake

--- a/src/api/CMakeLists.txt
+++ b/src/api/CMakeLists.txt
@@ -51,27 +51,23 @@ install( TARGETS BamTools
          LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
          RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" )
 
-# export API headers
-include(../ExportHeader.cmake)
-set(ApiIncludeDir "api")
-ExportHeader(APIHeaders api_global.h             ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAlgorithms.h          ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAlignment.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders BamAux.h                 ${ApiIncludeDir})
-ExportHeader(APIHeaders BamConstants.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders BamIndex.h               ${ApiIncludeDir})
-ExportHeader(APIHeaders BamMultiReader.h         ${ApiIncludeDir})
-ExportHeader(APIHeaders BamReader.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders BamWriter.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders IBamIODevice.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamConstants.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamHeader.h              ${ApiIncludeDir})
-ExportHeader(APIHeaders SamProgram.h             ${ApiIncludeDir})
-ExportHeader(APIHeaders SamProgramChain.h        ${ApiIncludeDir})
-ExportHeader(APIHeaders SamReadGroup.h           ${ApiIncludeDir})
-ExportHeader(APIHeaders SamReadGroupDictionary.h ${ApiIncludeDir})
-ExportHeader(APIHeaders SamSequence.h            ${ApiIncludeDir})
-ExportHeader(APIHeaders SamSequenceDictionary.h  ${ApiIncludeDir})
+install( FILES api_global.h              DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamAlgorithms.h           DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamAlignment.h            DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamAux.h                  DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamConstants.h            DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamIndex.h                DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamMultiReader.h          DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamReader.h               DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES BamWriter.h               DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES IBamIODevice.h            DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamConstants.h            DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamHeader.h               DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamProgram.h              DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamProgramChain.h         DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamReadGroup.h            DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamReadGroupDictionary.h  DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamSequence.h             DESTINATION "include/bamtools/api" COMPONENT Development )
+install( FILES SamSequenceDictionary.h   DESTINATION "include/bamtools/api" COMPONENT Development )
 
-set( AlgorithmsIncludeDir "api/algorithms" )
-ExportHeader( AlgorithmsHeaders algorithms/Sort.h ${AlgorithmsIncludeDir} )
+install( FILES algorithms/Sort.h         DESTINATION "include/bamtools/api/algorithms" COMPONENT Development )
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,9 +11,7 @@ add_subdirectory( toolkit )
 add_subdirectory( utils )
 
 # export shared headers
-include( ExportHeader.cmake )
-set( SharedIncludeDir "shared" )
-ExportHeader( SharedHeaders shared/bamtools_global.h ${SharedIncludeDir} )
+install( FILES shared/bamtools_global.h DESTINATION "include/bamtools/shared" COMPONENT Development )
 
 # configure and install pkg-config file
 configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/bamtools.pc.in ${CMAKE_CURRENT_BINARY_DIR}/bamtools-1.pc @ONLY )
--- a/src/ExportHeader.cmake
+++ b/src/ExportHeader.cmake
@@ -1,27 +0,0 @@
-#
-# ExportHeader
-#
-
-function( ExportHeader MODULE FILE DEST )
-
-    # if haven't defined our custom 'build target'
-    # not exactly a build target, but lets this command get
-    # checked any time build step happens
-    if( NOT TARGET ${MODULE} )
-        add_custom_target( ${MODULE} ALL COMMENT "Exporting ${MODULE}" )
-    endif( NOT TARGET ${MODULE} )
-
-    # get the filename (without path)
-    get_filename_component( FILENAME "${FILE}" NAME )
-
-    # copy header to destination
-    add_custom_command( TARGET ${MODULE} COMMAND
-        ${CMAKE_COMMAND} -E copy_if_different
-        "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}"
-        "${CMAKE_CURRENT_BINARY_DIR}/include/${DEST}/${FILENAME}" )
-
-    # make sure files are properly 'installed'
-    install( FILES "${FILE}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bamtools/${DEST}" )
-
-endfunction( ExportHeader )
-
