If I am understanding correctly, you are looking for a debug version of a library. If you can not find that library, then you default to using the non-debug version of the library?

If that is the case then there are some CMake macros that might help. I grabbed one from either the FindQt4 or the FindBoost and tweaked it for my needs.

############################################
#
# Check the existence of the libraries.
#
############################################
# This macro was taken directly from the FindQt4.cmake file that is included # with the CMake distribution. This is NOT my work. All work was done by the # original authors of the FindQt4.cmake file. Only minor modifications were # made to remove references to Qt and make this file more generally applicable ######################################################################## #

MACRO (_MXA_ADJUST_LIB_VARS basename)
  IF (${basename}_INCLUDE_DIR)

# if only the release version was found, set the debug variable also to the release version
  IF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)
    SET(${basename}_LIBRARY_DEBUG ${${basename}_LIBRARY_RELEASE})
    SET(${basename}_LIBRARY       ${${basename}_LIBRARY_RELEASE})
    SET(${basename}_LIBRARIES     ${${basename}_LIBRARY_RELEASE})
  ENDIF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)

# if only the debug version was found, set the release variable also to the debug version
  IF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
    SET(${basename}_LIBRARY_RELEASE ${${basename}_LIBRARY_DEBUG})
    SET(${basename}_LIBRARY         ${${basename}_LIBRARY_DEBUG})
    SET(${basename}_LIBRARIES       ${${basename}_LIBRARY_DEBUG})
  ENDIF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
  IF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)
    # if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
    IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
SET(${basename}_LIBRARY optimized ${${basename} _LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
    ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
      # then just use the release libraries
      SET(${basename}_LIBRARY       ${${basename}_LIBRARY_RELEASE} )
    ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
SET(${basename}_LIBRARIES optimized ${${basename} _LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
  ENDIF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)

SET(${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The ${basename} library")

  IF (${basename}_LIBRARY)
    SET(${basename}_FOUND 1)
  ENDIF (${basename}_LIBRARY)

ENDIF (${basename}_INCLUDE_DIR )

  # Make variables changeble to the advanced user
MARK_AS_ADVANCED(${basename}_LIBRARY ${basename}_LIBRARY_RELEASE $ {basename}_LIBRARY_DEBUG ${basename}_INCLUDE_DIR )
ENDMACRO (_MXA_ADJUST_LIB_VARS)


I use the above in the following manner:

# Look for the library.
FIND_LIBRARY(EXPAT_LIBRARY_DEBUG
  NAMES ${EXPAT_SEARCH_DEBUG_NAMES}
  PATHS ${EXPAT_LIB_SEARCH_DIRS}
  NO_DEFAULT_PATH
  )

FIND_LIBRARY(EXPAT_LIBRARY_RELEASE
  NAMES ${EXPAT_SEARCH_RELEASE_NAMES}
  PATHS ${EXPAT_LIB_SEARCH_DIRS}
  NO_DEFAULT_PATH
  )

# include the macro to adjust libraries
INCLUDE (${MXA_RESOURCES_DIR}/MXAAdjustLibVars.cmake)
_MXA_ADJUST_LIB_VARS(EXPAT)

This will end up giving me the following variables:

EXPAT_LIBRARY           /Toolkits/expat/lib/libexpat.dylib
EXPAT_LIBRARY_DEBUG     /Toolkits/expat/lib/libexpat_debug.dylib
EXPAT_LIBRARY_RELEASE   /Toolkits/expat/lib/libexpat.dylib

Is that more what you were after?

The source for these examples can be found at:

http://titanium.imts.us/viewvc/Task_7/MXADataModel/Resources/

Look for MXAFindExpat.cmake and MXAAdjustLibVars.cmake

Does that help your use case?
--
Mike Jackson   Senior Research Engineer
Innovative Management & Technology Services


On Aug 20, 2008, at 10:33 AM, Philip Lowman wrote:

So I submitted a patch to add a new unset() command to CMake. The command will unset normal or cache variables (causing them to become undefined). The command also supports unsetting environment variables, in case anyone has to do that.

The primary use case that drove me to implement this was this:

find_library(FOO_LIBRARY foo)
if(MSVC OR SEARCH_FOO_DEBUG)
    find_library(FOO_LIBRARY_DEBUG food)
else()
    unset(FOO_LIBRARY_DEBUG)
    set(FOO_LIBRARY_DEBUG ${FOO_LIBRARY})
endif()

http://public.kitware.com/Bug/view.php?id=7507

Comments?

--
Philip Lowman
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake


_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to