PUBLIC:公开的。PUBLIC = PRIVATE + INTERFACE。生成 libhello-world.so 时,在 hello_world.c 和 hello_world.h 中都包含了 hello.h。并且 main.c 中也需要使用 libhello.so 提供的功能。那么在 hello-world/CMakeLists.txt 中应该写入: target_link_libraries(hello-world PUBLIC hello)target_include_direc...
第一:private, public, protected 访问标号的访问范围。 private:只能由1.该类中的函数、2.其友元函数访问。 不能被任何其他访问,该类的对象也不能访问。 protected:可以被1.该类中的函数、2.子类的函数、以及3.其友元函数访问。 但不能被该类的对象访问。 public:可以被1.该类中的函数、2.子类的函数、3....
PUBLIC headers are used for # compiling the library, and will be added to consumers' build # paths. target_include_directories(lib PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include> PRIVATE src) 我正在构建一个库项目,由于我使用标准路径( lib/用于静态库...
{PROJECT_NAME} PRIVATE ${PRJ_INCLUDE_DIRS} ) target_link_libraries( ${PROJECT_NAME} PRIVATE ${PRJ_LIBRARIES} ) target_compile_features ( ${PROJECT_NAME} PRIVATE ${PRJ_COMPILE_FEATURES} ) get_target_property(include_dirs ${PROJECT_NAME} INCLUDE_DIRECTORIES) foreach(dir ${include_dirs}) ...