2
0

CMakeFeatureDetect.cmake 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. #-------------------------------------------------------------------------------------------------------
  5. include(CheckCXXSourceCompiles)
  6. include(CheckCXXSourceRuns)
  7. if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  8. # by default this is disabled for osx
  9. # enable temporarily
  10. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
  11. -Werror"
  12. )
  13. endif()
  14. check_cxx_source_runs("
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. __attribute__((disable_tail_calls))
  18. int inc(int a) { return a + 1; }
  19. int main(int argc, char **argv) {
  20. printf(\"%d\", inc(argc + 1));
  21. exit(0);
  22. }" CLANG_HAS_DISABLE_TAIL_CALLS_CFG)
  23. if(CLANG_HAS_DISABLE_TAIL_CALLS_CFG STREQUAL 1)
  24. add_definitions(-DCLANG_HAS_DISABLE_TAIL_CALLS=1)
  25. set(CXX_DO_NOT_OPTIMIZE_SIBLING_CALLS "")
  26. else()
  27. set(CXX_DO_NOT_OPTIMIZE_SIBLING_CALLS "-fno-optimize-sibling-calls")
  28. endif()
  29. if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  30. # by default this is disabled for osx
  31. # disable back
  32. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
  33. -Wno-error"
  34. )
  35. endif()