[CMake] Calling NMake from CMake

David Cole david.cole at kitware.com
Thu Aug 23 14:25:29 EDT 2012


I use a technique like this:

  configure_file(input ${CMAKE_CURRENT_BINARY_DIR}/proj-CMakeLists.txt
@ONLY)
    # or maybe COPYONLY instead of @ONLY if you have no replacements
occurring

  ExternalProject_Add(proj
    URL http://blah/blah/blah.tar.gz
    URL_MD5 md5-ofcourse
    PATCH_COMMAND ${CMAKE_COMMAND} -E copy
      ${CMAKE_CURRENT_BINARY_DIR}/proj-CMakeLists.txt
      <SOURCE_DIR>/CMakeLists.txt
    ...
  )

That should work if your "proj" source comes from a .tar.gz file without a
CMakeLists file in it, or with a CMakeLists.txt file that you want to
overwrite with your own.

Let me know if you run into problems with it.

On Thu, Aug 23, 2012 at 2:16 PM, Brian Davis <bitminer at gmail.com> wrote:

> Thanks for the response on this, I was able to get this to work (to
> degrees) with libtiff and Jasper as well as other non CMake-a-fied
> projects.  I have run into another issue where I wish to use configure_file
> to generate a CMakeLists.txt file in the directory where
> ExternalProject_add dumps the source and looks for the CMakeLists.txt
> file.
>
> The problem is that I cannot configure_file at CMakeLists.txt.config file
> into a CMakeLists.txt file in the source directory where
> ExternalProject_Add will later look for it as ExternalProject_Add removes
> the file and generates the error:
>
> CMake Error: The source directory
> "D:/projects/glade/branches/glade_win_x64/source/libtiff" does not appear
> to contain CMakeLists.txt.
>
> Clicking the Generate button in CMake creates the CMakeLists.txt file and
> the ExternalProject_Add works just fine, but requires going back and
> clicking generate in CMake
>
> I think my options are currently to run patch (not as powerful as
> configure_file) using PATCH_COMMAND which as I recall is not in on Win
> boxes and for which I have used GNUWin32 or possibly the
> CONFIGURE_COMMAND.  Maybe I should recursively call CMake to configure_file
> the CMakeLists.txt file?
>
> Thanks,
>
> Brian
>
>
> On Sun, Jun 17, 2012 at 2:10 PM, David Cole <david.cole at kitware.com>wrote:
>
>> You could use:
>>
>>   BUILD_COMMAND nmake /f makefile.vc
>>   BUILD_IN_SOURCE 1
>>
>> in your ExternalProject_Add call.
>>
>> "nmake" is already available from within the Visual Studio environment.
>>
>> Of course, if your project is cross-platform, you'll have to
>> conditionalize this so that it only happens when using a Visual Studio or
>> NMake generator.
>>
>>
>> HTH,
>> David
>>
>>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120823/011e51d6/attachment.htm>


More information about the CMake mailing list