From 2d3480b912a98737193cd99ee3fe673e2333e3fc Mon Sep 17 00:00:00 2001 From: alex <38814044+alextwothousand@users.noreply.github.com> Date: Sat, 7 Aug 2021 17:51:05 +0100 Subject: [PATCH 1/7] add CMake FetchContent support --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index f3c6029..c5c7782 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,23 @@ $ npm install enet.c --save Add include path to the library `node_modules/enet.c/include` to your makefile/ +## Installation (via CMake >3.11) + +Install library by + +```cmake +include(FetchContent) + +FetchContent_Declare( + enet + GIT_REPOSITORY https://github.com/zpl-c/enet.git + GIT_TAG YOUR_BRANCH_OR_TAG_OF_CHOICE +) +FetchContent_MakeAvailable(enet) +``` + +and link against the `enet` library in projects that necessitate it. + ## Installation (manually) Download file [include/enet.h](https://raw.githubusercontent.com/zpl-c/enet/master/include/enet.h) and just add to your project. From 3cfd32a136c68466a1c3caa09d58250f36b1755b Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:06:55 +0100 Subject: [PATCH 2/7] add GitHub Actions --- .github/workflows/cmake.yml | 34 ++++++++++++++++++++++++++++++++++ CMakeLists.txt | 16 +++++----------- test/CMakeLists.txt | 13 +++++++++++++ 3 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/cmake.yml create mode 100644 test/CMakeLists.txt diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..006dd0a --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,34 @@ +name: CMake + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + ENET_STATIC: 1 + ENET_TEST: 1 + ENET_SHARED: 0 + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENET_STATIC=${{env.ENET_STATIC}} -DENET_SHARED=${{env.ENET_SHARED}} -DENET_TEST=${{env.ENET_TEST}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} diff --git a/CMakeLists.txt b/CMakeLists.txt index ba539ee..3bfaf0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.0) project(enet C) # defaults -set(ENET_STATIC ON) -set(ENET_SHARED OFF) -set(ENET_TEST OFF) +option(ENET_STATIC ON) +option(ENET_SHARED OFF) +option(ENET_TEST OFF) # configure projects if (ENET_STATIC) @@ -25,19 +25,13 @@ if (ENET_SHARED) endif() if (ENET_TEST) - add_executable(enet_test test/build.c) - target_include_directories(enet_test PRIVATE ${PROJECT_SOURCE_DIR}/include) - - if (WIN32) - target_link_libraries(enet_test PUBLIC winmm ws2_32) - endif() + add_subdirectory(test) endif() - if(MSVC) target_compile_options(enet PRIVATE -W3) else() target_compile_options(enet PRIVATE -Wno-error) endif() -target_include_directories(enet PUBLIC ${PROJECT_SOURCE_DIR}/include) +target_include_directories(enet PUBLIC ${PROJECT_SOURCE_DIR}/include) \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..c45b019 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.0) +project(enet_test C) + +add_executable(enet_test build.c) + +target_link_libraries(enet_test PRIVATE enet) +target_include_directories(enet_test PRIVATE enet) + +if(MSVC) + target_compile_options(enet_test PRIVATE -W3) +else() + target_compile_options(enet_test PRIVATE -Wno-error) +endif() \ No newline at end of file From ddcb5c7977489b74346793f7f06f147a802b1afa Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:09:53 +0100 Subject: [PATCH 3/7] add linux, macOS and windows ci/cd --- .github/workflows/{cmake.yml => linux.yml} | 4 +-- .github/workflows/macOS.yml | 34 ++++++++++++++++++++++ .github/workflows/windows.yml | 34 ++++++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) rename .github/workflows/{cmake.yml => linux.yml} (98%) create mode 100644 .github/workflows/macOS.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/linux.yml similarity index 98% rename from .github/workflows/cmake.yml rename to .github/workflows/linux.yml index 006dd0a..2e97403 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/linux.yml @@ -1,4 +1,4 @@ -name: CMake +name: Linux on: push: @@ -14,7 +14,7 @@ env: ENET_SHARED: 0 jobs: - build: + x64: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. diff --git a/.github/workflows/macOS.yml b/.github/workflows/macOS.yml new file mode 100644 index 0000000..48ed050 --- /dev/null +++ b/.github/workflows/macOS.yml @@ -0,0 +1,34 @@ +name: Windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + ENET_STATIC: 1 + ENET_TEST: 1 + ENET_SHARED: 0 + +jobs: + x64: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: macos-11 + + steps: + - uses: actions/checkout@v2 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENET_STATIC=${{env.ENET_STATIC}} -DENET_SHARED=${{env.ENET_SHARED}} -DENET_TEST=${{env.ENET_TEST}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..09e233c --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,34 @@ +name: Windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + ENET_STATIC: 1 + ENET_TEST: 1 + ENET_SHARED: 0 + +jobs: + x64: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENET_STATIC=${{env.ENET_STATIC}} -DENET_SHARED=${{env.ENET_SHARED}} -DENET_TEST=${{env.ENET_TEST}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} From 38936ce04623dca114921ea0ee92e48c38dec07d Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:10:56 +0100 Subject: [PATCH 4/7] correct build names --- .github/workflows/{macOS.yml => darwin.yml} | 2 +- .github/workflows/windows.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{macOS.yml => darwin.yml} (98%) diff --git a/.github/workflows/macOS.yml b/.github/workflows/darwin.yml similarity index 98% rename from .github/workflows/macOS.yml rename to .github/workflows/darwin.yml index 48ed050..c9fe3da 100644 --- a/.github/workflows/macOS.yml +++ b/.github/workflows/darwin.yml @@ -1,4 +1,4 @@ -name: Windows +name: darwin on: push: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 09e233c..1cc129f 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,4 +1,4 @@ -name: Windows +name: windows on: push: From cf38f4daee284d048c242df1426c2918d43cf25e Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:11:52 +0100 Subject: [PATCH 5/7] switch back to macos-latest from macos-11 --- .github/workflows/darwin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml index c9fe3da..3ecc087 100644 --- a/.github/workflows/darwin.yml +++ b/.github/workflows/darwin.yml @@ -19,7 +19,7 @@ jobs: # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: macos-11 + runs-on: macos-latest steps: - uses: actions/checkout@v2 From c0bc497c00e2e55078c23e6155b005d93ca1f22f Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:12:21 +0100 Subject: [PATCH 6/7] modify build names again --- .github/workflows/darwin.yml | 2 +- .github/workflows/linux.yml | 2 +- .github/workflows/windows.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml index 3ecc087..fd44145 100644 --- a/.github/workflows/darwin.yml +++ b/.github/workflows/darwin.yml @@ -14,7 +14,7 @@ env: ENET_SHARED: 0 jobs: - x64: + cmake-x64: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2e97403..232661f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -14,7 +14,7 @@ env: ENET_SHARED: 0 jobs: - x64: + cmake-x64: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 1cc129f..187134a 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -14,7 +14,7 @@ env: ENET_SHARED: 0 jobs: - x64: + cmake-x64: # The CMake configure and build commands are platform agnostic and should work equally # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. From 4a0f4a930e66d6a6edb137b899c8c99c9626aab7 Mon Sep 17 00:00:00 2001 From: alextwothousand Date: Sat, 7 Aug 2021 18:15:14 +0100 Subject: [PATCH 7/7] alter travis ci build --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f15a486..62a0677 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ compiler: - clang script: - - cmake . -DCMAKE_BUILD_TYPE=Release -DENET_TEST=1 -DENET_SHARED=1 + - cmake . -DCMAKE_BUILD_TYPE=Release -DENET_TEST=1 -DENET_SHARED=1 -DENET_STATIC=0 - cmake --build . - ./enet_test