[libcxx] r307118 - Add dummy CMake target for *.pass.cpp tests when LIBCXX_CONFIGURE_IDE=ON.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 4 20:50:03 PDT 2017


Author: ericwf
Date: Tue Jul  4 20:50:03 2017
New Revision: 307118

URL: http://llvm.org/viewvc/llvm-project?rev=307118&view=rev
Log:
Add dummy CMake target for *.pass.cpp tests when LIBCXX_CONFIGURE_IDE=ON.

In order for IDE's like CLion to correctly parse and highlight the tests
it needs to know roughly how to build them. This patch adds a dummy CMake target
for each/all of the .pass.cpp tests in the test suite to solve this problem.
The target is only created when LIBCXX_CONFIGURE_IDE=ON, so it shouldn't affect
most users.

Originally I wasn't sure that this change deserved to live upstream, but it's
quite frustrating to edit libc++ tests using CLion or Visual Studio without it,
in particular the filesystem tests which rely heavily on macros. Even though the change
should have no effect on non-IDE users/configurations I decided to commit it upstream
with the hopes it will benefit somebody other than me.

Modified:
    libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=307118&r1=307117&r2=307118&view=diff
==============================================================================
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Tue Jul  4 20:50:03 2017
@@ -85,3 +85,36 @@ if (LIBCXX_GENERATE_COVERAGE)
   set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
   setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
 endif()
+
+
+if (LIBCXX_CONFIGURE_IDE)
+  # Create dummy targets for each of the tests in the test suite, this allows
+  # IDE's such as CLion to correctly highlight the tests because it knows
+  # roughly what include paths/compile flags/macro definitions are needed.
+  include_directories(support)
+  file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
+  file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
+  file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
+  add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
+          ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
+  add_dependencies(libcxx_test_objects cxx)
+
+  set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/experimental/filesystem/Inputs/static_test_env)
+  add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")
+
+  set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)
+  add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}")
+
+  set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ")
+  add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}")
+
+  split_list(LIBCXX_COMPILE_FLAGS)
+  split_list(LIBCXX_LINK_FLAGS)
+
+  set_target_properties(libcxx_test_objects
+          PROPERTIES
+            COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+            LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
+            EXCLUDE_FROM_ALL ON
+  )
+endif()




More information about the cfe-commits mailing list