No subject
Wed Oct 7 22:37:18 EDT 2009
configured to have an installation of both debug and release libraries
in the same installation tree. Qt was the first one that I have seen
but there are a few others. After going through pain on windows where
ALL libraries MUST be linked against the same type of libraries (Debug
or Release), creating my support libraries with debug-and-release
variants in the same installation directory proved much more useful so
I created my own sets of FindXXXX for each of the libraries that I
depend on: Tiff, Expat, HDF5. Boost and Qt both have debug-and-release
in the same installation so those didn't need help.
I have my own CMake build systems for each of those libraries so
the FindXXX.cmake modules are customized for my own use although they
are _suppose_ to work with the standard distributions of those
libraries.
There does not seem to be any consensus on what the debug suffix
should be: "d" "_debug" "Debug" so it is hard to come up with
something consistent.
I have not asked the CMake devs to use this FindExpat because of
all the specializations I have made. Most of the code is taken
directly from the FindQt4.cmake file.
_________________________________________________________
Mike Jackson mike.jackson at bluequartz.net
On Tue, Feb 9, 2010 at 8:40 AM, Luigi Calori <l.calori at cineca.it> wrote:
> Hi Mike, thanks for the code, I' ll try to understand it and to apply to =
my
> need...
> I see is quite more complex than the statndard FindExpat bundled with CMa=
ke:
> Is it customized to your need or just "better"?
> In the latter case, why not ship cmake with it?
> Is testing for debugging libs a very uncommon task?
> Are there other ways to accomplish the same thing?
>
> Thanks a lot
>
> Luigi
>
>
> Mike Jackson wrote:
>>
>> Here is one I wrote for Expat:
>>
>>
>> ------8<------------------------------------------------
>> # - Find expat
>> # Find the native EXPAT headers and libraries.
>> #
>> # =A0EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
>> # =A0EXPAT_LIBRARIES =A0 =A0- List of libraries when using expat.
>> # =A0EXPAT_LIBRARY_DEBUG - Debug version of Library
>> # =A0EXPAT_LIBRARY_RELEASE - Release Version of Library
>> # =A0EXPAT_FOUND =A0 =A0 =A0 =A0- True if expat found.
>>
>>
>> ############################################
>> #
>> # 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 (ADJUST_LIB_VARS basename)
>> =A0IF (${basename}_INCLUDE_DIR)
>>
>> =A0# if only the release version was found, set the debug variable also
>> to the release version
>> =A0IF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)
>> =A0 =A0SET(${basename}_LIBRARY_DEBUG ${${basename}_LIBRARY_RELEASE})
>> =A0 =A0SET(${basename}_LIBRARY =A0 =A0 =A0 ${${basename}_LIBRARY_RELEASE=
})
>> =A0 =A0SET(${basename}_LIBRARIES =A0 =A0 ${${basename}_LIBRARY_RELEASE})
>> =A0ENDIF (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG)
>>
>> =A0# if only the debug version was found, set the release variable also
>> to the debug version
>> =A0IF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
>> =A0 =A0SET(${basename}_LIBRARY_RELEASE ${${basename}_LIBRARY_DEBUG})
>> =A0 =A0SET(${basename}_LIBRARY =A0 =A0 =A0 =A0 ${${basename}_LIBRARY_DEB=
UG})
>> =A0 =A0SET(${basename}_LIBRARIES =A0 =A0 =A0 ${${basename}_LIBRARY_DEBUG=
})
>> =A0ENDIF (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE)
>> =A0IF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)
>> =A0 =A0# if the generator supports configuration types then set
>> =A0 =A0# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a=
value
>> =A0 =A0IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>> =A0 =A0 =A0SET(${basename}_LIBRARY =A0 =A0 =A0 optimized
>> ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
>> =A0 =A0ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>> =A0 =A0 =A0# if there are no configuration types and CMAKE_BUILD_TYPE ha=
s no
>> value
>> =A0 =A0 =A0# then just use the release libraries
>> =A0 =A0 =A0SET(${basename}_LIBRARY =A0 =A0 =A0 ${${basename}_LIBRARY_REL=
EASE} )
>> =A0 =A0ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
>> =A0 =A0SET(${basename}_LIBRARIES =A0 =A0 =A0 optimized
>> ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
>> =A0ENDIF (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE)
>>
>> =A0SET(${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The
>> ${basename} library")
>>
>> =A0IF (${basename}_LIBRARY)
>> =A0 =A0SET(${basename}_FOUND 1)
>> =A0ENDIF (${basename}_LIBRARY)
>>
>> ENDIF (${basename}_INCLUDE_DIR )
>>
>> =A0# Make variables changeble to the advanced user
>> =A0MARK_AS_ADVANCED(${basename}_LIBRARY ${basename}_LIBRARY_RELEASE
>> ${basename}_LIBRARY_DEBUG ${basename}_INCLUDE_DIR )
>> ENDMACRO (ADJUST_LIB_VARS)
>>
>>
>>
>>
>>
>> # Look for the header file.
>>
>> # MESSAGE (STATUS "Finding expat library and headers..." )
>> SET (EXPAT_DEBUG 0)
>>
>> SET(EXPAT_INCLUDE_SEARCH_DIRS
>> =A0$ENV{EXPAT_INSTALL}/include
>> )
>>
>> SET (EXPAT_LIB_SEARCH_DIRS
>> =A0$ENV{EXPAT_INSTALL}/lib
>> =A0)
>>
>> SET (EXPAT_BIN_SEARCH_DIRS
>> =A0$ENV{EXPAT_INSTALL}/bin
>> )
>>
>> FIND_PATH(EXPAT_INCLUDE_DIR
>> =A0NAMES expat.h
>> =A0PATHS ${EXPAT_INCLUDE_SEARCH_DIRS}
>> =A0NO_DEFAULT_PATH
>> )
>>
>> IF (WIN32 AND NOT MINGW)
>> =A0 =A0SET (EXPAT_SEARCH_DEBUG_NAMES "expatdll_D;libexpat_D")
>> =A0 =A0SET (EXPAT_SEARCH_RELEASE_NAMES "expatdll;libexpat")
>> ELSE (WIN32 AND NOT MINGW)
>> =A0 =A0SET (EXPAT_SEARCH_DEBUG_NAMES "expat_debug")
>> =A0 =A0SET (EXPAT_SEARCH_RELEASE_NAMES "expat")
>> ENDIF(WIN32 AND NOT MINGW)
>>
>>
>> IF (EXPAT_DEBUG)
>> message (STATUS "EXPAT_INCLUDE_SEARCH_DIRS: ${EXPAT_INCLUDE_SEARCH_DIRS}=
")
>> message (STATUS "EXPAT_LIB_SEARCH_DIRS: ${EXPAT_LIB_SEARCH_DIRS}")
>> message (STATUS "EXPAT_BIN_SEARCH_DIRS: ${EXPAT_BIN_SEARCH_DIRS}")
>> message (STATUS "EXPAT_SEARCH_RELEASE_NAMES:
>> ${EXPAT_SEARCH_RELEASE_NAMES}")
>> message (STATUS "EXPAT_SEARCH_DEBUG_NAMES: ${EXPAT_SEARCH_DEBUG_NAMES}")
>> ENDIF (EXPAT_DEBUG)
>>
>> # Look for the library.
>> FIND_LIBRARY(EXPAT_LIBRARY_DEBUG
>> =A0NAMES ${EXPAT_SEARCH_DEBUG_NAMES}
>> =A0PATHS ${EXPAT_LIB_SEARCH_DIRS}
>> =A0NO_DEFAULT_PATH
>> =A0)
>>
>> FIND_LIBRARY(EXPAT_LIBRARY_RELEASE
>> =A0NAMES ${EXPAT_SEARCH_RELEASE_NAMES}
>> =A0PATHS ${EXPAT_LIB_SEARCH_DIRS}
>> =A0NO_DEFAULT_PATH
>> =A0)
>>
>> SET (EXPAT_XMLWF_PROG_NAME "xmlwf")
>> IF (WIN32)
>> =A0 =A0SET (EXPAT_XMLWF_PROG_NAME "xmlwf.exe")
>> ENDIF(WIN32)
>>
>> FIND_PROGRAM(EXPAT_XMLWF_PROG
>> =A0 =A0NAMES ${EXPAT_XMLWF_PROG_NAME}
>> =A0 =A0PATHS ${EXPAT_BIN_SEARCH_DIRS}
>> =A0 =A0NO_DEFAULT_PATH
>> )
>> MARK_AS_ADVANCED(EXPAT_XMLWF_PROG)
>>
>> IF (EXPAT_DEBUG)
>> MESSAGE(STATUS "EXPAT_INCLUDE_DIR: ${EXPAT_INCLUDE_DIR}")
>> MESSAGE(STATUS "EXPAT_LIBRARY_DEBUG: ${EXPAT_LIBRARY_DEBUG}")
>> MESSAGE(STATUS "EXPAT_LIBRARY_RELEASE: ${EXPAT_LIBRARY_RELEASE}")
>> MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
>> endif(EXPAT_DEBUG)
>>
>> ADJUST_LIB_VARS(EXPAT)
>>
>> # MESSAGE( STATUS "EXPAT_LIBRARY: ${EXPAT_LIBRARY}")
>>
>> # Copy the results to the output variables.
>> IF(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
>> =A0SET(EXPAT_FOUND 1)
>> =A0SET(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
>> =A0SET(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
>> =A0IF (EXPAT_LIBRARY_DEBUG)
>> =A0 =A0GET_FILENAME_COMPONENT(EXPAT_LIBRARY_PATH ${EXPAT_LIBRARY_DEBUG} =
PATH)
>> =A0 =A0SET(EXPAT_LIB_DIR =A0${EXPAT_LIBRARY_PATH})
>> =A0ELSEIF(EXPAT_LIBRARY_RELEASE)
>> =A0 =A0GET_FILENAME_COMPONENT(EXPAT_LIBRARY_PATH ${EXPAT_LIBRARY_RELEASE=
}
>> PATH)
>> =A0 =A0SET(EXPAT_LIB_DIR =A0${EXPAT_LIBRARY_PATH})
>> =A0ENDIF(EXPAT_LIBRARY_DEBUG)
>>
>> =A0IF (EXPAT_XMLWF_PROG)
>> =A0 =A0GET_FILENAME_COMPONENT(EXPAT_BIN_PATH ${EXPAT_XMLWF_PROG} PATH)
>> =A0 =A0SET(EXPAT_BIN_DIR =A0${EXPAT_BIN_PATH})
>> =A0ENDIF (EXPAT_XMLWF_PROG)
>>
>> ELSE(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
>> =A0SET(EXPAT_FOUND 0)
>> =A0SET(EXPAT_LIBRARIES)
>> =A0SET(EXPAT_INCLUDE_DIRS)
>> ENDIF(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
>>
>> # Report the results.
>> IF(NOT EXPAT_FOUND)
>> =A0SET(EXPAT_DIR_MESSAGE
>> =A0 =A0"EXPAT was not found. Make sure EXPAT_LIBRARY and
>> EXPAT_INCLUDE_DIR are set or set the EXPAT_INSTALL environment
>> variable.")
>> =A0IF(NOT EXPAT_FIND_QUIETLY)
>> =A0 =A0MESSAGE(STATUS "${EXPAT_DIR_MESSAGE}")
>> =A0ELSE(NOT EXPAT_FIND_QUIETLY)
>> =A0 =A0IF(EXPAT_FIND_REQUIRED)
>> =A0 =A0 =A0# MESSAGE(FATAL_ERROR "${EXPAT_DIR_MESSAGE}")
>> =A0 =A0 =A0MESSAGE(FATAL_ERROR "Expat was NOT found and is Required by t=
his
>> project")
>> =A0 =A0ENDIF(EXPAT_FIND_REQUIRED)
>> =A0ENDIF(NOT EXPAT_FIND_QUIETLY)
>> ENDIF(NOT EXPAT_FOUND)
>>
>>
>> IF (EXPAT_FOUND)
>> =A0INCLUDE(CheckSymbolExists)
>> =A0#############################################
>> =A0# Find out if EXPAT was build using dll's
>> =A0#############################################
>> =A0# Save required variable
>> =A0SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
>> =A0SET(CMAKE_REQUIRED_FLAGS_SAVE =A0 =A0${CMAKE_REQUIRED_FLAGS})
>> =A0# Add EXPAT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
>> =A0SET(CMAKE_REQUIRED_INCLUDES
>> "${CMAKE_REQUIRED_INCLUDES};${EXPAT_INCLUDE_DIRS}")
>>
>> =A0CHECK_SYMBOL_EXISTS(EXPAT_BUILT_AS_DYNAMIC_LIB "expat_config.h"
>> HAVE_EXPAT_DLL)
>>
>> =A0 =A0IF (HAVE_EXPAT_DLL STREQUAL "TRUE")
>> =A0 =A0 =A0 =A0SET (HAVE_EXPAT_DLL "1")
>> =A0 =A0ENDIF (HAVE_EXPAT_DLL STREQUAL "TRUE")
>>
>> =A0# Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
>> =A0SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
>> =A0SET(CMAKE_REQUIRED_FLAGS =A0 =A0${CMAKE_REQUIRED_FLAGS_SAVE})
>> =A0#
>> =A0#############################################
>>
>> ENDIF (EXPAT_FOUND)
>>
>> ------8<------------------------------------------------
>>
>>
>> _________________________________________________________
>> Mike Jackson =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mike.jackson at bluequartz.=
net
>> BlueQuartz Software =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0www.bluequart=
z.net
>> Principal Software Engineer =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Dayton, O=
hio
>>
>>
>>
>> On Tue, Feb 9, 2010 at 7:10 AM, Luigi Calori <l.calori at cineca.it> wrote:
>>
>>>
>>> Is there a way to instruct FindXXX modules to produce variables that ha=
ve
>>> different linking in debug and release?
>>>
>>> I am producind a lib with suffix D (zlib) in an =A0ExternalProjetAdd,
>>> target.It gets installed correctly in debug (which is the default for V=
S
>>> cmake--build)
>>> This zlibD.lib does not get found when other projects subsequently issu=
es
>>> a
>>> find_package(ZLIB )
>>>
>>> Are there Find modules that supports debug/release?
>>>
>>> Any example of this usage pattern?
>>>
>>> Thanks
>>>
>>> Luigi
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>>
>>>
>>
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
More information about the CMake
mailing list