[cfe-dev] [PATCH] [libc++, cmake] fix duplicate installation of headers

David Fang fang at csl.cornell.edu
Mon Apr 28 15:44:48 PDT 2014


Hi,
 	The attached patch is my attempt to fix
http://llvm.org/bugs/show_bug.cgi?id=18681
where extra copies of libc++ header were installed by cmake.

The patch cleans up a few things:
1) no longer copy $srcdir/includes into $builddir/include (they were
 	identical)
2) pass both $srcdir/include and $builddir/include to cxxflags
3) move handling of header installs into the setup_abi_lib macro,
 	clear out include/CMakeLists.txt completely
4) tighter control over what headers get installed

I've only tested this on my powerpc-darwin8 setup, with cmake 2.8.12, so 
it would be nice if someone could test on !darwin, maybe even cmake 2.8.10.
I am *not* adept at cmake, so this should (in addition) reviewed by 
someone who is.  I'm sure it could be cleaner.

David

-- 
David Fang
http://www.csl.cornell.edu/~fang/
-------------- next part --------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45bd4cc..b182485 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,12 +125,34 @@ macro(setup_abi_lib abipathvar abidefines abilibs abifiles abidirs)
   endforeach()
   add_custom_target(abilib_headers DEPENDS ${LIBCXX_CXX_ABI_DEPS})
   set(LIBCXX_CXX_ABI_DEPS abilib_headers)
+  include_directories("${CMAKE_SOURCE_DIR}/include")
   include_directories("${CMAKE_BINARY_DIR}/include")
-  install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
-    DESTINATION include/c++/v1
+  set(VERSIONED_HEADER_INSTALL_DIR include/c++/v1)
+  if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
+    set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
+  endif()
+  install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
+    DESTINATION ${VERSIONED_HEADER_INSTALL_DIR}
     FILES_MATCHING
     PATTERN "*"
+    PATTERN "CMakeLists.txt" EXCLUDE
+    PATTERN ".svn" EXCLUDE
+    ${LIBCXX_SUPPORT_HEADER_PATTERN}
+    )
+  # install a copy of the found cxxabi.h header
+  install(DIRECTORY "${CMAKE_BINARY_DIR}/include/"
+    DESTINATION ${VERSIONED_HEADER_INSTALL_DIR}
+    FILES_MATCHING
+    PATTERN "cxxabi.h"
+    PATTERN "CMakeFiles" EXCLUDE
+  )
+  foreach(_d ${abidirs})
+    install(DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}"
+      DESTINATION ${VERSIONED_HEADER_INSTALL_DIR}
+      FILES_MATCHING
+      PATTERN "*"
     )
+  endforeach()
 endmacro()
 
 if ("${LIBCXX_CXX_ABI}" STREQUAL "libstdc++" OR
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index 0c88b7f..e976962 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -1,16 +1 @@
-if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS)
-  set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE)
-endif()
-
-file(COPY .
-  DESTINATION "${CMAKE_BINARY_DIR}/include/c++/v1"
-  FILES_MATCHING
-  PATTERN "*"
-  PATTERN "CMakeLists.txt" EXCLUDE
-  PATTERN ".svn" EXCLUDE
-  ${LIBCXX_SUPPORT_HEADER_PATTERN}
-  )
-
-install(DIRECTORY "${CMAKE_BINARY_DIR}/include/c++/v1/"
-  DESTINATION include/c++/v1/
-  )
+# installation managed in top-level CMakeLists.txt


More information about the cfe-dev mailing list