[cmake-developers] Need some pointers on learning the code

Clinton Stimpson clinton at elemtech.com
Mon May 13 15:02:01 EDT 2013


On Monday, May 13, 2013 12:55:39 PM Clinton Stimpson wrote:
> On Monday, May 13, 2013 02:30:32 PM Brad King wrote:
> > On 05/13/2013 02:07 PM, Robert Dailey wrote:
> > > Actually now that I think about this a littler closer, changing the
> > > generator expressions may not work for a specific case I'm blocked on.
> > > 
> > > I store my third party library binaries in a "debug" and "release"
> > > directories. I have a custom target that I define to copy the
> > > appropriate debug or release DLLs to the appropriate output
> > > directories, so that when I debug my applications, they find the
> > > appropriate DLLs in the same directory. So the copy mapping should be
> > > as follows:
> > > 
> > > debug -> Debug
> > > release -> Release
> > > release -> RelWithDebInfo
> > > release -> MinSizeRel
> > > 
> > > Specifically for the RELEASE case. I can't use $<CONFIGURATION> for
> > > the source directory, since the name is "release" between all 3
> > > release configurations. This case is easily solved with issue 9974,
> > > however. Any thoughts?
> > 
> > This looks like the common use case I explain here:
> >  http://www.cmake.org/Bug/view.php?id=9974#c29033
> > 
> > You don't need any new features for it.
> 
> To avoid the copy step, would it be useful to make generator expressions
> work in target properties?
> 
> set_target_properties(mylib PROPERTIES
>   LIBRARY_OUTPUT_DIRECTORY
> "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/lib")
> set_target_properties(myexe PROPERTIES
>   RUNTIME_OUTPUT_DIRECTORY
> "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/bin")
> 
> Currently, I can have more code than that to loop over
> CMAKE_CONFIGURATION_TYPES and set those properties myself, and it results in
> the libraries and executables being together without a copy step and
> without an extra config directory separating them.

Actually, I guess not, because for that to work I would have to set the 
LIBRARY_OUTPUT_DIRECTORY_* property instead.

So, I'm back to this:
set_target_properties(mylib PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
set_target_properties(myexe PROPERTIES
  RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")

foreach(config ${CMAKE_CONFIGURATION_TYPES})
  string(TOUPPER ${config} CONFIG)
  set_target_properties(mylib PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY_${CONFIG}
      "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin")
  set_target_properties(myexe PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_${CONFIG}
      "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin")
endforeach()

Clint




More information about the cmake-developers mailing list