[CMake] Question about install()
Michael Jackson
mike.jackson at bluequartz.net
Mon Dec 8 12:09:41 EST 2008
On Dec 8, 2008, at 11:49 AM, Hendrik Sattler wrote:
> Robert Dailey schrieb:
>> This makes absolutely no sense to me. To copy "all relevant files",
>> I have
>> to know their name. To know their name, I need to know the platform
>> and the
>> build configuration, since as I said before the names are different
>> in both
>> cases.
>
> How do you link against them if you do not know the name? Do you use
> that special auto-linking feature of MSVC?
>
>> I don't think you understand. I have no control over the names of
>> the shared
>> libraries, since I am using third party libraries, such as boost.
>
> Well, it's obvious that boost library naming sucks a lot. I know that
> you cannot do anything about that.
>
>> For
>> example, in debug I need to use boost_filesystem-mt-gd.dll, and in
>> release I
>> use boost_filesystem-mt.dll. On Linux debug & release, the suffix
>> will
>> probably .so instead of .dll. I cannot debug my applications unless
>> the DLL
>> files can be copied to the location of the executable.
>
> Again, how do you link against those libraries?
>
> HS
Someone created some cmake code to do just this exact thing earlier
this year. I have been trying to hunt it down in the archives but just
keep coming up empty. I have some code for an "install" rule. You
could put that code in a separate cmake file, configure the file
during cmake time, and then run it as a process.
Here is some code that I use for an actual "install".
MACRO (MXA_INSTALL_SUPPORT_LIBRARY basename)
IF (HAVE_${basename}_DLL)
IF (WIN32)
GET_FILENAME_COMPONENT(${basename}_LIB_DEBUG_NAME ${$
{basename}_LIBRARY_DEBUG} NAME_WE)
GET_FILENAME_COMPONENT(${basename}_LIB_RELEASE_NAME ${$
{basename}_LIBRARY_RELEASE} NAME_WE)
INSTALL(FILES ${${basename}_BIN_DIR}/${$
{basename}_LIB_DEBUG_NAME}.dll
DESTINATION bin
CONFIGURATIONS Debug
COMPONENT Runtime)
INSTALL(FILES ${${basename}_BIN_DIR}/${$
{basename}_LIB_RELEASE_NAME}.dll
DESTINATION bin
CONFIGURATIONS Release
COMPONENT Runtime)
ENDIF (WIN32)
ENDIF (HAVE_${basename}_DLL)
ENDMACRO(MXA_INSTALL_SUPPORT_LIBRARY basename)
#-- Install the support libraries if needed
IF ( MXA_USE_HDF5 )
MXA_INSTALL_SUPPORT_LIBRARY(HDF5)
ENDIF ( MXA_USE_HDF5 )
This assumes that the library you are trying to copy has CMake
variables of the form ${basename}_LIB_DEBUG_NAME which boost does.
For instance in my project that I use boost, I have the some boost
variables of the type:
Boost_FILESYSTEM_LIBRARY_DEBUG
Boost_FILESYSTEM_LIBRARY_RELEASE
Those variables will hold the correct name for each platform that you
are compiling on. You could try replacing the INSTALL(.. ) command
with some commands to copy the files.
_________________________________________________________
Mike Jackson mike.jackson at bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
More information about the CMake
mailing list