Hi Mike, I'm in a similar boat: I would like to build, via CMake and ExternalProjectAdd, some of the deps needed by OpenSceneGraph pluging (runtime loaded dlls). I currently have almost managed to build zlib,png,jpeg,freetype,curl
under windows MSVC9 and had tried also linux, with partial success.
Even with this so simple setup, happens that png depends on zlib, so zlib builds first, then the png cmake can find it if you specify the CMAKE_PREFIX_PATH and CMAKE_INSTALL_PREFIX as a common install prefix.
If building first on debug, the findZLIB fail.
It seem to me not so uncommon setup, as, at least for OSG, all the dep libs are provided in debug and release version by appending D
(or d)
Are you using ExternalProject ?  are you building tiff with cmake?
If your project is open, would be really helpful to get pointers.
Anyway, I' ll try to apply your suggestion and see how it goes. It seem to me anyway a worth improvement over standard Find.

Thanks again

Luigi


Mike Jackson wrote:
>From my own experience there are very few projects that can be
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.jack...@bluequartz.net

On Tue, Feb 9, 2010 at 8:40 AM, Luigi Calori <l.cal...@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 CMake:
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.
#
#  EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
#  EXPAT_LIBRARIES    - List of libraries when using expat.
#  EXPAT_LIBRARY_DEBUG - Debug version of Library
#  EXPAT_LIBRARY_RELEASE - Release Version of Library
#  EXPAT_FOUND        - 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)
 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 (ADJUST_LIB_VARS)





# Look for the header file.

# MESSAGE (STATUS "Finding expat library and headers..." )
SET (EXPAT_DEBUG 0)

SET(EXPAT_INCLUDE_SEARCH_DIRS
 $ENV{EXPAT_INSTALL}/include
)

SET (EXPAT_LIB_SEARCH_DIRS
 $ENV{EXPAT_INSTALL}/lib
 )

SET (EXPAT_BIN_SEARCH_DIRS
 $ENV{EXPAT_INSTALL}/bin
)

FIND_PATH(EXPAT_INCLUDE_DIR
 NAMES expat.h
 PATHS ${EXPAT_INCLUDE_SEARCH_DIRS}
 NO_DEFAULT_PATH
)

IF (WIN32 AND NOT MINGW)
   SET (EXPAT_SEARCH_DEBUG_NAMES "expatdll_D;libexpat_D")
   SET (EXPAT_SEARCH_RELEASE_NAMES "expatdll;libexpat")
ELSE (WIN32 AND NOT MINGW)
   SET (EXPAT_SEARCH_DEBUG_NAMES "expat_debug")
   SET (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
 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
 )

SET (EXPAT_XMLWF_PROG_NAME "xmlwf")
IF (WIN32)
   SET (EXPAT_XMLWF_PROG_NAME "xmlwf.exe")
ENDIF(WIN32)

FIND_PROGRAM(EXPAT_XMLWF_PROG
   NAMES ${EXPAT_XMLWF_PROG_NAME}
   PATHS ${EXPAT_BIN_SEARCH_DIRS}
   NO_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)
 SET(EXPAT_FOUND 1)
 SET(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
 SET(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
 IF (EXPAT_LIBRARY_DEBUG)
   GET_FILENAME_COMPONENT(EXPAT_LIBRARY_PATH ${EXPAT_LIBRARY_DEBUG} PATH)
   SET(EXPAT_LIB_DIR  ${EXPAT_LIBRARY_PATH})
 ELSEIF(EXPAT_LIBRARY_RELEASE)
   GET_FILENAME_COMPONENT(EXPAT_LIBRARY_PATH ${EXPAT_LIBRARY_RELEASE}
PATH)
   SET(EXPAT_LIB_DIR  ${EXPAT_LIBRARY_PATH})
 ENDIF(EXPAT_LIBRARY_DEBUG)

 IF (EXPAT_XMLWF_PROG)
   GET_FILENAME_COMPONENT(EXPAT_BIN_PATH ${EXPAT_XMLWF_PROG} PATH)
   SET(EXPAT_BIN_DIR  ${EXPAT_BIN_PATH})
 ENDIF (EXPAT_XMLWF_PROG)

ELSE(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)
 SET(EXPAT_FOUND 0)
 SET(EXPAT_LIBRARIES)
 SET(EXPAT_INCLUDE_DIRS)
ENDIF(EXPAT_INCLUDE_DIR AND EXPAT_LIBRARY)

# Report the results.
IF(NOT EXPAT_FOUND)
 SET(EXPAT_DIR_MESSAGE
   "EXPAT was not found. Make sure EXPAT_LIBRARY and
EXPAT_INCLUDE_DIR are set or set the EXPAT_INSTALL environment
variable.")
 IF(NOT EXPAT_FIND_QUIETLY)
   MESSAGE(STATUS "${EXPAT_DIR_MESSAGE}")
 ELSE(NOT EXPAT_FIND_QUIETLY)
   IF(EXPAT_FIND_REQUIRED)
     # MESSAGE(FATAL_ERROR "${EXPAT_DIR_MESSAGE}")
     MESSAGE(FATAL_ERROR "Expat was NOT found and is Required by this
project")
   ENDIF(EXPAT_FIND_REQUIRED)
 ENDIF(NOT EXPAT_FIND_QUIETLY)
ENDIF(NOT EXPAT_FOUND)


IF (EXPAT_FOUND)
 INCLUDE(CheckSymbolExists)
 #############################################
 # Find out if EXPAT was build using dll's
 #############################################
 # Save required variable
 SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
 SET(CMAKE_REQUIRED_FLAGS_SAVE    ${CMAKE_REQUIRED_FLAGS})
 # Add EXPAT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
 SET(CMAKE_REQUIRED_INCLUDES
"${CMAKE_REQUIRED_INCLUDES};${EXPAT_INCLUDE_DIRS}")

 CHECK_SYMBOL_EXISTS(EXPAT_BUILT_AS_DYNAMIC_LIB "expat_config.h"
HAVE_EXPAT_DLL)

   IF (HAVE_EXPAT_DLL STREQUAL "TRUE")
       SET (HAVE_EXPAT_DLL "1")
   ENDIF (HAVE_EXPAT_DLL STREQUAL "TRUE")

 # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
 SET(CMAKE_REQUIRED_FLAGS    ${CMAKE_REQUIRED_FLAGS_SAVE})
 #
 #############################################

ENDIF (EXPAT_FOUND)

------8<------------------------------------------------


_________________________________________________________
Mike Jackson                  mike.jack...@bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Tue, Feb 9, 2010 at 7:10 AM, Luigi Calori <l.cal...@cineca.it> wrote:

Is there a way to instruct FindXXX modules to produce variables that have
different linking in debug and release?

I am producind a lib with suffix D (zlib) in an  ExternalProjetAdd,
target.It gets installed correctly in debug (which is the default for VS
cmake--build)
This zlibD.lib does not get found when other projects subsequently issues
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




_______________________________________________
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

Reply via email to