On 3/26/10 5:22 AM, Michael Schildt wrote:

You don't generally need to use link-directories - if you're using
imported targets from a *Config.cmake file, the build type choice I
would imagine is automatic (?),
Yes, that is that the former guys wrote and it is really working this easy way now.

and if not you should be passing full
paths to the library files in target_link_libraries, where you can
specify using the debug, optimized, and general keywords.
For external lib not using cmake i will use something like

/TARGET_LINK_LIBRARIES( Project1 debug //F:/Extern////Lib1/Debug/test1.lib//
/    optimized //F:/Extern//Lib1/Release/test1.lib
    )
/

But i have not tested yet. i suggest to add this to the FAQ because i missed it there very much.

Ciao,
   Michael
Instead of hard-coding the paths in your CMakeLists.txt, I'd suggest using the find_library and find_path (for include_directories) to attempt to find the libraries in some area, and to allow the developer to change the library/include paths by editing a cache variable with the CMake GUI. At least to me, I code my CMakeLists files for all projects as if the project were open source and might be built by folks who had just installed the dependencies either a: in their default locations (where I want to auto-detect them), or b: in some strange location (if they configured a different install location, I want them to be able to configure the build of the project similarly.) As a result, I create Find*.cmake modules for every dependency that provide a WHATEVER_ROOT_DIR cache variable, used to generate appropriate paths to pass as "HINTS" to the find_library/path calls, that is not marked as advanced until the full library is found, as well as the individual _LIBRARY and _INCLUDE_DIR cache vars that are marked as advanced automatically in all cases. I've pasted an example below.

Ryan

---- FindVRPN.cmake ----

# - try to find VRPN library
#
# Cache Variables:
#  VRPN_LIBRARY
#  VRPN_SERVER_LIBRARY
#  VRPN_INCLUDE_DIR
#
# Non-cache variables you might use in your CMakeLists.txt:
#  VRPN_FOUND
#  VRPN_SERVER_LIBRARIES
#  VRPN_LIBRARIES
#  VRPN_INCLUDE_DIRS
#
# VRPN_ROOT_DIR is searched preferentially for these files
#
# Requires these CMake modules:
#  FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpav...@iastate.edu> <abir...@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC

set(VRPN_ROOT_DIR
    "${VRPN_ROOT_DIR}"
    CACHE
    PATH
    "Root directory to search for VRPN")

if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8")
    set(_libsuffixes lib64 lib)
else()
    set(_libsuffixes lib)
endif()

###
# Configure VRPN
###

find_path(VRPN_INCLUDE_DIR
    NAMES
    vrpn_Connection.h
    PATH_SUFFIXES
    include
    include/vrpn
    HINTS
    "${VRPN_ROOT_DIR}")

find_library(VRPN_LIBRARY
    NAMES
    vrpn
    PATH_SUFFIXES
    ${_libsuffixes}
    HINTS
    "${VRPN_ROOT_DIR}")

find_library(VRPN_SERVER_LIBRARY
    NAMES
    vrpnserver
    PATH_SUFFIXES
    ${_libsuffixes}
    HINTS
    "${VRPN_ROOT_DIR}")

###
# Dependencies
###
set(_deps_libs)
set(_deps_includes)
set(_deps_check)

find_package(quatlib)
list(APPEND _deps_libs ${QUATLIB_LIBRARIES})
list(APPEND _deps_includes ${QUATLIB_INCLUDE_DIRS})
list(APPEND _deps_check QUATLIB_FOUND)

if(NOT WIN32)
    find_package(Threads)
    list(APPEND _deps_libs ${CMAKE_THREAD_LIBS_INIT})
    list(APPEND _deps_check CMAKE_HAVE_THREADS_LIBRARY)
endif()


# handle the QUIETLY and REQUIRED arguments and set xxx_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VRPN
    DEFAULT_MSG
    VRPN_LIBRARY
    VRPN_INCLUDE_DIR
    ${_deps_check})

if(VRPN_FOUND)
    set(VRPN_INCLUDE_DIRS "${VRPN_INCLUDE_DIR}" ${_deps_includes})
    set(VRPN_LIBRARIES "${VRPN_LIBRARY}" ${_deps_libs})
    set(VRPN_SERVER_LIBRARIES "${VRPN_SERVER_LIBRARY}" ${_deps_libs})

    mark_as_advanced(VRPN_ROOT_DIR)
endif()

mark_as_advanced(VRPN_LIBRARY
    VRPN_SERVER_LIBRARY
    VRPN_INCLUDE_DIR)

--
Ryan Pavlik
Human-Computer Interaction Graduate Student
Virtual Reality Applications Center
Iowa State University

rpav...@iastate.edu
http://academic.cleardefinition.com/

_______________________________________________
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