[CMake] Adding external executable

Manoj Vaghela manoj.vaghela at gmail.com
Fri Nov 9 03:49:35 EST 2012


Dear Eric,

Thanks for your reply.

When I am using INSTALL (FILES... ) for adding external executable to my
CMakeLists.txt file, it shows the executable file in the RPM archive. But
it's execute permission is lost. What should I have to do for that?

Also, ADD_EXECUTABLE( ... IMPORTED) did not work for me. I added this line
but when archive is created, it did not include my executable in it.

This is sample of my CMakeLists.txt
-----------------------------------------------

SET( CPACK_GENERATOR "RPM" )

##### MAIN EXE
SET( MAIN_EXE myExe)
ADD_EXECUTABLE(${MAIN_EXE} SOME_SOURCE_FILES )
SET( INSTALL_DIR "$ENV{HOME}/MANOJ" )
INSTALL( TARGETS ${MAIN_EXEC} DESTINATION ${INSTALL_DIR} )

##### EXTERNAL EXE
SET( EXTERNAL_EXE "/home/manoj/EXTERNAL/a.out.exe" )
SET( IMPORTED_LOCATION ${EXTERNAL_EXE} )
ADD_EXECUTABLE( ${EXTERNAL_EXE} IMPORTED) // This does not pack the
executable

#INSTALL( FILES ${EXTERNAL_EXE} DESTINATION ${INSTALL_DIR}) // This packs,
but permissions lost

##### EXTERNAL LIB
INSTALL( FILES EXTERNAL_LIB DESTINATION ${INSTALL_DIR} )

INCLUDE(CPack)

Can you please tell me what is the error in this file?
Thanks..

--
regards,
Manoj


On Fri, Nov 9, 2012 at 1:18 PM, Eric Noulard <eric.noulard at gmail.com> wrote:

> 2012/11/9 Manoj Vaghela <manoj.vaghela at gmail.com>:
> > Hi cmake,
> >
> > I have just started learning use of CPack for my application.
> >
> > I have an application which uses Qt and other third party libraries.
> >
> > In CMakeLists.txt,
> >
> > For adding libraries of external package, I used
> > INSTALL( FILES Lib1 lib2 DESTINATION ${INSTALL_DIR} )
> >
> > For installing target generated from this CMakeLists.txt,
> > INSTALL( TARGETS ${EXECUTABLE_NAME} DESTINATION ${INSTALL_DIR} )
> >
> > Here, while installing TARGETS, I want to add an executable of external
> > package.
> > When I included it with the above INSTALL, it says that "install TARGETS
> > given target "some/path/exe" which does not  exist in this directory."
>
> INSTALL(TARGETS ...)
> signature is only for *targets* which are build or imported by your
> current project.
> IMPORTED target may be defined using
>
> add_executable(... IMPORTED)
> or
> add_library(... IMPORTED)
>
> If you want to install other file/executable you can use:
> INSTALL(FILE ...)
>
> reading the builtin doc will certainly help you
>
> cmake --help-command add_library
> cmake --help-command add_executable
> cmake --help-command install
>
>
> > I want to do it without copying in to the CMakeLists.txt folder. Is there
> > any other way?
>
> see above.
>
> > Also, can somebody throw some light on while making package, which type
> of
> > libraries should I include ?? SHARED or STATIC ??
>
> This is not really a packaging choice.
> If your executable use shared lib then you should include those.
> Putting STATIC libs in your package usually means your package is offering
> the use of those libs to the user.
>
> Concerning including Qt libs in your installer you shoud find many
> reference of this
> on the ML list archive.
>
> A good starting point may be Mike's blog entry on DeployQt4 as well:
> http://mikemcquaid.com/2012/01/04/deploying-qt-applications-with-deployqt4/
> --
> Erk
> Le gouvernement représentatif n'est pas la démocratie --
> http://www.le-message.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121109/754200f6/attachment.htm>


More information about the CMake mailing list