diff --git a/.github/workflows/darwin.yml b/.github/workflows/darwin.yml new file mode 100644 index 0000000..fd44145 --- /dev/null +++ b/.github/workflows/darwin.yml @@ -0,0 +1,34 @@ +name: darwin + +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: + 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. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: macos-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/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..232661f --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,34 @@ +name: Linux + +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: + 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. + # 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/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..187134a --- /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: + 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. + # 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}} 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 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/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. 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