[PATCH] D16153: tools/CMakeLists: Use a macro for common code, fix custom_command output

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 13:43:32 PST 2016


MatzeB created this revision.
MatzeB added reviewers: jlebar, mcrosier, jmolloy.
MatzeB added a subscriber: llvm-commits.
MatzeB set the repository for this revision to rL LLVM.

Removing the explicit ${CMAKE_CURRENT_BINARY_DIR}/ prefix from the
add_custom_command OUTPUT part, fixes ninja warnings for me. I assume this is possible now after we chose a different target name for the add_custom_target().

This version works fine for me with ninja and make now. Does this look sensible and work for others?

Repository:
  rL LLVM

http://reviews.llvm.org/D16153

Files:
  tools/CMakeLists.txt

Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -9,15 +9,14 @@
 
 set(TEST_SUITE_HOST_CC "cc" CACHE STRING "C compiler targetting the host")
 mark_as_advanced(TEST_SUITE_HOST_CC)
-add_custom_target(fpcmp-host
-    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fpcmp)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fpcmp
-  COMMAND ${TEST_SUITE_HOST_CC} ${CMAKE_CURRENT_SOURCE_DIR}/fpcmp.c -o ${CMAKE_CURRENT_BINARY_DIR}/fpcmp
-  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/fpcmp.c
-)
-add_custom_target(timeit-host
-    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/timeit)
-add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/timeit
-  COMMAND ${TEST_SUITE_HOST_CC} ${CMAKE_CURRENT_SOURCE_DIR}/timeit.c -o ${CMAKE_CURRENT_BINARY_DIR}/timeit
-  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/timeit.c
-)
+macro(llvm_add_host_executable targetname exename sourcefile)
+  add_custom_command(OUTPUT ${exename}
+    COMMAND ${TEST_SUITE_HOST_CC} ${CMAKE_CURRENT_SOURCE_DIR}/${sourcefile} -o ${CMAKE_CURRENT_BINARY_DIR}/${exename}
+    COMMENT "[TEST_SUITE_HOST_CC] Building host executable ${exename}"
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${sourcefile}
+  )
+  add_custom_target(${targetname} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${exename})
+endmacro()
+
+llvm_add_host_executable(fpcmp-host fpcmp fpcmp.c)
+llvm_add_host_executable(timeit-host timeit timeit.c)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16153.44783.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160113/3163db46/attachment.bin>


More information about the llvm-commits mailing list