Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ project(CGraph VERSION 3.1.1)
# CGraph默认使用C++11版本,推荐使用C++17版本。暂不支持C++11以下版本
set(CMAKE_CXX_STANDARD 11)

option(CGRAPH_BUILD_TUTORIAL "Enables builds of tutorials" ON)
option(CGRAPH_BUILD_EXAMPLE "Enables builds of examples" ON)
option(CGRAPH_BUILD_FUNCTIONAL_TESTS "Enables builds of functional tests" OFF)
option(CGRAPH_BUILD_PERFORMANCE_TESTS "Enables builds of performance tests" OFF)
option(CGRAPH_BUILD_TUTORIALS "Enable build tutorials" ON)
option(CGRAPH_BUILD_EXAMPLES "Enable build examples" ON)
option(CGRAPH_BUILD_FUNCTIONAL_TESTS "Enable build functional tests" OFF)
option(CGRAPH_BUILD_PERFORMANCE_TESTS "Enable build performance tests" OFF)

# 如果开启此宏定义,则CGraph执行过程中,不会在控制台打印任何信息
# add_definitions(-D_CGRAPH_SILENCE_)
Expand All @@ -40,12 +40,17 @@ option(CGRAPH_BUILD_PERFORMANCE_TESTS "Enables builds of performance tests" OFF)
# add CGraph environment info
include(cmake/CGraph-env-include.cmake)

if(CGRAPH_BUILD_TUTORIAL)
# 教程相关内容
if(CGRAPH_BUILD_TUTORIALS)
message(STATUS "[CGraph] build tutorials")
add_subdirectory(./tutorial)
endif(CGRAPH_BUILD_TUTORIAL)
if(CGRAPH_BUILD_EXAMPLE)
endif(CGRAPH_BUILD_TUTORIALS)

# 样例相关内容
if(CGRAPH_BUILD_EXAMPLES)
message(STATUS "[CGraph] build examples")
add_subdirectory(./example)
endif(CGRAPH_BUILD_EXAMPLE)
endif(CGRAPH_BUILD_EXAMPLES)

# 功能测试相关内容
if(CGRAPH_BUILD_FUNCTIONAL_TESTS)
Expand Down
37 changes: 22 additions & 15 deletions COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@
$ ./tutorial/T00-HelloCGraph # 运行 T00-HelloCGraph
```

* 在项目中作为第三方库调用,使用FetchContent
```cmake
Include(FetchContent)
FetchContent_Declare(
CGraph
GIT_REPOSITORY https://github.com/ChunelFeng/CGraph.git
GIT_TAG main
GIT_SHALLOW true
)
FetchContent_MakeAvailable(CGraph)

target_include_directories(${PROJECT_NAME} PRIVATE ${CGraph_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} PRIVATE CGraph)
```

* Bazel编译方式(Linux/MacOS/Windows)
```shell
$ git clone https://github.com/ChunelFeng/CGraph.git
Expand All @@ -72,6 +57,28 @@

---

* 在其他使用 CMakeLists.txt 构建的项目中,通过 FetchContent 作为三方库引入
```cmake
set(CGRAPH_BUILD_TUTORIAL OFF CACHE BOOL "" FORCE)
set(CGRAPH_BUILD_EXAMPLE OFF CACHE BOOL "" FORCE)
set(CGRAPH_BUILD_FUNCTIONAL_TESTS OFF CACHE BOOL "" FORCE)
set(CGRAPH_BUILD_PERFORMANCE_TESTS OFF CACHE BOOL "" FORCE)

Include(FetchContent)
FetchContent_Declare(
CGraph
GIT_REPOSITORY https://github.com/ChunelFeng/CGraph.git
GIT_TAG main
GIT_SHALLOW true
)

FetchContent_MakeAvailable(CGraph)
target_include_directories(${PROJECT_NAME} PRIVATE ${CGraph_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} PRIVATE CGraph)
```

---

### Python 版本
* MacOS 和 Windows 用户可以通过命令安装(推荐)
```shell
Expand Down
Loading