Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export target's properties when installing targets in CMake

Tags:

cmake

I have the following sample project which I would like to export PROTOCOLS_LIST properties.

cmake_minimum_required(VERSION 3.14.0)
project(exported_props LANGUAGES CXX)

add_library(protocols ...)
set_target_properties(protocols PROPERTIES PROTOCOLS_LIST "IP" "TCP" "UDP")

install(TARGETS protocols EXPORT protocol)
install(EXPORT protocol DESTINATION ${CMAKE_BINARY_DIR})

When installing the above sample code, the created protocol.cmake file will not contain my custom property PROTOCOLS_LIST.

Is it possible to pass some target's properties when installing TARGETS?

like image 927
AmirSalar Avatar asked Oct 14 '25 20:10

AmirSalar


1 Answers

By default, CMake installs only specific set of target's properties.

For tell CMake to install additional properties you could list that properties in the EXPORT_PROPERTIES target's property:

# Tell CMake to install PROTOCOLS_LIST property for the target.
set_property(TARGET protocols APPEND PROPERTY EXPORT_PROPERTIES PROTOCOLS_LIST)
like image 105
Tsyvarev Avatar answered Oct 18 '25 04:10

Tsyvarev