[CMake] externalproject_add install_dir doesn't work

J Decker d3ck0r at gmail.com
Sun Oct 22 09:38:23 EDT 2017


A smiple cmakelists like this.  Without specifying the CMAKE_ARGS
CMAKE_INSTALL_PREFIX this tries to install into c:\program files.

-----
cmake_minimum_required(VERSION 3.6)

include( ExternalProject )

ExternalProject_Add( external
PREFIX ${CMAKE_BINARY_DIR}/tmpout
           SOURCE_DIR ${CMAKE_SOURCE_DIR}/extern
           INSTALL_DIR ${CMAKE_BINARY_DIR}/output
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/output

)

---- ./extern/cmakelists.txt
cmake_minimum_required(VERSION 3.6)

INSTALL( FILES tmp.bat DESTINATION data )

--------

I was trying to figure out why the install is failing on another project,
it says (using vs 2015 generator)

MSBUILD : error MSB1009: Project file does not exist.
[M:\javascript\vfs\native\build\sack.vcxproj]
  Switch: install

in which the rule that runs
C:\tools\unix\cmake\bin\cmake.exe --build . --config Debug --target install

is failling... to work it would have to be INSTALL.

but my simple case isn't causing the same failure

----
Been tinkering with this for a couple hours trying to make the example more
close to the full case, but cannot; if I edit the rule and make the
'--target INSTALL'  then it works in the actual case... although the same
thing works fine in the simplified example....


--------
Line 1766 of ExternalProject in latest cmake download
        list(APPEND args --target install)

should(could) be

        if( MSVC )
        list(APPEND args --target INSTALL)
        else( MSVC )
        list(APPEND args --target install)
        endif( MSVC )


which fixes my issue.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171022/f1bfd4d9/attachment.html>


More information about the CMake mailing list