CMake: Fix public header search for generating Xcode/MSVC projects.
authorJordan Rose <jordan_rose@apple.com>
Tue, 23 Oct 2012 21:54:03 +0000 (21:54 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 23 Oct 2012 21:54:03 +0000 (21:54 +0000)
Previously, we only had support for one level of library under lib/,
with the existence of the two-level lib/StaticAnalyzer/* hardcoded in
the top-level CMakeLists.txt. This became a problem with split of
libRewrite into several libraries -- with the same sub-names as the
libraries in lib/StaticAnalyzer/.

Now, we match up anything under lib/ to the corresponding directory
in include/clang/.

llvm-svn: 166505

clang/CMakeLists.txt

index 2f4fa1c..53d4165 100644 (file)
@@ -181,16 +181,26 @@ endfunction(clang_tablegen)
 macro(add_clang_library name)
   llvm_process_sources(srcs ${ARGN})
   if(MSVC_IDE OR XCODE)
-    string( REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
-    list( GET split_path -1 dir)
-    file( GLOB_RECURSE headers
-      ../../../include/clang/StaticAnalyzer${dir}/*.h
-      ../../../include/clang/StaticAnalyzer${dir}/*.td
-      ../../../include/clang/StaticAnalyzer${dir}/*.def
-      ../../include/clang${dir}/*.h
-      ../../include/clang${dir}/*.td
-      ../../include/clang${dir}/*.def)
-    set(srcs ${srcs} ${headers})
+    # Add public headers
+    file(RELATIVE_PATH lib_path
+      ${CLANG_SOURCE_DIR}/lib/
+      ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+    if(NOT lib_path MATCHES "^[.][.]")
+      file( GLOB_RECURSE headers
+        ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.h
+        ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.def
+      )
+      set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON)
+
+      file( GLOB_RECURSE tds
+        ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.td
+      )
+      source_group("TableGen descriptions" FILES ${tds})
+      set_source_files_properties(${tds}} PROPERTIES HEADER_FILE_ONLY ON)
+
+      set(srcs ${srcs} ${headers} ${tds})
+    endif()
   endif(MSVC_IDE OR XCODE)
   if (MODULE)
     set(libkind MODULE)