SelectLibraryConfigurations.cmake 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #.rst:
  2. # SelectLibraryConfigurations
  3. # ---------------------------
  4. #
  5. #
  6. #
  7. # select_library_configurations( basename )
  8. #
  9. # This macro takes a library base name as an argument, and will choose
  10. # good values for basename_LIBRARY, basename_LIBRARIES,
  11. # basename_LIBRARY_DEBUG, and basename_LIBRARY_RELEASE depending on what
  12. # has been found and set. If only basename_LIBRARY_RELEASE is defined,
  13. # basename_LIBRARY will be set to the release value, and
  14. # basename_LIBRARY_DEBUG will be set to basename_LIBRARY_DEBUG-NOTFOUND.
  15. # If only basename_LIBRARY_DEBUG is defined, then basename_LIBRARY will
  16. # take the debug value, and basename_LIBRARY_RELEASE will be set to
  17. # basename_LIBRARY_RELEASE-NOTFOUND.
  18. #
  19. # If the generator supports configuration types, then basename_LIBRARY
  20. # and basename_LIBRARIES will be set with debug and optimized flags
  21. # specifying the library to be used for the given configuration. If no
  22. # build type has been set or the generator in use does not support
  23. # configuration types, then basename_LIBRARY and basename_LIBRARIES will
  24. # take only the release value, or the debug value if the release one is
  25. # not set.
  26. #=============================================================================
  27. # Copyright 2009 Will Dicharry <wdicharry@stellarscience.com>
  28. # Copyright 2005-2009 Kitware, Inc.
  29. #
  30. # Distributed under the OSI-approved BSD License (the "License");
  31. # see accompanying file Copyright.txt for details.
  32. #
  33. # This software is distributed WITHOUT ANY WARRANTY; without even the
  34. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  35. # See the License for more information.
  36. #=============================================================================
  37. # (To distribute this file outside of CMake, substitute the full
  38. # License text for the above reference.)
  39. # This macro was adapted from the FindQt4 CMake module and is maintained by Will
  40. # Dicharry <wdicharry@stellarscience.com>.
  41. macro( select_library_configurations basename )
  42. if(NOT ${basename}_LIBRARY_RELEASE)
  43. set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.")
  44. endif()
  45. if(NOT ${basename}_LIBRARY_DEBUG)
  46. set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.")
  47. endif()
  48. if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND
  49. NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND
  50. ( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) )
  51. # if the generator supports configuration types or CMAKE_BUILD_TYPE
  52. # is set, then set optimized and debug options.
  53. set( ${basename}_LIBRARY "" )
  54. foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
  55. list( APPEND ${basename}_LIBRARY optimized "${_libname}" )
  56. endforeach()
  57. foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG )
  58. list( APPEND ${basename}_LIBRARY debug "${_libname}" )
  59. endforeach()
  60. elseif( ${basename}_LIBRARY_RELEASE )
  61. set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} )
  62. elseif( ${basename}_LIBRARY_DEBUG )
  63. set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} )
  64. else()
  65. set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND")
  66. endif()
  67. set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" )
  68. if( ${basename}_LIBRARY )
  69. set( ${basename}_FOUND TRUE )
  70. endif()
  71. mark_as_advanced( ${basename}_LIBRARY_RELEASE
  72. ${basename}_LIBRARY_DEBUG
  73. )
  74. endmacro()