<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo;
        panose-1:2 11 6 9 3 8 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt">Let's say I have a simple CMakeLists.txt:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">cmake_minimum_required(VERSION 3.11)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">project(foo C)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">add_subdirectory(foo)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">foo/CMakeLists.txt looks like:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">add_library(foo SHARED foo.c)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">set_target_properties(foo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">                      PROPERTIES<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">                      FRAMEWORK ON<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">                      FRAMEWORK_VERSION A)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">install(TARGETS foo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">        FRAMEWORK DESTINATION Frameworks)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">add_custom_target(install-foo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">                  DEPENDS foo<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Menlo">                  COMMAND echo "Installing")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">An actual useful install-foo target would do something along the lines of `cmake -P cmake_install.cmake`, but we don't need that to demonstrate the issue. foo.c is also irrelevant; it could even be empty.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">With CMake 3.11.4 and when using the Ninja generator, my custom install-foo target ends up transitively depending on "foo/foo.framework/foo", which doesn't exist and causes a build error. There is a "foo.framework/foo"
 target, which is just a phony target depending on "foo/foo.framework/Versions/A/foo" (which is the actual library), and I suspect that's the actual desired dependency, but instead, the subdirectory is being incorrectly prepended to the dependency name.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">This works correctly when using the Makefile generator instead of the Ninja generator. It works with the Ninja generator if my framework target is in the top-level CMakeLists.txt instead of a subdirectory,
 but that's not a viable workaround for my use case.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Am I doing something wrong, or is this a bug with CMake's Ninja generator? If it's the latter, any thoughts on how to work around it? I suppose I could try to manually create the "foo/foo.framework/foo" target,
 but that seems kinda gross.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt">Shoaib Meenai<o:p></o:p></span></p>
</div>
</body>
</html>