libfuzzer.cmake 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright 2018 Google
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # Downloads and builds libFuzzer from its sources. Uses the build.sh script
  15. # provided by libFuzzer to compile the sources and produce a library with the
  16. # name libFuzzer.a in the same directory as the sources because we have
  17. # BUILD_IN_SOURCES set to TRUE.
  18. # This build method might not work on all systems. See the build.sh script of
  19. # libFuzzer here:
  20. # (https://github.com/llvm-mirror/compiler-rt/blob/master/lib/fuzzer/build.sh).
  21. # An alternative is to write own CMake file that builds libFuzzer.
  22. include(ExternalProject)
  23. if(TARGET libfuzzer)
  24. return()
  25. endif()
  26. # Mark libfuzzer target as done if: (a) fuzzing is not enabled and libFuzzer is
  27. # not needed; (b) a fuzzing library is already provided in LIB_FUZZING_ENGINE
  28. # environment variable as in OSS Fuzz and there is no need to build it; and
  29. # (c) on Windows because fuzzing is not supported.
  30. if(NOT FUZZING OR DEFINED ENV{LIB_FUZZING_ENGINE} OR WIN32)
  31. add_custom_target(libfuzzer)
  32. return()
  33. endif()
  34. set(tag RELEASE_601) # latest release@{2018-07-27}
  35. ExternalProject_Add(
  36. libfuzzer
  37. DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
  38. DOWNLOAD_NAME libfuzzer
  39. SVN_REPOSITORY "https://llvm.org/svn/llvm-project/compiler-rt/tags/${tag}/final/lib/fuzzer"
  40. LOG_DOWNLOAD TRUE # Do not print SVN checkout messages.
  41. PREFIX ${PROJECT_BINARY_DIR}
  42. SOURCE_DIR ${PROJECT_BINARY_DIR}/src/libfuzzer
  43. BUILD_IN_SOURCE TRUE
  44. UPDATE_COMMAND ""
  45. CONFIGURE_COMMAND ""
  46. BUILD_COMMAND "${PROJECT_BINARY_DIR}/src/libfuzzer/build.sh"
  47. INSTALL_COMMAND ""
  48. TEST_COMMAND ""
  49. )