diff --git a/.github/workflows/msys2-cminpack-install.yaml b/.github/workflows/msys2-cminpack-install.yaml new file mode 100644 index 0000000..2a19a0c --- /dev/null +++ b/.github/workflows/msys2-cminpack-install.yaml @@ -0,0 +1,88 @@ +name: MSYS2 - Install cminpack on Windows through CMake +run-name: MSYS2 - Build, test and install cminpack on Windows through CMake +on: [push, pull_request] + +jobs: + cminpack-MSYS2: + name: cminpack (MSYS2 toolchains + CMake) + runs-on: windows-latest + + defaults: + run: + shell: cmd + + strategy: + matrix: + CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ] + CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ] + CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work + MSYS2_CONFIG: + - { sys: mingw64, env: x86_64 } + - { sys: ucrt64, env: ucrt-x86_64 } + - { sys: clang64, env: clang-x86_64 } + + env: + CMINPACK_BUILD_DIR: >- + %RUNNER_TEMP%\cminpack-build-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} + CMINPACK_INSTALL_DIR: >- + %RUNNER_TEMP%\cminpack-install-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} + + MSYS2_PACKAGES_TO_INSTALL: "mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-cc mingw-w64-${{ matrix.MSYS2_CONFIG.env }}-make" + + steps: + - name: Checkout repository to cminpack directory + uses: actions/checkout@v4 + with: + path: cminpack + + # Installing tools from MSYS2 could fail + # on a high number of concurrent jobs. + # So, we keep retrying it for a few times + - name: Install C compiler + GNU Make from MSYS2 + shell: pwsh + run: | + $install_succeeded = $false; + $max_tries = 10; + $tries = 0; + while ((-not $install_succeeded) -and ($tries -lt $max_tries)) + { + try + { + & C:\msys64\usr\bin\bash.exe -lc "pacman -S ${{ env.MSYS2_PACKAGES_TO_INSTALL }} --noconfirm" + $install_succeeded = $true; + } + catch + { + $tries++; + } + } + + if (-not $install_succeeded) + { + Write-Host "Failed to install MSYS2 packages: ${{ env.MSYS2_PACKAGES_TO_INSTALL }}"; + exit 1; + } + + - name: Place MSYS2 tools in front of system environment PATH variable + run: echo C:\msys64\${{ matrix.MSYS2_CONFIG.sys }}\bin;%PATH% >> %GITHUB_PATH% + + - name: Configure cminpack build + run: cmake -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }} + + - name: Build cminpack + run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }} + + - name: Test cminpack + run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }} + + - name: Install cminpack + run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }} + + - name: Delete checkout directory + run: rmdir /S /Q cminpack + + - name: Delete build directory + run: rmdir /S /Q ${{ env.CMINPACK_BUILD_DIR }} + + - name: Delete install directory + run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }} diff --git a/.github/workflows/ubuntu-cminpack-install.yaml b/.github/workflows/ubuntu-cminpack-install.yaml index 96a1372..2f8c9bd 100644 --- a/.github/workflows/ubuntu-cminpack-install.yaml +++ b/.github/workflows/ubuntu-cminpack-install.yaml @@ -1,9 +1,12 @@ name: Install cminpack on Ubuntu through CMake run-name: Build, test and install cminpack on Ubuntu through CMake on: [push, pull_request] + jobs: cminpack-ubuntu: + name: cminpack (GCC toolchain + CMake) runs-on: ubuntu-latest + strategy: matrix: BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ] @@ -15,32 +18,43 @@ jobs: CMAKE_BUILD_TYPE: 'RelWithDebInfo' CMINPACK_PRECISION: 'd' USE_BLAS: 'ON' + env: CMINPACK_BUILD_DIR: $RUNNER_TEMP/cminpack-build-shared-libs-${{ matrix.BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMAKE_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} CMINPACK_INSTALL_DIR: $RUNNER_TEMP/cminpack-install-shared-libs-${{ matrix.BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMAKE_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} + steps: - name: Install BLAS run: sudo apt-get install -y libopenblas-dev if: ${{ matrix.USE_BLAS == 'ON' }} + - name: Checkout repository to cminpack directory uses: actions/checkout@v4 with: path: cminpack + - name: Configure cminpack build run: cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=${{ matrix.BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMAKE_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=${{ matrix.USE_BLAS }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }} + - name: Build cminpack run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMAKE_BUILD_TYPE }} + - name: Test cminpack run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMAKE_BUILD_TYPE }} if: ${{ matrix.USE_BLAS == 'OFF' }} + - name: Test cminpack with BLAS run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMAKE_BUILD_TYPE }} --exclude-regex tlmdifc if: ${{ matrix.USE_BLAS == 'ON' }} + - name: Install cminpack run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMAKE_BUILD_TYPE }} + - name: Delete checkout directory run: rm -rf $RUNNER_TEMP/cminpack + - name: Delete build directory run: rm -rf ${{ env.CMINPACK_BUILD_DIR }} + - name: Delete install directory run: rm -rf ${{ env.CMINPACK_INSTALL_DIR }} diff --git a/.github/workflows/windows-visual-studio-cminpack-install.yaml b/.github/workflows/windows-visual-studio-cminpack-install.yaml index d2d350a..c1e80b7 100644 --- a/.github/workflows/windows-visual-studio-cminpack-install.yaml +++ b/.github/workflows/windows-visual-studio-cminpack-install.yaml @@ -1,41 +1,52 @@ name: MSVC - Install cminpack on Windows through CMake run-name: MSVC - Build, test and install cminpack on Windows through CMake on: [push, pull_request] + jobs: cminpack-visual-studio: + name: cminpack (MSVC toolchain + CMake) runs-on: windows-latest + defaults: run: shell: cmd + strategy: matrix: ARCH: [ 'x64', 'Win32'] CMINPACK_BUILD_SHARED_LIBS: [ 'ON' , 'OFF' ] CMINPACK_BUILD_TYPE: [ 'Release', 'Debug', 'RelWithDebInfo', 'MinSizeRel' ] CMINPACK_PRECISION: [ 'd' ] # seems to be the only precision that the current tests reference work + env: CMINPACK_BUILD_DIR: >- %RUNNER_TEMP%\cminpack-build-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} CMINPACK_INSTALL_DIR: >- %RUNNER_TEMP%\cminpack-install-arch-${{ matrix.ARCH }}-shared-libs-${{ matrix.CMINPACK_BUILD_SHARED_LIBS }}-build-type-${{ matrix.CMINPACK_BUILD_TYPE }}-precision-${{ matrix.CMINPACK_PRECISION }} + steps: - - name: Checkout sources with CRLF EOLs for reference test files - run: git config --global core.autocrlf true - name: Checkout repository to cminpack directory uses: actions/checkout@v4 with: path: cminpack + - name: Configure cminpack build run: cmake -DBUILD_SHARED_LIBS=${{ matrix.CMINPACK_BUILD_SHARED_LIBS }} -DCMAKE_BUILD_TYPE=${{ matrix.CMINPACK_BUILD_TYPE }} -DCMINPACK_PRECISION=${{ matrix.CMINPACK_PRECISION }} -DUSE_BLAS=OFF -A ${{ matrix.ARCH }} --install-prefix ${{ env.CMINPACK_INSTALL_DIR }} -S cminpack -B ${{ env.CMINPACK_BUILD_DIR }} + - name: Build cminpack run: cmake --build ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }} + - name: Test cminpack run: ctest --test-dir ${{ env.CMINPACK_BUILD_DIR }} --build-config ${{ matrix.CMINPACK_BUILD_TYPE }} + - name: Install cminpack run: cmake --install ${{ env.CMINPACK_BUILD_DIR }} --config ${{ matrix.CMINPACK_BUILD_TYPE }} + - name: Delete checkout directory run: rmdir /S /Q cminpack + - name: Delete build directory run: rmdir /S /Q ${{ env.CMINPACK_BUILD_DIR }} + - name: Delete install directory run: rmdir /S /Q ${{ env.CMINPACK_INSTALL_DIR }} diff --git a/CMakeLists.txt b/CMakeLists.txt index adeb880..bbc2d5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # The name of our project is "CMINPACK". CMakeLists files in this project can # refer to the root source directory of the project as ${CMINPACK_SOURCE_DIR} and # to the root binary directory of the project as ${CMINPACK_BINARY_DIR}. -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.14) if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") diff --git a/appveyor.yml b/appveyor.yml index 1f7df22..ffe2891 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,145 +1,76 @@ -version: 1.0.{build} -image: -- Visual Studio 2022 -build: - parallel: true -environment: - matrix: - - job_name: MSVC toolchain - CMAKE_CONFIG_TYPE: "Release" - GENERATOR: Visual Studio 17 2022 - - - job_name: MSYS2 x86_64 toolchain - CMAKE_CONFIG_TYPE: "Release" - SYS_MSYSTEM: 'MINGW64' - SYS_MENVIRONMENT: 'x86_64' - GENERATOR: MinGW Makefiles - - - job_name: MSYS2 UCRT64 toolchain - CMAKE_CONFIG_TYPE: "Release" - SYS_MSYSTEM: 'UCRT64' - SYS_MENVIRONMENT: 'ucrt-x86_64' - GENERATOR: MinGW Makefiles - - - job_name: MSYS2 CLANG64 toolchain - CMAKE_CONFIG_TYPE: "Release" - SYS_MSYSTEM: 'CLANG64' - SYS_MENVIRONMENT: 'clang-x86_64' - GENERATOR: MinGW Makefiles -platform: - - x64 - -init: # Only MSVC toolchain will hit here - # This is needed because reference files for tests must be checked-out with CRLF EOLs - - git config --global core.autocrlf true - -for: - # - # init specific instructions for MSYS2 x86_64 toolchain - # - - - matrix: - only: - - job_name: MSYS2 x86_64 toolchain - - init: - # This is needed because reference files for tests must be checked-out with CRLF EOLs - - git config --global core.autocrlf true - - # - # Following the guide on https://www.msys2.org/docs/ci#appveyor - # to build the project using MSYS2 toolchain on appveyor CI service - # - # Update MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Core update (in case any core packages are outdated) - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Normal update - - # Setup MSYS2 environment - - set MSYSTEM=%SYS_MSYSTEM% # Start a 64 bit Mingw environment - - # Install gcc on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-gcc" - # Install GNU Make on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-make" - - # Adjust system PATH environment variable - - set PATH=C:\msys64\%SYS_MSYSTEM%\bin;%PATH% # Place MSYS2 tools in front of system PATH - - # - # init specific instructions for MSYS2 UCRT64 toolchain - # - - - matrix: - only: - - job_name: MSYS2 UCRT64 toolchain - - init: - # This is needed because reference files for tests must be checked-out with CRLF EOLs - - git config --global core.autocrlf true - - # - # Following the guide on https://www.msys2.org/docs/ci#appveyor - # to build the project using MSYS2 toolchain on appveyor CI service - # - # Update MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Core update (in case any core packages are outdated) - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Normal update - - # Setup MSYS2 environment - - set MSYSTEM=%SYS_MSYSTEM% # Start a 64 bit Mingw environment - - # Install gcc on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-gcc" - # Install GNU Make on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-make" - - # Adjust system PATH environment variable - - set PATH=C:\msys64\%SYS_MSYSTEM%\bin;%PATH% # Place MSYS2 tools in front of system PATH - - # - # init specific instructions for MSYS2 CLANG64 toolchain - # - - - matrix: - only: - - job_name: MSYS2 CLANG64 toolchain - - init: - # This is needed because reference files for tests must be checked-out with CRLF EOLs - - git config --global core.autocrlf true - - # - # Following the guide on https://www.msys2.org/docs/ci#appveyor - # to build the project using MSYS2 toolchain on appveyor CI service - # - # Update MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Core update (in case any core packages are outdated) - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Normal update - - # Setup MSYS2 environment - - set MSYSTEM=%SYS_MSYSTEM% # Start a 64 bit Mingw environment - - # Install clang on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-clang" - # Install GNU Make on MSYS2 - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-make" - - # Adjust system PATH environment variable - - set PATH=C:\msys64\%SYS_MSYSTEM%\bin;%PATH% # Place MSYS2 tools in front of system PATH - -build_script: - # Create build dir - - mkdir build - - # Change directory to build dir - - cd build - - # Configure to build the shared library - - cmake -G "%GENERATOR%" -DBUILD_SHARED_LIBS:BOOL=ON .. - - # Perform the build - - cmake --build . --config %CMAKE_CONFIG_TYPE% -test_script: - - # Perform tests - - ctest --output-on-failure -C %CMAKE_CONFIG_TYPE% +version: 1.0.{build} +image: +- Visual Studio 2022 +build: + parallel: true +environment: + matrix: + - job_name: MSVC toolchain + CMAKE_CONFIG_TYPE: "Release" + GENERATOR: Visual Studio 17 2022 + + - job_name: MSYS2 x86_64 toolchain + CMAKE_CONFIG_TYPE: "Release" + SYS_MSYSTEM: 'MINGW64' + SYS_MENVIRONMENT: 'x86_64' + GENERATOR: MinGW Makefiles + + - job_name: MSYS2 UCRT64 toolchain + CMAKE_CONFIG_TYPE: "Release" + SYS_MSYSTEM: 'UCRT64' + SYS_MENVIRONMENT: 'ucrt-x86_64' + GENERATOR: MinGW Makefiles + + - job_name: MSYS2 CLANG64 toolchain + CMAKE_CONFIG_TYPE: "Release" + SYS_MSYSTEM: 'CLANG64' + SYS_MENVIRONMENT: 'clang-x86_64' + GENERATOR: MinGW Makefiles +platform: + - x64 + +for: + # + # init specific instructions for MSYS2 toolchains + # + - + matrix: + only: + - job_name: MSYS2 x86_64 toolchain + - job_name: MSYS2 UCRT64 toolchain + - job_name: MSYS2 CLANG64 toolchain + + init: + # + # Following the guide on https://www.msys2.org/docs/ci#appveyor + # to build the project using MSYS2 toolchain on appveyor CI service + # + # Update MSYS2 + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Core update (in case any core packages are outdated) + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" # Normal update + + # Setup MSYS2 environment + - set MSYSTEM=%SYS_MSYSTEM% # Start a 64 bit Mingw environment + + # Install C compiler + GNU Make on MSYS2 + - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-%SYS_MENVIRONMENT%-cc mingw-w64-%SYS_MENVIRONMENT%-make" + + # Adjust system PATH environment variable + - set PATH=C:\msys64\%SYS_MSYSTEM%\bin;%PATH% # Place MSYS2 tools in front of system PATH + +build_script: + # Create build dir + - mkdir build + + # Change directory to build dir + - cd build + + # Configure to build the shared library + - cmake -G "%GENERATOR%" -DBUILD_SHARED_LIBS:BOOL=ON .. + + # Perform the build + - cmake --build . --config %CMAKE_CONFIG_TYPE% +test_script: + + # Perform tests + - ctest --output-on-failure -C %CMAKE_CONFIG_TYPE% \ No newline at end of file diff --git a/examples/runtest.cmake b/examples/runtest.cmake index 8544dc3..d3124b4 100644 --- a/examples/runtest.cmake +++ b/examples/runtest.cmake @@ -27,7 +27,7 @@ if(NOT ${RET} EQUAL 0) endif() # result with reference execute_process(COMMAND "${CMAKE_COMMAND}" - -E compare_files "${OUTPUT}" "${REFERENCE}" + -E compare_files --ignore-eol "${OUTPUT}" "${REFERENCE}" RESULT_VARIABLE RET) # if the test does not return 0, then fail it if(NOT ${RET} EQUAL 0)