diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..94c23d8 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,99 @@ +name: CMake + +on: + push: + branches: [ "winport" ] + pull_request: + branches: [ "winport" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + XX_BUILD_TYPE: Debug + +jobs: + create_github_release: + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + id: ${{ steps.create_release.outputs.id }} + steps: + - uses: actions/checkout@v3 + - name: Get OpenFST version + id: get_openfst_version + run: | + OPENFST_VER_STRING=$(grep -E 'AC_INIT\(\[OpenFst\]' configure.ac | sed 's/.*\[\([0-9][0-9.]*\)\].*/\1/g') + echo "openfst_ver=${OPENFST_VER_STRING}" >> $GITHUB_OUTPUT + - name: Create Draft Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: autorelease/${{ github.run_number }} + release_name: Release ${{ steps.get_openfst_version.outputs.openfst_ver }}-${{ github.run_number }} + draft: true + prerelease: false + + job_matrix: + strategy: + matrix: + os: [windows-2019, windows-2022] + build_type: [Release, Debug] + runs-on: ${{ matrix.os }} + needs: [create_github_release] + steps: + - uses: actions/checkout@v3 + + - name: Get Conan + # You may pin to the exact commit or the version. + # uses: turtlebrowser/get-conan@368dfd1b36f811723d7db981352dd77cd69c2c9e + uses: turtlebrowser/get-conan@v1.1 + + - name: Create default profile + run: conan profile new default --detect + + - name: Install dependencies + run: conan install . -s build_type=${{matrix.build_type}} --install-folder=${{github.workspace}}/build --build=missing + + - 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=${{matrix.build_type}} -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/${{matrix.os}}-${{matrix.build_type}} + + - name: Build + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}} + env: + CMAKE_BUILD_PARALLEL_LEVEL: 4 +# - name: Test +# working-directory: ${{github.workspace}}/build +# # Execute tests defined by the CMake configuration. +# # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail +# run: ctest -C ${{env.BUILD_TYPE}} + - name: Install + run: | + echo on + mkdir ${{github.workspace}}/${{matrix.os}}-${{matrix.build_type}} + cmake --install ${{github.workspace}}/build --prefix ${{github.workspace}}/${{matrix.os}}-${{matrix.build_type}} --config ${{matrix.build_type}} + cd ${{github.workspace}} + tar -czf ${{matrix.os}}-${{matrix.build_type}}.tar.gz ${{matrix.os}}-${{matrix.build_type}} + + - uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create_github_release.outputs.upload_url}} + asset_path: ./${{matrix.os}}-${{matrix.build_type}}.tar.gz + asset_name: ${{matrix.os}}-${{matrix.build_type}}.tar.gz + asset_content_type: application/gzip + + publish_github_release: + needs: [create_github_release, job_matrix] + runs-on: ubuntu-latest + steps: + - uses: eregon/publish-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + release_id: ${{ needs.create_github_release.outputs.id}} + diff --git a/CMakeLists.txt b/CMakeLists.txt index f6189db..2fe9f34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ project(openfst) include(CTest) + +if (WIN32) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif () + + find_package(ICU COMPONENTS data i18n io test tu uc) if (ICU_FOUND) include_directories(${ICU_INCLUDE_DIRS}) @@ -17,13 +24,13 @@ set(CMAKE_MACOSX_RPATH 1) set(CMAKE_CXX_STANDARD 11) if (WIN32) - add_definitions(/bigobj) + add_definitions(-DNOMINMAX -D_USE_MATH_DEFINES -DFST_NO_DYNAMIC_LINKING) + add_compile_options(/W0 /bigobj /wd4244 /wd4267 ) set(WHOLEFST "/WHOLEARCHIVE:fst") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${WHOLEFST}") - #set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS 1) - #this must be disabled unless the previous option (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS) is enabled option(BUILD_SHARED_LIBS "Build shared libraries" OFF) else() + set(CMAKE_POSITION_INDEPENDENT_CODE ON) option(BUILD_SHARED_LIBS "Build shared libraries" ON) endif (WIN32) diff --git a/conanfile b/conanfile new file mode 100644 index 0000000..dfa921d --- /dev/null +++ b/conanfile @@ -0,0 +1,6 @@ +[generators] +cmake + +[requires] +zlib/1.2.11 +icu/[>65.0] diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..8998763 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,6 @@ +[generators] +cmake + +[requires] +zlib/[>1.0.0] +icu/[>65.0]