[CMake] CPack: howto change directory layout depending on the generator
Tanguy Krotoff
tkrotoff at gmail.com
Fri Sep 19 13:15:33 EDT 2008
Hi everybody
I would like to change the directory layout generated by CPack given
the generator used.
In a way, I would like a more fine-grained control about what CPack
generates and after reading the different docs I don't know if it is
possible.
I have a pretty complex multiplatform program with plugins, internal
libraries... here are the different layouts I would like to achieve:
** NSIS:
/app.exe
/internal_lib1.dll
/internal_lib2.dll
/plugins/plugin1.dll
/plugins/plugin2.dll
** DEB / RPM:
/usr/bin/app
/usr/lib/app/internal_lib1.so
/usr/lib/app/internal_lib2.so
/usr/lib/app/plugins/plugin1.so
/usr/lib/app/plugins/plugin2.so
** TGZ / ZIP (same as NSIS):
/app
/app.sh (does a export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./app)
/internal_lib1.so
/internal_lib2.so
/plugins/plugin1.so
/plugins/plugin2.so
** If no generator is used, make install should give the same layout
as with NSIS / TGZ / NSIS
This way I just have to go to my build directory and run app.sh or
app.exe directly:
this simplifies the compile/test procedure since there is no need for
the install step (i.e compile/install/test).
So I have this code in my root CMakeLists.txt:
if (LINUX)
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/myapp
)
set(INSTALL_PLUGINS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/myapp/plugins
)
endif
if (WIN32)
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
set(INSTALL_PLUGINS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
endif
As you see it does not depend on the generator invoked but on the
platform instead
I you would to change it to something like this:
if (CPACK_GENERATOR == "DEB,RPM")
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/myapp
)
set(INSTALL_PLUGINS_DEFAULT_ARGS
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib/myapp/plugins
)
endif
if (CPACK_GENERATOR == "TGZ,ZIP,NSIS")
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
set(INSTALL_PLUGINS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
endif
if (NOT CPACK_GENERATOR)
set(INSTALL_TARGETS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
set(INSTALL_PLUGINS_DEFAULT_ARGS
RUNTIME DESTINATION .
LIBRARY DESTINATION .
)
endif
Do you know if this king of things are possible?
Thanks in advance,
--
Tanguy Krotoff <tkrotoff at gmail.com>
+33 6 68 42 70 24
More information about the CMake
mailing list