diff options
author | Avraham Shukron <avraham.shukron@gmail.com> | 2019-04-06 00:27:04 +0300 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-11 11:09:42 -0400 |
commit | a40f9083dd17d1cccf89ccdf290c3f494cab3aac (patch) | |
tree | 2170e1aeba12956f710761a7facc5286b7936dc0 | |
parent | 4f07fdde26f1de59e2e8c2a32f0af7a2caff422d (diff) | |
download | cmake-a40f9083dd17d1cccf89ccdf290c3f494cab3aac.tar.gz |
INTERFACE Target: allow (PUBLIC/PRIVATE)_HEADER properties
Also support installing headers on an INTERFACE library.
Signed-off-by: Avraham Shukron <avraham.shukron@gmail.com>
Fixes: #15234
-rw-r--r-- | Help/command/add_library.rst | 17 | ||||
-rw-r--r-- | Help/command/install.rst | 6 | ||||
-rw-r--r-- | Help/release/dev/iface-headers.rst | 7 | ||||
-rw-r--r-- | Source/cmInstallCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmTargetPropertyComputer.cxx | 2 | ||||
-rw-r--r-- | Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake | 6 | ||||
-rw-r--r-- | Tests/RunCMake/install/TARGETS-Defaults.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/install/obj2.h | 6 | ||||
-rw-r--r-- | Tests/RunCMake/interface_library/whitelist.cmake | 9 |
9 files changed, 53 insertions, 11 deletions
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst index ec6cb9d9a0..b42fe42bb2 100644 --- a/Help/command/add_library.rst +++ b/Help/command/add_library.rst @@ -80,12 +80,17 @@ option extends visibility. It may be referenced like any target built within the project. ``IMPORTED`` libraries are useful for convenient reference from commands like :command:`target_link_libraries`. Details about the imported library are specified by setting properties whose names -begin in ``IMPORTED_`` and ``INTERFACE_``. The most important such -property is :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration -variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the -location of the main library file on disk. Or, for object libraries, -:prop_tgt:`IMPORTED_OBJECTS` (and :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) -specifies the locations of object files on disk. +begin in ``IMPORTED_`` and ``INTERFACE_``. + +The most important properties are: + +* :prop_tgt:`IMPORTED_LOCATION` (and its per-configuration + variant :prop_tgt:`IMPORTED_LOCATION_<CONFIG>`) which specifies the + location of the main library file on disk. +* :prop_tgt:`IMPORTED_OBJECTS` (and :prop_tgt:`IMPORTED_OBJECTS_<CONFIG>`) + for object libraries, specifies the locations of object files on disk. +* :prop_tgt:`PUBLIC_HEADER` files to be installed during :command:`install` invocation + See documentation of the ``IMPORTED_*`` and ``INTERFACE_*`` properties for more information. diff --git a/Help/command/install.rst b/Help/command/install.rst index a4cee7108f..7571aae291 100644 --- a/Help/command/install.rst +++ b/Help/command/install.rst @@ -148,13 +148,13 @@ project. There are several kinds of target files that may be installed: property are treated as ``FRAMEWORK`` targets on macOS. ``BUNDLE`` - Executables marked with the ``MACOSX_BUNDLE`` property are treated as + Executables marked with the :prop_tgt:`MACOSX_BUNDLE` property are treated as ``BUNDLE`` targets on macOS. ``PUBLIC_HEADER`` - Any ``PUBLIC_HEADER`` files associated with a library are installed in + Any :prop_tgt:`PUBLIC_HEADER` files associated with a library are installed in the destination specified by the ``PUBLIC_HEADER`` argument on non-Apple - platforms. Rules defined by this argument are ignored for ``FRAMEWORK`` + platforms. Rules defined by this argument are ignored for :prop_tgt:`FRAMEWORK` libraries on Apple platforms because the associated files are installed into the appropriate locations inside the framework folder. See :prop_tgt:`PUBLIC_HEADER` for details. diff --git a/Help/release/dev/iface-headers.rst b/Help/release/dev/iface-headers.rst new file mode 100644 index 0000000000..2e1de5ed8e --- /dev/null +++ b/Help/release/dev/iface-headers.rst @@ -0,0 +1,7 @@ +iface-headers +------------- + +* ``INTERFACE`` library can now have :prop_tgt:`PUBLIC_HEADER` and + :prop_tgt:`PRIVATE_HEADER` properties set. The headers specified by those + properties can be installed using the :command:`install(TARGETS)` command by + passing the ``PUBLIC_HEADER`` and ``PRIVATE_HEADER`` arguments respectively. diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 20d1a31340..65875dce75 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -663,8 +663,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) // generators for them. bool createInstallGeneratorsForTargetFileSets = true; - if (target.IsFrameworkOnApple() || - target.GetType() == cmStateEnums::INTERFACE_LIBRARY) { + if (target.IsFrameworkOnApple()) { createInstallGeneratorsForTargetFileSets = false; } diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx index d2c3496ed2..994fcf750b 100644 --- a/Source/cmTargetPropertyComputer.cxx +++ b/Source/cmTargetPropertyComputer.cxx @@ -67,6 +67,8 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty( builtIns.insert("IMPORTED_GLOBAL"); builtIns.insert("MANUALLY_ADDED_DEPENDENCIES"); builtIns.insert("NAME"); + builtIns.insert("PRIVATE_HEADER"); + builtIns.insert("PUBLIC_HEADER"); builtIns.insert("TYPE"); } diff --git a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake index c41cb2a755..15335b2a92 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults-all-check.cmake @@ -4,6 +4,8 @@ if(WIN32) [[bin/exe\.exe]] [[bin/(lib)?lib1\.dll]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] @@ -20,6 +22,8 @@ elseif(CYGWIN) [[bin/cyglib1\.dll]] [[bin/exe\.exe]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] @@ -35,6 +39,8 @@ else() [[bin]] [[bin/exe]] [[include]] + [[include/obj1\.h]] + [[include/obj2\.h]] [[include/obj4\.h]] [[include/obj5\.h]] [[lib]] diff --git a/Tests/RunCMake/install/TARGETS-Defaults.cmake b/Tests/RunCMake/install/TARGETS-Defaults.cmake index bfd8c2c618..324aa111fe 100644 --- a/Tests/RunCMake/install/TARGETS-Defaults.cmake +++ b/Tests/RunCMake/install/TARGETS-Defaults.cmake @@ -8,6 +8,11 @@ set_property(TARGET lib3 PROPERTY PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj add_library(lib4 SHARED obj5.c) set_property(TARGET lib4 PROPERTY PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj5.h) +add_library(iface INTERFACE) +set_target_properties(iface PROPERTIES + PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj1.h + PRIVATE_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/obj2.h) + install(TARGETS exe lib1 lib2) install(TARGETS lib3 LIBRARY DESTINATION lib3 @@ -17,3 +22,6 @@ install(TARGETS lib4 LIBRARY DESTINATION lib4 RUNTIME DESTINATION lib4 ) +install(TARGETS iface + PUBLIC_HEADER DESTINATION include + PRIVATE_HEADER DESTINATION include) diff --git a/Tests/RunCMake/install/obj2.h b/Tests/RunCMake/install/obj2.h new file mode 100644 index 0000000000..90bcd34440 --- /dev/null +++ b/Tests/RunCMake/install/obj2.h @@ -0,0 +1,6 @@ +#ifndef OBJ2_H +#define OBJ2_H + +int obj2(void); + +#endif /* OBJ2_H */ diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake index bf64f01b00..0db6375311 100644 --- a/Tests/RunCMake/interface_library/whitelist.cmake +++ b/Tests/RunCMake/interface_library/whitelist.cmake @@ -14,3 +14,12 @@ get_target_property(outname iface "_custom_property") set_property(TARGET iface PROPERTY "custom_property" output) set_property(TARGET iface APPEND PROPERTY "custom_property" append) get_target_property(outname iface "custom_property") + +# PUBLIC_HEADER / PRIVATE_HEADER properties are allowed +set_property(TARGET iface PROPERTY PUBLIC_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PUBLIC_HEADER bar.h) +get_target_property(outname iface PUBLIC_HEADER) + +set_property(TARGET iface PROPERTY PRIVATE_HEADER foo.h) +set_property(TARGET iface APPEND PROPERTY PRIVATE_HEADER bar.h) +get_target_property(outname iface PRIVATE_HEADER) |