[CMake] find_library not using CMAKE_LIBRARY_ARCHITECTURE on Windows
Mike
too.cheesy at gmail.com
Tue Jan 22 15:53:26 EST 2013
For the MSVC builds of my project, I have pre-built libraries set up
with the following layout:
ext/
libname/
include/
lib/
vc90/
vc100/
vc110/
libname-config.cmake
libname-config-version.cmake
And so on. It seemed like a good way to go, to build my own *-config
scripts and set things up in this way. To make finding the libraries
easier, I could set CMAKE_LIBRARY_ARCHITECTURE to the relevant suffix
and use find_library(), but that is not working exactly right.
Right now the script is something like this:
if (MSVC)
math(EXPR msvcver "${MSVC_VERSION} / 10 - 60")
set(CMAKE_LIBRARY_ARCHITECTURE "vc{$msvcver}")
find_package(libname REQUIRED CONFIG HINTS ${root}/ext/libname)
endif ()
And in libname-config.cmake:
if (NOT TARGET libname)
add_library(libname STATIC IMPORTED)
find_library(libname_LIBRARY_RELEASE libname HINTS ${libname_DIR}/lib)
find_library(libname_LIBRARY_DEBUG libnamed HINTS ${libname_DIR}/lib)
set_target_properties(libname PROPERTIES
IMPORTED_LOCATION ${libname_LIBRARY_RELEASE}
IMPORTED_LOCATION_DEBUG ${libname_LIBRARY_DEBUG})
endif ()
End result: libname_LIBRARY_RELEASE-NOTFOUND and
libname_LIBRARY_DEBUG-NOTFOUND. If use PATH_SUFFIXES though:
find_library(libname_LIBRARY_RELEASE libname HINTS
${libname_DIR}/lib PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE})
find_library(libname_LIBRARY_DEBUG libnamed HINTS ${libname_DIR}/lib
PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE})
.. it works as the doc suggests to me it should work without the PATH_SUFFIXES.
Am I making a false assumption, or doing something wrong?
Also as a general comment, I'm not too keen on adding all that junk
(libname_LIBRARY_RELEASE, etc.) to my cache as paths are pretty well
locked in. Updates to the version in the depot could cause problems
requiring a cache clean. Is there a better practice for getting paths
to libraries? Should I perhaps be just hand-coding it in, or
determining the architecture suffix in each -config.cmake script?
Thanks!
More information about the CMake
mailing list