Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

CMakePushCheckState.cmake 2.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  1. # This module defines two macros:
  2. # CMAKE_PUSH_CHECK_STATE()
  3. # and
  4. # CMAKE_POP_CHECK_STATE()
  5. # These two macros can be used to save and restore the state of the variables
  6. # CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES
  7. # and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake,
  8. # like e.g. check_function_exists() etc.
  9. # The variable contents are pushed on a stack, pushing multiple times is supported.
  10. # This is useful e.g. when executing such tests in a Find-module, where they have to be set,
  11. # but after the Find-module has been executed they should have the same value
  12. # as they had before.
  13. #
  14. # Usage:
  15. # cmake_push_check_state()
  16. # set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
  17. # check_function_exists(...)
  18. # cmake_pop_check_state()
  19. #=============================================================================
  20. # Copyright 2006-2011 Alexander Neundorf, <neundorf@kde.org>
  21. #
  22. # Distributed under the OSI-approved BSD License (the "License");
  23. # see accompanying file Copyright.txt for details.
  24. #
  25. # This software is distributed WITHOUT ANY WARRANTY; without even the
  26. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  27. # See COPYING-CMAKE-SCRIPTS for more information.
  28. #=============================================================================
  29. MACRO(CMAKE_PUSH_CHECK_STATE)
  30. IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
  31. SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
  32. ENDIF()
  33. MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
  34. SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
  35. SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
  36. SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
  37. SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
  38. ENDMACRO(CMAKE_PUSH_CHECK_STATE)
  39. MACRO(CMAKE_POP_CHECK_STATE)
  40. # don't pop more than we pushed
  41. IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
  42. SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
  43. SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
  44. SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
  45. SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
  46. MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
  47. ENDIF()
  48. ENDMACRO(CMAKE_POP_CHECK_STATE)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...