[PATCH] D61660: [cmake] Make google benchmark project call llvm_add_library

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 10:00:38 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/utils/benchmark/CMakeLists.txt:5
+# build Benchmark as an standalone project.
+if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
+  # Tell cmake 3.0+ that it's safe to clear the PROJECT_VERSION variable in the
----------------
As discussed in IRC with @beanz, is this really about `project()`, or CMake policies `cmake_minimum_required()` ?



================
Comment at: llvm/utils/benchmark/CMakeLists.txt:15-23
+if(CMAKE_PROJECT_NAME STREQUAL "LLVM")
+  function(benchmark_add_library target)
+    llvm_add_library(${target} ${ARGN})
+  endfunction()
+else()
+  function(benchmark_add_library target)
+    add_library(${target} ${ARGN})
----------------
I'm serious, there is no need to have this *here*.
Here, only add:
```
# Creates a new library build target. Use this instead of `add_library`.
if(NOT COMMAND benchmark_add_library)
  function(benchmark_add_library target)
    add_library(${target} ${ARGN})
  endfunction()
endif() # NOT COMMAND benchmark_add_library
```
And add this in to `llvm/CMakeLists.txt`, right before `add_subdirectory(utils/benchmark)`
```
  function(benchmark_add_library target)
    llvm_add_library(${target} ${ARGN})
  endfunction()
```
This results in smallest diff from upstream.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61660/new/

https://reviews.llvm.org/D61660





More information about the llvm-commits mailing list