Hello all<br><br>I want to make my target dependent on existing non source file on disk.<br>So far I have the following :<br><br>SET_SOURCE_FILES_PROPERTIES(main.cpp OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/myfile.txt)<br>ADD_EXECUTABLE(MyTarget main.cpp)<br>
<br>But the this does NOT work, if I touch myfile.txt MyTarget is not rebuild.<br><br><br>I was searching the posts and I found that this can be solved with something like this :<br><br>add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp <br>
COMMAND echo "/* this file is empty */" > ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp <br> DEPENDS ${CMAKE_SOURCE_DIR}/myfile.txt )<br><br>add_executable(MyTarget main.cpp ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp )<br>
<br>But this solution is not the most elegant becauseit requires generating of dummy file which need to be added as input to add_executable. <br><br>Also the following works : <br><br>add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp <br>
COMMAND echo "/* this file is empty */" > ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp <br>
DEPENDS ${CMAKE_SOURCE_DIR}/myfile.txt )<br><br>add_custom_target(CustomTarget ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)<br><br>add_dependencies(MyTarget CustomTarget)<br><br>But again this creates new target which shows up in my Visual Studio solution.<br>
<br>So I found the first code with OBJECT_DEPENDS most acceptable. Can someone through light on this and say why it does not works? What I am doing wrong?<br><br>Thanks for the help<br><br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 12"><meta name="Originator" content="Microsoft Word 12"><link rel="File-List" href="file:///C:%5CUsers%5CNikola%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_filelist.xml"><link rel="themeData" href="file:///C:%5CUsers%5CNikola%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_themedata.thmx"><link rel="colorSchemeMapping" href="file:///C:%5CUsers%5CNikola%5CAppData%5CLocal%5CTemp%5Cmsohtmlclip1%5C01%5Cclip_colorschememapping.xml"><style>
<!--
/* Font Definitions */
@font-face
        {font-family:PMingLiU;
        panose-1:2 2 5 0 0 0 0 0 0 0;
        mso-font-alt:新細明體;
        mso-font-charset:136;
        mso-generic-font-family:roman;
        mso-font-pitch:variable;
        mso-font-signature:-1610611969 684719354 22 0 1048577 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;
        mso-font-charset:204;
        mso-generic-font-family:roman;
        mso-font-pitch:variable;
        mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;
        mso-font-charset:204;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
        {font-family:"\@PMingLiU";
        panose-1:2 2 5 0 0 0 0 0 0 0;
        mso-font-charset:136;
        mso-generic-font-family:roman;
        mso-font-pitch:variable;
        mso-font-signature:-1610611969 684719354 22 0 1048577 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-unhide:no;
        mso-style-qformat:yes;
        mso-style-parent:"";
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:10.0pt;
        margin-left:0cm;
        line-height:115%;
        mso-pagination:widow-orphan;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-ascii-font-family:Calibri;
        mso-ascii-theme-font:minor-latin;
        mso-fareast-font-family:PMingLiU;
        mso-fareast-theme-font:minor-fareast;
        mso-hansi-font-family:Calibri;
        mso-hansi-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;
        mso-fareast-language:ZH-CN;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-default-props:yes;
        mso-ascii-font-family:Calibri;
        mso-ascii-theme-font:minor-latin;
        mso-fareast-font-family:PMingLiU;
        mso-fareast-theme-font:minor-fareast;
        mso-hansi-font-family:Calibri;
        mso-hansi-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;
        mso-fareast-language:ZH-CN;}
.MsoPapDefault
        {mso-style-type:export-only;
        margin-bottom:10.0pt;
        line-height:115%;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;
        mso-header-margin:36.0pt;
        mso-footer-margin:36.0pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style><p class="MsoNormal"><span style=""><br></span></p>
<br><br>