diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1f4d0dca..667434d2 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,4 +1,4 @@ -name: Cmake CI +name: CI on: push: @@ -8,27 +8,45 @@ on: jobs: build-and-test: - - runs-on: ubuntu-latest + name: Build & Test (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ windows-2022, ubuntu-20.04 ] steps: - uses: actions/checkout@v2 with: submodules: true + - name: Add msbuild to PATH (windows only) + if: ${{ matrix.os == 'windows-2022' }} + uses: microsoft/setup-msbuild@v1.1 + with: + vs-version: '[17,18)' + msbuild-architecture: x64 - name: cmake uses: lukka/run-cmake@v10 with: - configurePreset: 'default' - buildPreset: 'default' - testPreset: 'default' + configurePreset: "ci-${{matrix.os}}" + buildPreset: "ci-${{matrix.os}}" + testPreset: "ci-${{matrix.os}}" - name: artifacts uses: actions/upload-artifact@v2 with: - name: linux-build + name: build-${{matrix.os}} path: | build + !build/tests + !build/Testing + !build/CMakeFiles + !build/DartConfiguration.tcl + !build/CTestTestfile.cmake !build/CMakeCache.txt !build/build.ninja !build/_deps !build/cmake_install.cmake !build/*.a + !build/*.lib + !build/*.dir + !build/*.vcxproj + !build/*.vcxproj.filters diff --git a/CMakeLists.txt b/CMakeLists.txt index 85d2316a..181876fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,6 +371,11 @@ RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" ${PROJECT_SOURCE_DIR}/dPhysics/*.cpp ) +if(MSVC) + # Skip warning for invalid conversion from size_t to uint32_t for all targets below for now + add_compile_options("/wd4267") +endif(MSVC) + # 3rdparty static libraries: #add_library(zlib ${SOURCES_ZLIB}) add_library(raknet ${SOURCES_RAKNET}) @@ -391,6 +396,10 @@ target_link_libraries(dNet dCommon) #Needed because otherwise linker errors occu target_link_libraries(dCommon ZLIB::ZLIB) target_link_libraries(dCommon libbcrypt) +if(WIN32) +target_link_libraries(raknet ws2_32) +endif(WIN32) + # Our executables: add_executable(WorldServer ${SOURCES}) add_executable(AuthServer ${SOURCES_AUTH}) @@ -421,9 +430,6 @@ target_link_libraries(ChatServer backtrace) endif() endif(UNIX) -if(WIN32) -target_link_libraries(WorldServer ws2_32) -endif(WIN32) target_link_libraries(WorldServer tinyxml2) # Target libraries for Auth: @@ -436,9 +442,6 @@ if(UNIX) target_link_libraries(AuthServer pthread) target_link_libraries(AuthServer dl) endif(UNIX) -if(WIN32) -target_link_libraries(AuthServer ws2_32) -endif(WIN32) # Target libraries for Master: target_link_libraries(MasterServer dCommon) @@ -450,9 +453,6 @@ if(UNIX) target_link_libraries(MasterServer pthread) target_link_libraries(MasterServer dl) endif(UNIX) -if(WIN32) -target_link_libraries(MasterServer ws2_32) -endif(WIN32) # Target libraries for Chat: target_link_libraries(ChatServer dCommon) @@ -465,9 +465,6 @@ if(UNIX) target_link_libraries(ChatServer pthread) target_link_libraries(ChatServer dl) endif(UNIX) -if(WIN32) -target_link_libraries(ChatServer ws2_32) -endif(WIN32) # Compiler flags: # Disabled deprecated warnings as the MySQL includes have deprecated code in them. diff --git a/CMakePresets.json b/CMakePresets.json index 77d41205..2e2f9bb8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -8,23 +8,39 @@ "configurePresets": [ { "name": "default", - "displayName": "Default Configure Settings", - "description": "Sets build and install directories", + "displayName": "Default configure step", + "description": "Use 'build' dir and Unix makefiles", "binaryDir": "${sourceDir}/build", "generator": "Unix Makefiles" }, + { + "name": "ci-ubuntu-20.04", + "displayName": "CI configure step for Ubuntu", + "description": "Same as default, Used in GitHub actions workflow", + "inherits": "default" + }, + { + "name": "ci-windows-2022", + "displayName": "CI configure step for Windows", + "description": "Set architecture to 64-bit (b/c RakNet)", + "inherits": "default", + "generator": "Visual Studio 17 2022", + "architecture": { + "value": "x64" + }, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, { "name": "windows-default", + "inherits": "ci-windows-2022", "displayName": "Windows only Configure Settings", "description": "Sets build and install directories", - "binaryDir": "${sourceDir}/build", "generator": "Ninja", "architecture": { "value": "x64", "strategy": "external" - }, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" } } ], @@ -35,14 +51,42 @@ "displayName": "Default Build", "description": "Default Build", "jobs": 2 + }, + { + "name": "ci-windows-2022", + "configurePreset": "ci-windows-2022", + "displayName": "Windows CI Build", + "description": "This preset is used by the CI build on windows", + "configuration": "RelWithDebInfo", + "jobs": 2 + }, + { + "name": "ci-ubuntu-20.04", + "configurePreset": "ci-ubuntu-20.04", + "displayName": "Linux CI Build", + "description": "This preset is used by the CI build on linux", + "jobs": 2 } ], "testPresets": [ { - "name": "default", - "configurePreset": "default", - "displayName": "Default Tests", - "description": "Runs all tests", + "name": "ci-ubuntu-20.04", + "configurePreset": "ci-ubuntu-20.04", + "displayName": "CI Tests on Linux", + "description": "Runs all tests on a linux configuration", + "execution": { + "jobs": 2 + }, + "output": { + "outputOnFailure": true + } + }, + { + "name": "ci-windows-2022", + "configurePreset": "ci-windows-2022", + "displayName": "CI Tests on windows", + "description": "Runs all tests on a windows configuration", + "configuration": "RelWithDebInfo", "execution": { "jobs": 2 }, diff --git a/tests/TestLDFFormat.cpp b/tests/TestLDFFormat.cpp index 276a8175..7ba31420 100644 --- a/tests/TestLDFFormat.cpp +++ b/tests/TestLDFFormat.cpp @@ -8,7 +8,7 @@ * @param argv Command line arguments * @return 0 on success, non-zero on failure */ -int TestLDFFormat(int argc, char** argv) { +int TestLDFFormat(int argc, char* *const argv) { // Create auto* data = LDFBaseData::DataFromString("KEY=0:VALUE"); diff --git a/tests/TestNiPoint3.cpp b/tests/TestNiPoint3.cpp index 68da4571..076b186d 100644 --- a/tests/TestNiPoint3.cpp +++ b/tests/TestNiPoint3.cpp @@ -3,7 +3,7 @@ #include "NiPoint3.h" #include "CommonCxxTests.h" -int TestNiPoint3(int argc, char** argv) { +int TestNiPoint3(int argc, char* *const argv) { // Check that Unitize works ASSERT_EQ(NiPoint3(3,0,0).Unitize(), NiPoint3::UNIT_X); // Check what unitize does to a vector of length 0