[PATCH] D31363: [libc++] Remove cmake glob for source files

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 24 19:29:25 PDT 2017


smeenai created this revision.
Herald added a subscriber: mgorny.

Globbing for source files is problematic because if a source file is
added or removed, the configuration won't be run again, and so the build
won't pick up on the added or removed file until the next configuration.
cmake's help explicitly recommends against the use of `file(GLOB)` to
collect a list of source files for the same reason. Switch to an
explicit list of files.

The glob for headers is left intact, partly because there are a ton of
them (courtesy of using `GLOB_RECURSE`), and partly because it shouldn't
affect building, since the header dependency tracking is handled
separately by cmake.


https://reviews.llvm.org/D31363

Files:
  benchmarks/CMakeLists.txt
  lib/CMakeLists.txt


Index: lib/CMakeLists.txt
===================================================================
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -2,12 +2,43 @@
 
 # Get sources
 file(GLOB LIBCXX_SOURCES ../src/*.cpp)
+set(LIBCXX_SOURCES
+      ../src/algorithm.cpp
+      ../src/any.cpp
+      ../src/bind.cpp
+      ../src/chrono.cpp
+      ../src/condition_variable.cpp
+      ../src/debug.cpp
+      ../src/exception.cpp
+      ../src/future.cpp
+      ../src/hash.cpp
+      ../src/ios.cpp
+      ../src/iostream.cpp
+      ../src/locale.cpp
+      ../src/memory.cpp
+      ../src/mutex.cpp
+      ../src/new.cpp
+      ../src/optional.cpp
+      ../src/random.cpp
+      ../src/regex.cpp
+      ../src/shared_mutex.cpp
+      ../src/stdexcept.cpp
+      ../src/string.cpp
+      ../src/strstream.cpp
+      ../src/system_error.cpp
+      ../src/thread.cpp
+      ../src/typeinfo.cpp
+      ../src/utility.cpp
+      ../src/valarray.cpp
+      ../src/variant.cpp)
 if(WIN32)
-  file(GLOB LIBCXX_WIN32_SOURCES ../src/support/win32/*.cpp)
-  list(APPEND LIBCXX_SOURCES ${LIBCXX_WIN32_SOURCES})
+  list(APPEND LIBCXX_SOURCES
+         ../src/support/win32/locale_win32.cpp
+         ../src/support/win32/support.cpp)
 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")
   file(GLOB LIBCXX_SOLARIS_SOURCES ../src/support/solaris/*.cpp)
-  list(APPEND LIBCXX_SOURCES ${LIBCXX_SOLARIS_SOURCES})
+  list(APPEND LIBCXX_SOURCES
+         ../src/support/solaris/xlocale.cpp)
 endif()
 
 # Add all the headers to the project for IDEs.
Index: benchmarks/CMakeLists.txt
===================================================================
--- benchmarks/CMakeLists.txt
+++ benchmarks/CMakeLists.txt
@@ -141,7 +141,13 @@
 #==============================================================================
 # Register Benchmark tests
 #==============================================================================
-file(GLOB BENCHMARK_TESTS "*.bench.cpp")
+set(BENCHMARK_TESTS
+      algorithms.bench.cpp
+      filesystem.bench.cpp
+      string.bench.cpp
+      unordered_set_operations.bench.cpp
+      util_smartptr.bench.cpp
+      vector_operations.bench.cpp)
 foreach(test_path ${BENCHMARK_TESTS})
   get_filename_component(test_file "${test_path}" NAME)
   string(REPLACE ".bench.cpp" "" test_name "${test_file}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31363.93030.patch
Type: text/x-patch
Size: 2303 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170325/bfd219b0/attachment.bin>


More information about the cfe-commits mailing list