Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

143 строки
5.0 KiB

  1. #-------------------------------------------------------------------
  2. # This file is part of the CMake build system for OGRE
  3. # (Object-oriented Graphics Rendering Engine)
  4. # For the latest info, see http://www.ogre3d.org/
  5. #
  6. # The contents of this file are placed in the public domain. Feel
  7. # free to make use of it in any way you like.
  8. #-------------------------------------------------------------------
  9. ##################################################################
  10. # Provides some common functionality for the FindPackage modules
  11. ##################################################################
  12. # Begin processing of package
  13. macro(findpkg_begin PREFIX)
  14. if (NOT ${PREFIX}_FIND_QUIETLY)
  15. message(STATUS "Looking for ${PREFIX}...")
  16. endif ()
  17. endmacro(findpkg_begin)
  18. # Display a status message unless FIND_QUIETLY is set
  19. macro(pkg_message PREFIX)
  20. if (NOT ${PREFIX}_FIND_QUIETLY)
  21. message(STATUS ${ARGN})
  22. endif ()
  23. endmacro(pkg_message)
  24. # Get environment variable, define it as ENV_$var and make sure backslashes are converted to forward slashes
  25. macro(getenv_path VAR)
  26. set(ENV_${VAR} $ENV{${VAR}})
  27. # replace won't work if var is blank
  28. if (ENV_${VAR})
  29. string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
  30. endif ()
  31. endmacro(getenv_path)
  32. # Construct search paths for includes and libraries from a PREFIX_PATH
  33. macro(create_search_paths PREFIX)
  34. foreach(dir ${${PREFIX}_PREFIX_PATH})
  35. set(${PREFIX}_INC_SEARCH_PATH ${${PREFIX}_INC_SEARCH_PATH}
  36. ${dir}/include ${dir}/include/${PREFIX} ${dir}/Headers)
  37. set(${PREFIX}_LIB_SEARCH_PATH ${${PREFIX}_LIB_SEARCH_PATH}
  38. ${dir}/lib ${dir}/lib/${PREFIX} ${dir}/Libs)
  39. endforeach(dir)
  40. set(${PREFIX}_FRAMEWORK_SEARCH_PATH ${${PREFIX}_PREFIX_PATH})
  41. endmacro(create_search_paths)
  42. # clear cache variables if a certain variable changed
  43. macro(clear_if_changed TESTVAR)
  44. # test against internal check variable
  45. if (NOT "${${TESTVAR}}" STREQUAL "${${TESTVAR}_INT_CHECK}")
  46. message(STATUS "${TESTVAR} changed.")
  47. foreach(var ${ARGN})
  48. set(${var} "NOTFOUND" CACHE STRING "x" FORCE)
  49. endforeach(var)
  50. endif ()
  51. set(${TESTVAR}_INT_CHECK ${${TESTVAR}} CACHE INTERNAL "x" FORCE)
  52. endmacro(clear_if_changed)
  53. # Try to get some hints from pkg-config, if available
  54. macro(use_pkgconfig PREFIX PKGNAME)
  55. find_package(PkgConfig)
  56. if (PKG_CONFIG_FOUND)
  57. pkg_check_modules(${PREFIX} ${PKGNAME})
  58. endif ()
  59. endmacro (use_pkgconfig)
  60. # Couple a set of release AND debug libraries (or frameworks)
  61. macro(make_library_set PREFIX)
  62. if (${PREFIX}_FWK)
  63. set(${PREFIX} ${${PREFIX}_FWK})
  64. elseif (${PREFIX}_REL AND ${PREFIX}_DBG)
  65. set(${PREFIX} optimized ${${PREFIX}_REL} debug ${${PREFIX}_DBG})
  66. elseif (${PREFIX}_REL)
  67. set(${PREFIX} ${${PREFIX}_REL})
  68. elseif (${PREFIX}_DBG)
  69. set(${PREFIX} ${${PREFIX}_DBG})
  70. endif ()
  71. endmacro(make_library_set)
  72. # Generate debug names from given release names
  73. macro(get_debug_names PREFIX)
  74. foreach(i ${${PREFIX}})
  75. set(${PREFIX}_DBG ${${PREFIX}_DBG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
  76. endforeach(i)
  77. endmacro(get_debug_names)
  78. # Add the parent dir from DIR to VAR
  79. macro(add_parent_dir VAR DIR)
  80. get_filename_component(${DIR}_TEMP "${${DIR}}/.." ABSOLUTE)
  81. set(${VAR} ${${VAR}} ${${DIR}_TEMP})
  82. endmacro(add_parent_dir)
  83. # Do the final processing for the package find.
  84. macro(findpkg_finish PREFIX)
  85. # skip if already processed during this run
  86. if (NOT ${PREFIX}_FOUND)
  87. if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
  88. set(${PREFIX}_FOUND TRUE)
  89. set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
  90. set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
  91. if (NOT ${PREFIX}_FIND_QUIETLY)
  92. message(STATUS "Found ${PREFIX}: ${${PREFIX}_LIBRARIES}")
  93. endif ()
  94. else ()
  95. if (NOT ${PREFIX}_FIND_QUIETLY)
  96. message(STATUS "Could not locate ${PREFIX}")
  97. endif ()
  98. if (${PREFIX}_FIND_REQUIRED)
  99. message(FATAL_ERROR "Required library ${PREFIX} not found! Install the library (including dev packages) and try again. If the library is already installed, set the missing variables manually in cmake.")
  100. endif ()
  101. endif ()
  102. mark_as_advanced(${PREFIX}_INCLUDE_DIR ${PREFIX}_LIBRARY ${PREFIX}_LIBRARY_REL ${PREFIX}_LIBRARY_DBG ${PREFIX}_LIBRARY_FWK)
  103. endif ()
  104. endmacro(findpkg_finish)
  105. # Slightly customised framework finder
  106. MACRO(findpkg_framework fwk)
  107. IF(APPLE)
  108. SET(${fwk}_FRAMEWORK_PATH
  109. ${${fwk}_FRAMEWORK_SEARCH_PATH}
  110. ${CMAKE_FRAMEWORK_PATH}
  111. ~/Library/Frameworks
  112. /Library/Frameworks
  113. /System/Library/Frameworks
  114. /Network/Library/Frameworks
  115. /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/
  116. )
  117. FOREACH(dir ${${fwk}_FRAMEWORK_PATH})
  118. SET(fwkpath ${dir}/${fwk}.framework)
  119. IF(EXISTS ${fwkpath})
  120. SET(${fwk}_FRAMEWORK_INCLUDES ${${fwk}_FRAMEWORK_INCLUDES}
  121. ${fwkpath}/Headers ${fwkpath}/PrivateHeaders)
  122. if (NOT ${fwk}_LIBRARY_FWK)
  123. SET(${fwk}_LIBRARY_FWK "-framework ${fwk}")
  124. endif ()
  125. ENDIF(EXISTS ${fwkpath})
  126. ENDFOREACH(dir)
  127. ENDIF(APPLE)
  128. ENDMACRO(findpkg_framework)