| 1 |
# select_library_configurations( basename ) |
| 2 |
# |
| 3 |
# This macro takes a library base name as an argument, and will choose good |
| 4 |
# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and |
| 5 |
# basename_LIBRARY_RELEASE depending on what has been found and set. If only |
| 6 |
# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG, |
| 7 |
# and basename_LIBRARY_RELEASE will be set to the release value. If only |
| 8 |
# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY, |
| 9 |
# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. |
| 10 |
# |
| 11 |
# If the generator supports configuration types, then basename_LIBRARY and |
| 12 |
# basename_LIBRARIES will be set with debug and optimized flags specifying the |
| 13 |
# library to be used for the given configuration. If no build type has been set |
| 14 |
# or the generator in use does not support configuration types, then |
| 15 |
# basename_LIBRARY and basename_LIBRARIES will take only the release values. |
| 16 |
|
| 17 |
#============================================================================= |
| 18 |
# Copyright 2009 Kitware, Inc. |
| 19 |
# Copyright 2009 Will Dicharry <[email protected]> |
| 20 |
# Copyright 2005-2009 Kitware, Inc. |
| 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 the License for more information. |
| 28 |
#============================================================================= |
| 29 |
# (To distributed this file outside of CMake, substitute the full |
| 30 |
# License text for the above reference.) |
| 31 |
|
| 32 |
# This macro was adapted from the FindQt4 CMake module and is maintained by Will |
| 33 |
# Dicharry <[email protected]>. |
| 34 |
|
| 35 |
# Utility macro to check if one variable exists while another doesn't, and set |
| 36 |
# one that doesn't exist to the one that exists. |
| 37 |
macro( _set_library_name basename GOOD BAD ) |
| 38 |
if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) |
| 39 |
set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} ) |
| 40 |
set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} ) |
| 41 |
set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} ) |
| 42 |
endif( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) |
| 43 |
endmacro( _set_library_name ) |
| 44 |
|
| 45 |
macro( select_library_configurations basename ) |
| 46 |
# if only the release version was found, set the debug to be the release |
| 47 |
# version. |
| 48 |
_set_library_name( ${basename} RELEASE DEBUG ) |
| 49 |
# if only the debug version was found, set the release value to be the |
| 50 |
# debug value. |
| 51 |
_set_library_name( ${basename} DEBUG RELEASE ) |
| 52 |
if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) |
| 53 |
# if the generator supports configuration types or CMAKE_BUILD_TYPE |
| 54 |
# is set, then set optimized and debug options. |
| 55 |
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) |
| 56 |
set( ${basename}_LIBRARY |
| 57 |
optimized ${${basename}_LIBRARY_RELEASE} |
| 58 |
debug ${${basename}_LIBRARY_DEBUG} ) |
| 59 |
set( ${basename}_LIBRARIES |
| 60 |
optimized ${${basename}_LIBRARY_RELEASE} |
| 61 |
debug ${${basename}_LIBRARY_DEBUG} ) |
| 62 |
else( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) |
| 63 |
# If there are no configuration types or build type, just use |
| 64 |
# the release version |
| 65 |
set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) |
| 66 |
set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) |
| 67 |
endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) |
| 68 |
endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) |
| 69 |
|
| 70 |
set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH |
| 71 |
"The ${basename} library" ) |
| 72 |
|
| 73 |
if( ${basename}_LIBRARY ) |
| 74 |
set( ${basename}_FOUND TRUE ) |
| 75 |
endif( ${basename}_LIBRARY ) |
| 76 |
|
| 77 |
mark_as_advanced( ${basename}_LIBRARY |
| 78 |
${basename}_LIBRARY_RELEASE |
| 79 |
${basename}_LIBRARY_DEBUG |
| 80 |
) |
| 81 |
endmacro( select_library_configurations ) |
| 82 |
|