CPack Deb generator exclude files/targets

409 Views Asked by At

I'm trying to build a C++ Project with CMake that contains a shared library (Lua) , the problem I'm having is that I only want to ship the Packages with Lua when building a Tar.gz for Linux or an NSIS installer for Windows, when packaging a deb or rpm package the library should be listed as a dependency (liblua5.3-0) but not actually be packaged.

Is it somehow possible to exclude files or build targets in CPack based on the generator?

1

There are 1 best solutions below

0
Stewart On BEST ANSWER

I think the answer is to install conditionally

I would probably make an option for this which is set at the top of my top-level cmake file, then use it in any install commands I come accross.

option(INSTALL_3RD_PARTY "Installs third party content" OFF)

if(INSTALL_3RD_PARTY)
  install(FILES liblua5.3-0 DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()

If you don't like making users set too many options, could you derive it from ${CPACK_GENERATOR} if that's user-defined. In my projects, I tend to set CPACK_GENERATOR after my install commands, so that wouldn't work as well for me.

if (${CPACK_GENERATOR} EQUAL "DEB")
  set(INSTALL_3RD_PARTY OFF)
endif()
if (${CPACK_GENERATOR} EQUAL "TZ")
  set(INSTALL_3RD_PARTY ON)
endif()