[CMake] How to deal with incompatible changes in interface of target_link_libraries()?

Marcel Loose marcel.loose at zonnet.nl
Sat Aug 9 09:46:25 EDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I'm struggling with the problem that CMake 2.8.12 introduced
incompatible changes in the interface of target_link_libraries()
w.r.t. dealing with direct and indirect (transitive) link
dependencies. Pre-2.8.12 you would use the keyword
LINK_INTERFACE_LIBRARIES to indicate indirect link dependencies. CMake
2.8.12 introduced the keywords PRIVATE, INTERFACE and PUBLIC, and
immediately deprecated the LINK_INTERFACE_LIBRARIES keyword,
triggering policy warnings CMP0022 and CMP0023.

What is the proper way to get rid of these policy warnings, while at
the same time staying backward compatible with older CMake versions? I
need to support all 2.8.x versions, but I don't want to set these
policies to OLD. I also don't want to wrap each call to
target_link_libraries() inside a conditional

	if (${CMAKE_VERSION} VERSION_LESS 2.8.12)
	...
	else()
	...
	endif()

Of course I could put this logic in a macro, but how then do I handle
the new keywords. Some hints or tips would be very much appreciated.

Kind regards,
Marcel Loose.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJT5iYxAAoJEEpMyb1AIWdYFR4IAJXH0KV9dc8cCPItf2R1UTTS
dkdvoqJtRRqKIS/fyQv4VHsbqP0DqH9qlCjc6O6h27I461PUwwfk+hYNDQI+q5wH
SKu3kosT4rIxDg+CmGr/yhzSdzuWKyhRu+L4syunoOxeXXreKSzSIrTvdRA1fPZg
aSJR4hvnA5cDUA/0pdV9pPKm4JATK8s2/S64PPjA2CRbq6pZfnnX4tRrQMnkt/+S
R1xmmVVzcuctdIAdanUnDlTfRHMNOyY3uWozXkO2OCeTFJLc00xQcvJdcr2zXyRx
EtvpFVmBU9IsAu4LY3gZZfjWwpwsMyYptaYSSF7oDJjshw5LctObJZ89jgFhtmw=
=RhRJ
-----END PGP SIGNATURE-----


More information about the CMake mailing list