[CMake] Current binary directory confusion

J Decker d3ck0r at gmail.com
Thu Jun 21 18:34:41 EDT 2012


On Thu, Jun 21, 2012 at 11:33 AM, Yuri Timenkov <yuri at timenkov.ru> wrote:
> Is it strict requirement? Can't you just add your .rc files as source
> file to your target or just add target name as part of file name? This
> way they can be put everywhere, including current binary dir. I use
> this for adding version information to binaries.

I do the same things, but I configure C files to .CPP files, but just
have a directory structure in the CMAKE_BINARY_DIR to put them... most
compile systems don't care if it's in a specific location, and cmake
will end up referencing it by full pathname where it was.  But... so
you can probably continue to use that temporary dir, and if another
build system doesn't use it, it'll still be there....

>
> Otherwise you may try to use post-build steps
> (http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:add_custom_command)
> to put your file in right place (e.g. create in current binary dir and
> then use ${CMAKE_COMMAND} -E copy_if_different).
>
> On Thu, Jun 21, 2012 at 10:06 PM, Robert Dailey
> <rcdailey.lists at gmail.com> wrote:
>> This is becoming a challenge :-)
>>
>> I'm generating .RC files using configure_file() in my CMake script. Since I
>> can have multiple targets defined in the same directory, and the resource
>> file generated for each target has the same name, I need them to be placed
>> in the <target_name>.dir directory inside of CMAKE_CURRENT_BINARY_DIR. Right
>> now I hard-code the path:
>>
>> set( output_dir "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.dir" )
>>
>>
>> On Thu, Jun 21, 2012 at 11:46 AM, J Decker <d3ck0r at gmail.com> wrote:
>>>
>>> On Thu, Jun 21, 2012 at 9:26 AM, Robert Dailey <rcdailey.lists at gmail.com>
>>> wrote:
>>> > You're totally confused. I'm not looking to work around a problem, I
>>> > just
>>> > want information from CMake that I know it has. Somewhere it knows
>>> > exactly
>>> > where binaries will be placed (those binaries that get compiled) because
>>> > it
>>> > has to generate the scripts and visual studio projects with those paths
>>> > inside.
>>> >
>>> > CMake is generating resource files that must be placed in these
>>> > directories
>>> > and are later included in the targets to be compiled, so I need to know
>>> > this
>>> > directory so that no matter what generator I'm using, the resource file
>>> > will
>>> > always be copied to the proper location.
>>> >
>>>
>>> that's didn't help a lot :)   what sort of resource files do you mean?
>>>  Watcom .rc handling isn't great for instance, and I have custom rules
>>> to generate the .res output, but then I just specify that output.
>>>
>>> >
>>> > On Thu, Jun 21, 2012 at 11:07 AM, J Decker <d3ck0r at gmail.com> wrote:
>>> >>
>>> >> On Thu, Jun 21, 2012 at 8:58 AM, Robert Dailey
>>> >> <rcdailey.lists at gmail.com>
>>> >> wrote:
>>> >> > So how do I get the absolute path to this directory in a portable
>>> >> > (between
>>> >> > generators) way?
>>> >> >
>>> >> >
>>> >>
>>> >> Well, what is it you want from there?  I generate INSTALL commands to
>>> >> put the outputs where I want them and let them worry about where the
>>> >> files are?
>>> >>
>>> >> > On Thu, Jun 21, 2012 at 9:03 AM, J Decker <d3ck0r at gmail.com> wrote:
>>> >> >>
>>> >> >> On Wed, Jun 20, 2012 at 12:08 PM, Robert Dailey
>>> >> >> <rcdailey.lists at gmail.com> wrote:
>>> >> >> > ${CMAKE_CURRENT_BINARY_DIR} returns a directory that contains
>>> >> >> > generated
>>> >> >> > files, such as vcproj files when generating for visual studio.
>>> >> >> > However,
>>> >> >> > actual compiled binaries are placed:
>>> >> >> >
>>> >> >> > ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.dir/Debug (for debug
>>> >> >> > configuration)
>>> >> >> >
>>> >> >> > Is there a variable or target property that will give me the
>>> >> >> > following
>>> >> >> > path
>>> >> >> > for any target:
>>> >> >> >
>>> >> >> > ${CMAKE_CURRENT_BINARY_DIR}/${target_name}.dir
>>> >> >> >
>>> >> >> > (I don't care about debug/release being part of the path, I just
>>> >> >> > want
>>> >> >> > the
>>> >> >> > "target.dir" part to be included in the path. Right now I'm
>>> >> >> > hard-coding
>>> >> >> > the
>>> >> >> > ".dir" directory and appending it to my path, but I don't know if
>>> >> >> > this
>>> >> >> > naming scheme is guaranteed by CMake or if it will change in the
>>> >> >> > future.
>>> >> >> >
>>> >> >> it differs from generator to generator
>>> >> >>
>>> >> >> > --
>>> >> >> >
>>> >> >> > 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
>>> >> >
>>> >> >
>>> >
>>> >
>>
>>
>>
>> --
>>
>> 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


More information about the CMake mailing list