<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>I'm currently testing CMake 3.14.2's iOS support with our build
      system and ran into a problem with try_compile() not finding the
      binary. Here is an example while trying to configure libjpeg-turbo
      2.0.2 (I've shortened the paths to make this easier to read):<br>
    </p>
    <p>--- SNIP ---<br>
    </p>
    <p>-- Check size of size_t<br>
      CMake Error at share/cmake-3.14/Modules/CheckTypeSize.cmake:120
      (try_compile):<br>
        Cannot copy output executable<br>
      <br>
          ''<br>
      <br>
        to destination specified by COPY_FILE:<br>
      <br>
         
      'libjpegturbo_library-ext-build/CMakeFiles/CheckTypeSize/SIZE_T.bin'<br>
      <br>
        Unable to find the executable at any of:<br>
      <br>
          libjpegturbo_library-ext-build/CMakeFiles/CMakeTmp/cmTC_3f58e<br>
         
      libjpegturbo_library-ext-build/CMakeFiles/CMakeTmp/Debug/cmTC_3f58e<br>
         
libjpegturbo_library-ext-build/CMakeFiles/CMakeTmp/Debug/cmTC_3f58e.app/cmTC_3f58e<br>
         
libjpegturbo_library-ext-build/CMakeFiles/CMakeTmp/Development/cmTC_3f58e<br>
      <br>
      Call Stack (most recent call first):<br>
        share/cmake-3.14/Modules/CheckTypeSize.cmake:247
      (__check_type_size_impl)<br>
        CMakeLists.txt:362 (check_type_size)<br>
    </p>
    <p>--- SNIP ---</p>
    <p>The problem is that the binary created by try_compile is located
      at
      libjpegturbo_library-ext-build/CMakeFiles/CMakeTmp/cmTC_3f58e.app,
      where cmake doesn't look. This happens with both the Unix Makefile
      and Ninja generators (since I don't use the Xcode generator I have
      no idea if it works there). The following patch to cmake fixes the
      problem:</p>
    <p>--- SNIP ---</p>
    <p>diff -uNr cmake-3.14.2.orig/Source/cmCoreTryCompile.cxx
      cmake-3.14.2/Source/cmCoreTryCompile.cxx<br>
      --- cmake-3.14.2.orig/Source/cmCoreTryCompile.cxx    2019-04-12
      14:10:08.000000000 +0200<br>
      +++ cmake-3.14.2/Source/cmCoreTryCompile.cxx    2019-04-15
      14:54:32.466161185 +0200<br>
      @@ -1040,8 +1040,12 @@<br>
         }<br>
         searchDirs.emplace_back("/Debug");<br>
       #if defined(__APPLE__)<br>
      -  std::string app = "/Debug/" + targetName + ".app";<br>
      +  // When building for Darwin, iOS, etc., the test program may be
      an .app<br>
      +  // bundle, so look for those as well.<br>
      +  std::string app = "/" + targetName + ".app";<br>
         searchDirs.push_back(std::move(app));<br>
      +  std::string appd = "/Debug/" + targetName + ".app";<br>
      +  searchDirs.push_back(std::move(appd));<br>
       #endif<br>
         searchDirs.emplace_back("/Development");<br>
    </p>
    <p>--- SNIP ---<br>
    </p>
    <p>So my question - is this a bug in CMake (the documentation says
      the Xcode generator is recommended, so I presume the other
      generators do not receive as much testing for iOS targets), or I
      am doing something fundamentally wrong ?</p>
    With kind regards,<br>
    <p>Eric<br>
    </p>
    -- <br>
    <div class="moz-signature">
      <div style="width:480px; text-align: left; font-family: Arial,
        Helvetica, sans-serif;">
        <p style="color: #062d64; font-size: 14px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;"><b>
            Dr. Eric Dönges
          </b><br>
          Senior Software Engineer
        </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;">MVTec Software
          GmbH | Arnulfstr. 205 | 80634 Munich | Germany<br>
          <a style="font-size: 12px; font-family: Arial, Helvetica,
            sans-serif; color: #062d64;" href="mailto:doenges@mvtec.com">doenges@mvtec.com</a>
          | Tel: +49 89 457 695-0 | <a style="font-size: 12px;
            font-family: Arial, Helvetica, sans-serif; color: #062d64;"
            href="http://www.mvtec.com">www.mvtec.com</a>
        </p>
        <p style="color: #062d64; font-size: 12px; text-align: left;
          font-family: Arial, Helvetica, sans-serif;"><img
src="https://mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/newsletter-icon.png"
            valign="bottom" width="16" height="16"> <a style="font-size:
            12px; font-family: Arial, Helvetica, sans-serif; color:
            #062d64; font-weight: bold;"
            href="http://www.mvtec.com/newsletter">Sign up</a> for our
          MVTec Newsletter!</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;">Geschäftsführer:
          Dr. Wolfgang Eckstein, Dr. Olaf Munkelt<br>
          Amtsgericht München HRB 114695</p>
        <p style="margin: 0px; color: #666; font-size: 12px; text-align:
          left; font-family: Arial, Helvetica, sans-serif;"> </p>
        <img
src="https://www.mvtec.com/fileadmin/Redaktion/newsletter/mail-signature/mvtec-logo-line.png"
          alt="MVTec Software GmbH Logo"></div>
    </div>
  </body>
</html>