浏览代码

Merge pull request #3168 from lukka/master

Use clang on Unix, msvc on Windows, Use Ninja everywhere
Kim Kulling 5 年之前
父节点
当前提交
0a66a2c670
共有 4 个文件被更改,包括 54 次插入37 次删除
  1. 38 32
      .github/workflows/ccpp.yml
  2. 3 3
      CMakeLists.txt
  3. 6 1
      code/glTF/glTFAsset.h
  4. 7 1
      code/glTF2/glTF2Asset.h

+ 38 - 32
.github/workflows/ccpp.yml

@@ -7,40 +7,46 @@ on:
     branches: [ master ]
 
 jobs:
-  linux:
-    runs-on: ubuntu-latest
-    
+  job:
+    name: ${{ matrix.os }}-build-and-test
+    runs-on: ${{ matrix.os }}
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, macos-latest, windows-latest]
+        # For Windows msvc, for Linux and macOS let's use the clang compiler
+        include:
+          - os: windows-latest
+            cxx: cl.exe
+            cc: cl.exe
+          - os: ubuntu-latest
+            cxx: clang++
+            cc: clang
+          - os: macos-latest
+            cxx: clang++
+            cc: clang
+
     steps:
     - uses: actions/checkout@v2
-    - name: configure
-      run: cmake CMakeLists.txt
-    - name: build
-      run: cmake --build .
-    - name: test
-      run: cd bin && ./unit
-  
-  mac:
-    runs-on: macos-latest
     
-    steps:
-    - uses: actions/checkout@v2
-    - name: configure
-      run: cmake CMakeLists.txt
-    - name: build
-      run: cmake --build .
-    - name: test
-      run: cd bin && ./unit
-
-  windows:
-    runs-on: windows-latest
+    - uses: lukka/get-cmake@latest
     
-    steps:
-    - uses: actions/checkout@v2
-    - name: configure
-      run: cmake CMakeLists.txt
-    - name: build
-      run: cmake --build . --config Release
+    - uses: ilammy/msvc-dev-cmd@v1
+    
+    - uses: lukka/set-shell-env@v1
+      with:
+        CXX: ${{ matrix.cxx }}
+        CC: ${{ matrix.cc }}
+    
+    - name: configure and build
+      uses: lukka/run-cmake@v2
+      with:
+        cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
+        cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
+        cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release'
+        buildWithCMakeArgs: '-- -v'
+        buildDirectory: '${{ github.workspace }}/build/'
+        
     - name: test
-      run: | 
-        cd bin\Release
-        .\unit
+      run: cd build/bin && ./unit
+      shell: bash

+ 3 - 3
CMakeLists.txt

@@ -267,10 +267,10 @@ ELSEIF(MSVC)
   SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od")
 ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
   IF(NOT ASSIMP_HUNTER_ENABLED)
-    SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}")
-    SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
+    SET(CMAKE_CXX_STANDARD 11)
+    SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
   ENDIF()
-  SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
+  SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
   SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}")
 ELSEIF( CMAKE_COMPILER_IS_MINGW )
   IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)

+ 6 - 1
code/glTF/glTFAsset.h

@@ -382,7 +382,12 @@ namespace glTF
         {
             friend struct Accessor;
 
-            Accessor& accessor;
+        // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
+        // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field]
+        protected:
+            Accessor &accessor;
+
+        private:
             uint8_t* data;
             size_t elemSize, stride;
 

+ 7 - 1
code/glTF2/glTF2Asset.h

@@ -389,12 +389,18 @@ struct Accessor : public Object {
     class Indexer {
         friend struct Accessor;
 
+    // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is:
+    // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field]
+    protected:
         Accessor &accessor;
+
+    private:
         uint8_t *data;
         size_t elemSize, stride;
 
         Indexer(Accessor &acc);
-
+    
+        
     public:
         //! Accesses the i-th value as defined by the accessor
         template <class T>