Skip to content

Commit

Permalink
add deps install cmake scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lkpworkspace committed May 6, 2024
1 parent 209eafe commit e47c629
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ launcher/launcher_config.h
test/performance_test_config.h
myframe/export.h
myframe/config.h
3rd/pkg/
3rd/src/
3rd/build/
output/
67 changes: 67 additions & 0 deletions 3rd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.10)
if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
project(myframe_deps VERSION 1.0.0)

include(ExternalProject)

set(DEPS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src)
set(DEPS_DOWNLOAD_DIR ${CMAKE_SOURCE_DIR}/pkg)

ExternalProject_Add(
gflags
URL https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.tar.gz
URL_MD5 1a865b93bacfa963201af3f75b7bd64c
DOWNLOAD_NAME "gflags.tar.gz"
PREFIX ${CMAKE_BINARY_DIR}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
SOURCE_DIR "${DEPS_SOURCE_DIR}/gflags"
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_ARGS
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

ExternalProject_Add(
glog
URL https://github.com/google/glog/archive/refs/tags/v0.6.0.tar.gz
URL_MD5 c98a6068bc9b8ad9cebaca625ca73aa2
DOWNLOAD_NAME "glog.tar.gz"
PREFIX ${CMAKE_BINARY_DIR}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
SOURCE_DIR "${DEPS_SOURCE_DIR}/glog"
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_ARGS
-DBUILD_SHARED_LIBS=ON
-DCMAKE_BUILD_TYPE=Release
-DWITH_PKGCONFIG=OFF
-DWITH_GTEST=OFF
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_PREFIX_PATH=${CMAKE_INSTALL_PREFIX}
)
ExternalProject_Add_StepDependencies(glog install gflags)

ExternalProject_Add(
jsoncpp
URL https://github.com/open-source-parsers/jsoncpp/archive/refs/tags/1.9.5.tar.gz
URL_MD5 d6c8c609f2162eff373db62b90a051c7
DOWNLOAD_NAME "jsoncpp.tar.gz"
PREFIX ${CMAKE_BINARY_DIR}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}
SOURCE_DIR "${DEPS_SOURCE_DIR}/jsoncpp"
UPDATE_COMMAND ""
PATCH_COMMAND ""
CMAKE_ARGS
-DBUILD_SHARED_LIBS=ON
-DBUILD_STATIC_LIBS=OFF
-DBUILD_OBJECT_LIBS=OFF
-DCMAKE_BUILD_TYPE=Release
-DJSONCPP_WITH_TESTS=OFF
-DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)
2 changes: 2 additions & 0 deletions 3rd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 3rd
该目录主要用于下载/构建/安装依赖包使用
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ worker自驱动,可以通过消息与actor交互;
| Windows |
| macOS |

## 构建
## github构建
* [github ci linux](.github/workflows/linux.yml)
* [github ci windows](.github/workflows/windows.yml)
* [github ci macOS](.github/workflows/macos.yml)

## 快速本地构建
```sh
# 下载/构建/安装依赖库
cd 3rd
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=../output
cmake --build build -j
# 构建安装
cd ..
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=./output -DCMAKE_PREFIX_PATH=./output
cmake --build build -j --config Release --target install
```

### Hello,World 示例
```c
#include <string.h>
Expand Down

0 comments on commit e47c629

Please sign in to comment.