Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create package for just one component with CMake and CPack

Tags:

cmake

cpack

I have a project for a client/server application and I have defined one installation component for each.

I use set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) in order to get two different package files when I run make package. But I don't get different make targets for each. So in order to get the client installation package I get the server application compiled and packaged too.

Is there a simple way to get the packaging for one single component?

like image 836
Antonio Pérez Avatar asked Oct 27 '25 04:10

Antonio Pérez


1 Answers

CMake assumes that before installation make all should be executed. Same assumptions are made by CPack, when it want to create package. If you want to build only targets, related to some specific component, you need to force make all to build only those targets.

E.g., you can check cache variables which intended to be set in cmake command line:

CMakeLists.txt:

option(SERVER_ONLY "Set if you want to build only server")
option(CLIENT_ONLY "Set if you want to build only client")

if(NOT SERVER_ONLY)
    add_subdirectory(client)
endif()

if(NOT CLIENT_ONLY)
    add_subdirectory(server)
endif()

So, for build and package only server component, you may use

cmake -DSERVER_ONLY=ON <source-dir>
cpack <...>
like image 156
Tsyvarev Avatar answered Oct 30 '25 00:10

Tsyvarev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!