[CMake] Modifying LIBRARY_OUTPUT_PATH dynamically in a macro

Filipe Sousa natros at gmail.com
Wed Jun 6 16:45:31 EDT 2007


you can use

SET_TARGET_PROPERTIES(${target}
  PROPERTIES LIBRARY_OUTPUT_DIRECTORY ...)

gga wrote:
> I'm trying to change the destination where some shared libraries are
> created, trying to place them in subdirectories.
> 
> I need to have a macro, which in turn will modify the
> LIBRARY_OUTPUT_PATH and create the new library in that new directory.  I
> have created such a beast.  The debug output spits out the path properly
> for LIBRARY_OUTPUT_PATH.
> 
> Unfortunately, this seems to not work.  I am only able to change the
> LIBRARY_OUTPUT_PATH in a new CMakeLists.txt file (ie. in a subdir), but
> I don't seem to be able to modify it from within a single CMakeLists.txt
> file and macro.  Cmake does not respect the change and just dumps the
> libraries in the previously defined LIBRARY_OUTPUT_PATH location.
> 
> # A simple macro to create a maya plugin.
> #
> # Usage is:
> #
> # CREATE_MAYA_PLUG_IN(
> #                      "mrLiquid" "0.7"
> #                      "test.cpp hello.cpp"
> #                      "OpenMaya OpenMayaAnim"
> #                     )
> #
> MACRO(CREATE_MAYA_PLUG_IN NAME VERSION SOURCES LIBRARIES)
> 
>   # define a bunch of maya variables
>   MAYA_DEFINITIONS()
> 
>   # split input name into a plugin name and any optional subdir
>   STRING( REGEX MATCH "[^/]+$" PLUGNAME "${NAME}" )
>   STRING( REGEX REPLACE "${PLUGNAME}$" "" ANYPATH "${NAME}" )
> 
>   # store output path
>   SET( OLD_LIBRARY_PATH ${LIBRARY_OUTPUT_PATH} )
> 
>   # make sure subdirs exist
>   FILE( MAKE_DIRECTORY
>       "${LIBRARY_OUTPUT_PATH}"
>       "${LIBRARY_OUTPUT_PATH}/maya${MAYA_VERSION}"
>       )
> 
>   # change output path
>   SET( LIBRARY_OUTPUT_PATH
>       "${LIBRARY_OUTPUT_PATH}/maya${MAYA_VERSION}/${ANYPATH}" )
> 
>   # make sure output directory exists
>   FILE( MAKE_DIRECTORY "${LIBRARY_OUTPUT_PATH}" )
> 
>   # debug the stuff
>   MESSAGE( STATUS "# Creating Maya${MAYA_VERSION} plug-in ${PLUGNAME} in
> ${LIBRARY_OUTPUT_PATH} #" )
> 
> 
>   # add the plugin
>   ADD_LIBRARY( ${PLUGNAME} SHARED ${SOURCES} )
>   TARGET_LINK_LIBRARIES( ${PLUGNAME} ${LIBRARIES} )
> 
>   # get old link flags
>   GET_TARGET_PROPERTY( OLD_FLAGS "${PLUGNAME}" LINK_FLAGS )
>   IF( NOT OLD_FLAGS )
>     SET( OLD_FLAGS "" )
>   ENDIF( NOT OLD_FLAGS )
> 
>   # change properties
>   SET_TARGET_PROPERTIES(
>       "${PLUGNAME}"
>       PROPERTIES
>       PREFIX     ""
>       SUFFIX     "${MAYA_EXTENSION}"
>       VERSION    "${VERSION}"
>       SOVERSION  "${VERSION}"
>       LINK_FLAGS "${MAYA_LINK_FLAGS} ${OLD_FLAGS}"
>       )
> 
>   # revert output directory
>   SET( LIBRARY_OUTPUT_PATH ${OLD_LIBRARY_PATH} )
> 
> ENDMACRO(CREATE_MAYA_PLUG_IN)
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://public.kitware.com/pipermail/cmake/attachments/20070606/035a2925/signature.pgp


More information about the CMake mailing list