[CMake] Why is cmake deleting my files?

J Decker d3ck0r at gmail.com
Fri Aug 5 16:35:02 EDT 2016


On Fri, Aug 5, 2016 at 12:46 PM, J Decker <d3ck0r at gmail.com> wrote:

>
>
> On Fri, Aug 5, 2016 at 11:59 AM, J Decker <d3ck0r at gmail.com> wrote:
>
>> I'm using "MinGW Makefiles" as a generator...
>>
>>
>> When I change a cmakelists.txt file, a bunch of sources I specify to copy
>> from /.../.c to ${CMAKE_BINARY_DIR}/.../.cpp get deleted in binary by cmake.
>>
>> There are no rules in the makefiles for those files to depend on anything
>> other than the original .c file, so I was really confused why they kept
>> getting regenerated... I started to pay attention and found that cmake,
>> during configure, if a cmakeLists.txt changes goes through and deletes all
>> those files.
>>
>>
>> add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/${BASENAME}${FILEEXT}
>>                               DEPENDS ${SOURCE}
>>                               COMMAND ${CMAKE_COMMAND} -E
>> copy_if_different ${SOURCE} ${CMAKE_BINARY_DIR}/${BASENAME}${FILEEXT}
>>                               )
>>
>>
>> all outputs get deleted?
>>
> The file is opened with CreateFile, then
>
> SetDispositionInformationFile \Device\HarddiskVolume15\
> mingw64-x86\sack-r\release_solution\core\src\utils\
> deploy\CMakeFiles\sack_deploy.dir\DependInfo.cmake.tmp SUCCESS Delete:
> True
>
> so when the file is closed it's deleted...
>
> Seems to be set from __archive_mktemp(const char *tmpdir)  passing
> FILE_FLAG_DELETE_ON_CLOSE; but my files aren't temporary....
> that's the only thing that seems to set that flag....
>
> ---------
> trying to make a simple case; but it's not doing it.
>

----------
in the simple case, modifying the COMMANDs in  add_custom_command() deletes
the output file; I can understand that....
In the complex case, I'm modifying a CMakeLists.txt which doesn't have any
bearing on the commands applied to the sources or the other libraries using
those sources; but it's still deleting them.

In the root CMakeLists.txt, I setup the list of sources for the main
project 'bag' and then for each of those sources copy them to
${CMAKE_BINARY_DIR}/original/path/to/source/file[s/.c/.cpp/] and add
another library 'bag++' with those sources.  I then include a bunch of
various subdirectories, one of which I'm currently working in, and while
that references the original C source names in the original tree, it
doesn't reference any of the C++ sources...  or even the built libraries;
it's a target that links from all the original sources directly; with a
different path than originally specified even  (original paths would be
like add_library( bag M:/sack/src/memlib/sharemem.c .... ) where the paths
used in thie project would be add_exeutable( something
"../../../../../src/memlib/sharemem.c" )



It's also different whether I do 'make' which ends up trigger the cmake
generation which doesn't delete the files.   if I just call 'cmake .' the
files do get deleted.  no that's not it either... this time after the build
finished I re-saved the cmakelists that I've been working on with no
changes, and the files all copied again running with just 'make'

I dunno maybe I'm using some common variable like MORE_SOURCES or
EXTRA_SOURCES or something that's somehow related inadvertantly
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160805/85e8a8d8/attachment.html>


More information about the CMake mailing list