Skip to content

Commit b8e1443

Browse files
authored
[fix] replacing include_directories with target_include_directories (ChunelFeng#350)
thx for your pr
1 parent 100931d commit b8e1443

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

cmake/CGraph-env-include.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ ELSEIF(WIN32)
3030
# 本工程也支持在windows平台上的mingw环境使用
3131
ENDIF()
3232

33-
include_directories(${CGRAPH_PROJECT_ROOT_DIR}/src/) # 直接加入"CGraph.h"文件对应的位置
34-
3533
# 以下三选一,本地编译执行,推荐OBJECT方式
3634
add_library(CGraph OBJECT ${CGRAPH_PROJECT_SRC_LIST}) # 通过代码编译
3735
# add_library(CGraph SHARED ${CGRAPH_PROJECT_SRC_LIST}) # 编译libCGraph动态库
3836
# add_library(CGraph STATIC ${CGRAPH_PROJECT_SRC_LIST}) # 编译libCGraph静态库
37+
38+
target_include_directories(CGraph PUBLIC ${CGRAPH_PROJECT_ROOT_DIR}/src/) # 直接加入"CGraph.h"文件对应的位置

example/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(CGRAPH_EXAMPLE_LIST
88

99
foreach(example ${CGRAPH_EXAMPLE_LIST})
1010
add_executable(${example}
11-
$<TARGET_OBJECTS:CGraph>
1211
${example}.cpp
1312
)
14-
endforeach()
13+
target_link_libraries(${example} PRIVATE CGraph)
14+
endforeach()

tutorial/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ set(CGRAPH_TUTORIAL_LIST
3434
foreach(tut ${CGRAPH_TUTORIAL_LIST})
3535
add_executable(${tut}
3636
# 在自己的工程中引入CGraph功能,仅需引入 CGraph-env-include.cmake 后,加入这一句话即可
37-
$<TARGET_OBJECTS:CGraph>
3837
${tut}.cpp
3938
)
39+
target_link_libraries(${tut} PRIVATE CGraph)
40+
4041
endforeach()

0 commit comments

Comments
 (0)