Specify public header files in a ``FRAMEWORK`` shared library target. Shared library targets marked with the ``FRAMEWORK`` property generate frameworks on macOS, iOS and normal shared libraries on other platforms. This property may be set to a list of header files to be placed in the ``Headers`` directory inside the framework folder. On non-Apple platforms these headers may be installed using the ``PUBLIC_HEADER`` option to the ``install(TARGETS)`` command.
时间: 2023-07-13 08:16:36 浏览: 107
The ``FRAMEWORK`` property in CMake can be used to specify public header files for a shared library target that generates frameworks on macOS, iOS, and normal shared libraries on other platforms. When the ``FRAMEWORK`` property is set, the specified header files will be placed in the ``Headers`` directory inside the framework folder.
On non-Apple platforms, these headers can be installed using the ``PUBLIC_HEADER`` option to the ``install(TARGETS)`` command. This will ensure that the headers are installed in the appropriate location for other projects to use as public headers.
For example, the following CMake code specifies the public header files for a shared library target with the ``FRAMEWORK`` property:
```
add_library(MyLibrary SHARED
source_file1.cpp
source_file2.cpp
)
set_target_properties(MyLibrary PROPERTIES
FRAMEWORK TRUE
PUBLIC_HEADER "header_file1.h;header_file2.h"
)
install(TARGETS MyLibrary
LIBRARY DESTINATION lib
FRAMEWORK DESTINATION Library/Frameworks
PUBLIC_HEADER DESTINATION include
)
```
This code specifies that ``header_file1.h`` and ``header_file2.h`` should be included as public headers for the ``MyLibrary`` target. The headers will be placed in the ``Headers`` directory inside the ``MyLibrary.framework`` folder on macOS and iOS, and will be installed in the ``include`` directory on other platforms.
阅读全文