Skip to content

Commit

Permalink
refactor: use FetchContent instead of conan for better flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Jan 31, 2024
1 parent 2fd2ca4 commit 8bf0cfe
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 60 deletions.
30 changes: 12 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,18 @@ jobs:
- name: Set up CMake and Ninja
uses: lukka/get-cmake@latest

- name: Set up Conan
- name: Build with CMake
run: |
python -m pip install -U conan
conan profile detect --force
conan export third_party/funchook --version 1.1.3
conan install . --build=missing -pr:a .github/conan_profiles/windows
- name: Build with Conan
run: conan build . -pr:a .github/conan_profiles/windows
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: endstone-cpp-plugin-windows
path: ./build/Release/*.dll
path: ./build/*.dll

build_linux:
name: Build on Ubuntu
Expand Down Expand Up @@ -83,18 +80,15 @@ jobs:
- name: Set up CMake and Ninja
uses: lukka/get-cmake@latest

- name: Set up Conan
- name: Build with CMake
run: |
python -m pip install -U conan
conan profile detect --force
conan export third_party/funchook --version 1.1.3
conan install . --build=missing -pr:a .github/conan_profiles/linux
- name: Build with Conan
run: conan build . -pr:a .github/conan_profiles/linux
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: endstone-cpp-plugin-linux
path: ./build/Release/*.so
path: ./build/*.so
51 changes: 49 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,57 @@ cmake_minimum_required(VERSION 3.15)

project(endstone_cpp_plugin CXX)

find_package(endstone REQUIRED COMPONENTS)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)


# ===============
# Compiler Check
# ===============
if (WIN32 AND NOT MSVC)
message(FATAL_ERROR "MSVC is required on Windows")
elseif (UNIX)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Clang is required on Linux")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif ()


# ===============
# Dependencies
# ===============
include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.2.1
)
FetchContent_MakeAvailable(fmt)

FetchContent_Declare(
endstone
GIT_REPOSITORY https://github.com/EndstoneMC/endstone.git
GIT_TAG v1.20.51
)
FetchContent_GetProperties(endstone)
if (NOT endstone_POPULATED)
FetchContent_Populate(endstone)
endif ()


# ===============
# Build
# ===============
add_library(${PROJECT_NAME} SHARED src/endstone_cpp_plugin.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_link_libraries(${PROJECT_NAME} PRIVATE endstone::headers)
target_include_directories(${PROJECT_NAME} PRIVATE ${endstone_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)


# ===============
# Install
# ===============
install(TARGETS ${PROJECT_NAME})
40 changes: 0 additions & 40 deletions conanfile.py

This file was deleted.

0 comments on commit 8bf0cfe

Please sign in to comment.