原文:
CMake target_link_libraries Interface Dependencies
http://stackoverflow.com/questions/26037954/cmake-target-link-libraries-interface-dependencies
If you are creating a shared library and your source cpp files #include the headers of another library (Say, QtNetwork for example), but your header files don't include QtNetwork headers, then QtNetwork is a PRIVATE dependency.
If your source files and your headers include the headers of another library, then it is a PUBLIC dependency.
If your header files but not your source files include the headers of another library, then it is an INTERFACE dependency.
Other build properties of PUBLIC and INTERFACE dependencies are propagated to consuming libraries. http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#transitive-usage-requirements
相关推荐
你可以使用`PUBLIC`, `PRIVATE`和`INTERFACE`关键字来控制这些属性。例如: ```cmake target_include_directories(MyLibrary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) ``` 这样,`MyLibrary`的公共头文件路径...
7. `target_include_directories(<target> <INTERFACE|PUBLIC|PRIVATE> )`:为特定目标添加头文件路径,更现代且推荐的方法。 8. `target_link_libraries(<target> <libraries...>)`:链接目标到所需的库。 9. `...
- `target_link_libraries(target [INTERFACE|PRIVATE|PUBLIC] libraries)`: 设置目标链接的库。 4. **变量与选项**: - `set(variable value)`: 设置变量。 - `option(option_name "help_string" default_value...
- `target_include_directories(TARGET [INTERFACE|PRIVATE|PUBLIC]_DIRECTORIES)`: 为特定目标指定包含路径,更现代且灵活的替代`include_directories`。 - `target_link_libraries(TARGET [TARGETS|LIBRARIES])`...
- `target_sources(target_name PRIVATE|PUBLIC|INTERFACE sources...)`: 为特定目标设置源文件,控制源文件的可见性。 - `target_include_directories(target_name ...)`:设置目标的包含目录。 - `target_...
target_link_libraries(ffmpeg ${log-lib}) ``` 这里需要替换`ffmpeg_source_file`为实际的源文件,`ffmpeg_include_dir`为头文件目录。 4. **在Android Studio中构建**:完成以上步骤后,Android Studio会自动...
- `target_include_directories(TARGET_NAME PUBLIC|PRIVATE|INTERFACE dir1 dir2 ...)`: 设置目标的包含目录。 - `target_link_libraries(TARGET_NAME lib1 lib2 ...)`: 将目标与库链接。 2. **变量与选项**:...
如果是使用CMakeLists.txt,可以在`target_link_libraries`中添加`json`: ```cmake target_link_libraries(myapp_jni json ${log-lib}) ``` 编译完成后,就可以在Java代码中调用`parseJsonString`方法,利用JNI和...
`target_compile_options(TARGET_NAME PRIVATE PUBLIC PRIVATE_COMPILE_OPTIONS)`用于设置编译选项,`PRIVATE`、`PUBLIC`和`INTERFACE`分别代表目标自身的、子目标的和接口库的选项。 7. **安装目标** `install...
# Specifies libraries CMake should link to your target library. # You can link multiple libraries, such as libraries you define in this # build script, pre-built third-party libraries, or system ...
target_link_libraries( # Specifies the target library. hello-jni # Links the target library to the log library # included in the NDK. ${log-lib} ) ``` 构建完成后,生成的.so文件将位于项目的`app/...
target_link_libraries( # Specifies the target library. native-lib # Links the target library to the log library # included in the NDK. ${JavaCV_LIBRARIES} ${opencv_LIBRARIES} ) ``` 6. **测试...
target_link_libraries( # Specifies the target library. native-lib # Links the target library to the log library # included in the NDK. ${log-lib} ) ``` 5. **构建并运行** 现在,你可以构建并...
target_link_libraries( # Specifies the target library. native-lib jnigraphics ${log-lib} ) ``` 这里,`CMakeLists.txt`指定了一个名为`native-lib`的共享库,并链接了`jnigraphics`库,这是处理Bitmap所需...