`
aigo
  • 浏览: 2680965 次
  • 性别: Icon_minigender_1
  • 来自: 宜昌
社区版块
存档分类
最新评论

[cmake]target_link_libraries参数:PRIVATE、PUBLIC、INTERFACE三者区别

阅读更多

 

原文:

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

 

 

 

分享到:
评论

相关推荐

    CMake添加引用多个子目录多个CMakeLists同时编译

    你可以使用`PUBLIC`, `PRIVATE`和`INTERFACE`关键字来控制这些属性。例如: ```cmake target_include_directories(MyLibrary PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) ``` 这样,`MyLibrary`的公共头文件路径...

    Cmake使用手册,CMakeLists.txt的语法规则!

    7. `target_include_directories(<target> <INTERFACE|PUBLIC|PRIVATE> )`:为特定目标添加头文件路径,更现代且推荐的方法。 8. `target_link_libraries(<target> <libraries...>)`:链接目标到所需的库。 9. `...

    cmake代码示例,基础知识

    - `target_link_libraries(target [INTERFACE|PRIVATE|PUBLIC] libraries)`: 设置目标链接的库。 4. **变量与选项**: - `set(variable value)`: 设置变量。 - `option(option_name "help_string" default_value...

    Cmakelists.tar.gz

    - `target_include_directories(TARGET [INTERFACE|PRIVATE|PUBLIC]_DIRECTORIES)`: 为特定目标指定包含路径,更现代且灵活的替代`include_directories`。 - `target_link_libraries(TARGET [TARGETS|LIBRARIES])`...

    cmakelists文件架构组织

    - `target_sources(target_name PRIVATE|PUBLIC|INTERFACE sources...)`: 为特定目标设置源文件,控制源文件的可见性。 - `target_include_directories(target_name ...)`:设置目标的包含目录。 - `target_...

    android studio使用CMAKE编译ffmepg

    target_link_libraries(ffmpeg ${log-lib}) ``` 这里需要替换`ffmpeg_source_file`为实际的源文件,`ffmpeg_include_dir`为头文件目录。 4. **在Android Studio中构建**:完成以上步骤后,Android Studio会自动...

    cmake入门操作博客源代码

    - `target_include_directories(TARGET_NAME PUBLIC|PRIVATE|INTERFACE dir1 dir2 ...)`: 设置目标的包含目录。 - `target_link_libraries(TARGET_NAME lib1 lib2 ...)`: 将目标与库链接。 2. **变量与选项**:...

    libjson fro android

    如果是使用CMakeLists.txt,可以在`target_link_libraries`中添加`json`: ```cmake target_link_libraries(myapp_jni json ${log-lib}) ``` 编译完成后,就可以在Java代码中调用`parseJsonString`方法,利用JNI和...

    tutorial

    `target_compile_options(TARGET_NAME PRIVATE PUBLIC PRIVATE_COMPILE_OPTIONS)`用于设置编译选项,`PRIVATE`、`PUBLIC`和`INTERFACE`分别代表目标自身的、子目标的和接口库的选项。 7. **安装目标** `install...

    jniDemo的配置

    # 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 ...

    jni生成so并在另一个项目使用

    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/...

    android+javaCV环境配置

    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. **测试...

    Android ndk cpp 线程运行 java 方法

    target_link_libraries( # Specifies the target library. native-lib # Links the target library to the log library # included in the NDK. ${log-lib} ) ``` 5. **构建并运行** 现在,你可以构建并...

    Android JNI处理图片实现黑白滤镜的方法

    target_link_libraries( # Specifies the target library. native-lib jnigraphics ${log-lib} ) ``` 这里,`CMakeLists.txt`指定了一个名为`native-lib`的共享库,并链接了`jnigraphics`库,这是处理Bitmap所需...

Global site tag (gtag.js) - Google Analytics