diff --git a/.github/workflows/cmake-build.yml b/.github/workflows/cmake-build.yml index ea5dc6f..78f33f1 100644 --- a/.github/workflows/cmake-build.yml +++ b/.github/workflows/cmake-build.yml @@ -2,19 +2,17 @@ name: CI Matrix on: [push, pull_request] -env: - BUILD_TYPE: Release - jobs: build: - name: ${{ matrix.config.name }} + name: '${{ matrix.config.name }} - ${{ matrix.build-type }}' runs-on: ${{ matrix.config.os }} strategy: fail-fast: false matrix: + build-type: [Release, Debug] config: - { - name: "windows-latest", + name: "windows-latest-ninja", os: windows-latest, artifact: "Windows-MSVC.7z", build_type: "Release", @@ -24,6 +22,28 @@ jobs: archiver: "7z a", generators: "Visual Studio 17 2022", } + - { + name: "windows-latest-nmake", + os: windows-latest, + artifact: "Windows-MSVC.7z", + build_type: "Release", + cc: "cl", + cxx: "cl", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + archiver: "7z a", + generators: "Visual Studio 17 2022", + } + - { + name: "windows-msvc", + os: windows-2019, + artifact: "Windows-MSVC.7z", + build_type: "Release", + cc: "cl", + cxx: "cl", + environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + archiver: "7z a", + generators: "Visual Studio 17 2022", + } - { name: "ubuntu-latest", os: ubuntu-latest, @@ -89,11 +109,12 @@ jobs: uses: abdes/gha-setup-ninja@master with: version: 1.11.0 + if: ${{ !endsWith(matrix.config.name, 'msvc') }} - name: Setup cmake uses: jwlawson/actions-setup-cmake@v1.13 with: - cmake-version: 3.21.x + cmake-version: 3.20.0 - name: Install ccache shell: cmake -P {0} @@ -188,17 +209,25 @@ jobs: set(OMP "OFF") endif() + if ("${{ matrix.config.name }}" STREQUAL "windows-msvc") + set(Generator -G "Visual Studio 16 2019") + elseif("${{ matrix.config.name }}" STREQUAL "windows-latest-nmake") + set(Generator -G "NMake Makefiles" -D CMAKE_MAKE_PROGRAM=nmake) + else() + set(Generator -G Ninja -D CMAKE_MAKE_PROGRAM=ninja) + endif() + execute_process( COMMAND cmake -S . -B build - -D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE} - -G Ninja - -D CMAKE_MAKE_PROGRAM=ninja + -D CMAKE_BUILD_TYPE=${{ matrix.build-type }} + ${Generator} -D USE_CCACHE=${enable_ccache} -D CMAKE_VERBOSE_MAKEFILE=ON -D USE_OPENMP=${OMP} RESULT_VARIABLE result + COMMAND_ECHO STDOUT ) if (NOT result EQUAL 0) message(FATAL_ERROR "Bad exit status") @@ -219,7 +248,7 @@ jobs: endif() execute_process( - COMMAND cmake --build build --target all + COMMAND cmake --build build --config ${{ matrix.build-type }} RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE output @@ -241,8 +270,17 @@ jobs: set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + execute_process( - COMMAND ctest "--verbose" "-R" "cryptest" + COMMAND ctest "--verbose" "-R" "cryptest" "-C" "${{ matrix.build-type }}" WORKING_DIRECTORY build RESULT_VARIABLE result OUTPUT_VARIABLE output @@ -265,8 +303,17 @@ jobs: set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON") + if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") + file(STRINGS environment_script_output.txt output_lines) + foreach(line IN LISTS output_lines) + if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") + set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") + endif() + endforeach() + endif() + execute_process( - COMMAND ctest "-E" "cryptest" + COMMAND ctest "-E" "cryptest" "-C" "${{ matrix.build-type }}" WORKING_DIRECTORY build RESULT_VARIABLE result OUTPUT_VARIABLE output @@ -281,7 +328,7 @@ jobs: endif() - name: Install Strip - run: cmake --install build --prefix instdir --strip + run: cmake --install build --prefix instdir --strip --config ${{ matrix.build-type }} - name: Pack working-directory: instdir @@ -322,7 +369,7 @@ jobs: publish: if: contains(github.ref, 'tags/CRYPTOPP_') - name: ${{ matrix.config.name }} + name: 'Publish ${{ matrix.config.name }}' runs-on: ${{ matrix.config.os }} strategy: fail-fast: false @@ -374,3 +421,96 @@ jobs: asset_path: ./${{ matrix.config.artifact }} asset_name: ${{ matrix.config.artifact }} asset_content_type: application/x-gtar + msys-build: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build-type: [Release, Debug] + sys: [mingw32, mingw64, ucrt64, clang64] + name: 'MSys - ${{ matrix.sys }} - ${{ matrix.build-type }}' + defaults: + run: + shell: msys2 {0} + steps: + - name: 'Checkout' + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: 'Setup MSYS2' + uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + update: true + install: >- + git + make + pacboy: >- + toolchain:p + cmake:p + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + with: + prepend_symlinks_to_path: false + windows_compile_environment: msys2 + - name: 'Configure' + run: | + cmake -G"Unix Makefiles" -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DUSE_CCACHE=ON -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} + - name: 'Build' + run: | + cmake --build build + - name: 'Run cryptest' + run: | + ctest --test-dir build --verbose -R cryptest + - name: 'Run tests' + run: | + ctest --test-dir build --output-on-failure -E cryptest + + cygwin-build: + strategy: + fail-fast: false + matrix: + build-type: [Release, Debug] + runs-on: windows-latest + name: 'Cygwin - ${{ matrix.build-type }}' + steps: + - name: 'Checkout' + env: + HOME: C:\cygwin\home\runneradmin + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: 'Setup cygwin' + uses: cygwin/cygwin-install-action@master + with: + packages: >- + ccache + cmake + gcc-g++ + git + ninja + - name: 'Removing ccache from choco' + run: | + Remove-Item -Path C:\ProgramData\Chocolatey\bin\ccache.exe -Verbose + - name: Setup ccache + uses: Chocobo1/setup-ccache-action@v1 + with: + install_ccache: false + prepend_symlinks_to_path: false + update_packager_index: false + windows_compile_environment: msvc + - name: 'Configure' + run: | + cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -D CMAKE_VERBOSE_MAKEFILE=ON -D USE_CCACHE=ON -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} + - name: 'Build' + run: | + cmake --build build + - name: 'Run cryptest' + run: | + ctest --test-dir build --verbose -R cryptest + - name: Run tests + run: | + ctest --test-dir build --verbose -E cryptest + - name: 'Workaround git warning' + run: | + git config --global --add safe.directory /cygdrive/d/a/cryptopp-cmake/cryptopp-cmake diff --git a/cmake/TargetArch.cmake b/cmake/TargetArch.cmake index effac62..056b220 100644 --- a/cmake/TargetArch.cmake +++ b/cmake/TargetArch.cmake @@ -17,6 +17,12 @@ set(archdetect_c_code # error cmake_ARCH arm # endif +#elif defined(__CYGWIN__) + #error cmake_ARCH cygwin +#elif defined(__MINGW64__) + #error cmake_ARCH mingw64 +#elif defined(__MINGW32__) + #error cmake_ARCH mingw32 #elif defined(__i386) || defined(__i386__) || defined(_M_IX86) #error cmake_ARCH i386 #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) diff --git a/cryptopp/CMakeLists.txt b/cryptopp/CMakeLists.txt index d8c44c6..981f28f 100644 --- a/cryptopp/CMakeLists.txt +++ b/cryptopp/CMakeLists.txt @@ -215,11 +215,22 @@ check_target_architecture(CRYPTOPP_AMD64 "(x86_64|amd64)") check_target_architecture(CRYPTOPP_I386 "^i.86$") check_target_architecture(CRYPTOPP_MINGW32 "^mingw32") check_target_architecture(CRYPTOPP_MINGW64 "(w64-mingw32|mingw64)") +check_target_architecture(CRYPTOPP_CYGWIN "(^cygwin)") check_target_architecture(CRYPTOPP_ARMV8 "(armv8|arm64|aarch32|aarch64)") check_target_architecture(CRYPTOPP_ARM32 "(^arm$|arm32|armhf|arm7l|eabihf)") check_target_architecture(CRYPTOPP_PPC32 "^(powerpc|ppc)") check_target_architecture(CRYPTOPP_PPC64 "^ppc64") +if (CRYPTOPP_MINGW32 AND NOT DISABLE_ASM) + message (STATUS "[cryptopp] Disabling ASM on MinGW32") + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "CRYPTOPP_DISABLE_ASM=1") +endif() + +if (CRYPTOPP_CYGWIN AND NOT DISABLE_ASM) + message (STATUS "[cryptopp] Disabling ASM on Cygwin") + list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "CRYPTOPP_DISABLE_ASM=1") +endif() + # Cleanup 32/64 bit if(CRYPTOPP_AMD64) set(CRYPTOPP_I386 0) @@ -409,7 +420,7 @@ include(sources) # X86/X32/X64 Options ##### # ############################################################################## -if((CRYPTOPP_I386 OR CRYPTOPP_AMD64) AND NOT MSVC) +if((CRYPTOPP_I386 OR CRYPTOPP_AMD64 OR MINGW) AND NOT MSVC) if(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") set(sse2_flag "-xarch=sse2") set(sse3_flag "-xarch=sse3") @@ -1233,7 +1244,8 @@ if(CRYPTOPP_BUILD_TESTING) DESTINATION ${PROJECT_BINARY_DIR}) add_test(NAME build_cryptest COMMAND "${CMAKE_COMMAND}" --build - ${CMAKE_BINARY_DIR} --target cryptest) + ${PROJECT_BINARY_DIR} --target cryptest + --config ${CMAKE_BUILD_TYPE}) add_test( NAME cryptest COMMAND $ v @@ -1356,6 +1368,8 @@ elseif(CRYPTOPP_MINGW32) message(STATUS "[cryptopp] Platform: MinGW-32") elseif(CRYPTOPP_MINGW64) message(STATUS "[cryptopp] Platform: MinGW-64") +elseif(CRYPTOPP_CYGWIN) + message(STATUS "[cryptopp] Platform: Cygwin") endif() if(CRYPTOPP_HAVE_ARM_NEON) message(STATUS "[cryptopp] NEON: TRUE") diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index cb3404c..66ee353 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -14,7 +14,7 @@ foreach(test ${tests}) message(STATUS "Adding install integration test: ${test_name}") # Configure add_test( - NAME ${test_name}-configure + NAME cryptopp-${test_name}-configure COMMAND ${CMAKE_COMMAND} # Always use ninja, never the visual studio generator (bugged) @@ -39,30 +39,35 @@ foreach(test ${tests}) # Enable verbose makefiles so we can see the full compile command line -D "CMAKE_VERBOSE_MAKEFILE=ON" # Throw the version in - -D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION}) + -D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION} + # Replicate the build-type + -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) # Build - add_test(NAME ${test_name}-build + add_test(NAME cryptopp-${test_name}-build COMMAND ${CMAKE_COMMAND} --build - "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test") - set_tests_properties(${test_name}-build PROPERTIES DEPENDS - ${test_name}-configure) + "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" + --config ${CMAKE_BUILD_TYPE}) + set_tests_properties(cryptopp-${test_name}-build PROPERTIES DEPENDS + cryptopp-${test_name}-configure) # Install add_test( - NAME ${test_name}-install + NAME cryptopp-${test_name}-install COMMAND ${CMAKE_COMMAND} --build - "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" --target install) - set_tests_properties(${test_name}-install PROPERTIES DEPENDS - ${test_name}-build) + "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" --target install + --config ${CMAKE_BUILD_TYPE}) + set_tests_properties(cryptopp-${test_name}-install PROPERTIES DEPENDS + cryptopp-${test_name}-build) # Check installed files add_test( - NAME ${test_name}-checks + NAME cryptopp-${test_name}-checks COMMAND ${CMAKE_COMMAND} --build - "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" --target do-checks) - set_tests_properties(${test_name}-checks PROPERTIES DEPENDS - ${test_name}-install) + "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" --target do-checks + --config ${CMAKE_BUILD_TYPE}) + set_tests_properties(cryptopp-${test_name}-checks PROPERTIES DEPENDS + cryptopp-${test_name}-install) endforeach() # ------------------------------------------------------------------------------ @@ -73,7 +78,7 @@ set(test_name "int-find-package") # Configure add_test( - NAME ${test_name}-configure + NAME cryptopp-${test_name}-configure COMMAND ${CMAKE_COMMAND} # Always use ninja, never the visual studio generator (bugged) @@ -88,17 +93,20 @@ add_test( # Enable verbose makefiles so we can see the full compile command line -D "CMAKE_VERBOSE_MAKEFILE=ON" # Throw the version in - -D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION}) + -D CRYPTOPP_MINIMUM_CMAKE_VERSION=${CRYPTOPP_MINIMUM_CMAKE_VERSION} + # Replicate the build-type + -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}) -set_tests_properties(${test_name}-configure - PROPERTIES DEPENDS "int-install-default-install") +set_tests_properties(cryptopp-${test_name}-configure + PROPERTIES DEPENDS "cryptopp-int-install-default-install") # Build -add_test(NAME ${test_name}-build +add_test(NAME cryptopp-${test_name}-build COMMAND ${CMAKE_COMMAND} --build - "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test") -set_tests_properties(${test_name}-build PROPERTIES DEPENDS - ${test_name}-configure) + "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test" + --config ${CMAKE_BUILD_TYPE}) +set_tests_properties(cryptopp-${test_name}-build PROPERTIES DEPENDS + cryptopp-${test_name}-configure) -set_tests_properties(int-install-prefix-configure - PROPERTIES DEPENDS "int-find-package-build") +set_tests_properties(cryptopp-int-install-prefix-configure + PROPERTIES DEPENDS "cryptopp-int-find-package-build") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index ecc6370..c0b1a16 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -10,7 +10,7 @@ foreach(test ${tests}) message(STATUS "Adding unit test: ${test_name}") # Configure add_test( - NAME ${test_name}-configure + NAME cryptopp-${test_name}-configure COMMAND ${CMAKE_COMMAND} # Always use ninja, never the visual studio generator (bugged) @@ -31,10 +31,10 @@ foreach(test ${tests}) # Enable verbose makefiles so we can see the full compile command line -D CMAKE_VERBOSE_MAKEFILE=ON) # Build - add_test(NAME ${test_name}-build + add_test(NAME cryptopp-${test_name}-build COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/${test_name}-test") # Run build test case after the configure test case - set_tests_properties(${test_name}-build PROPERTIES DEPENDS - ${test_name}-configure) + set_tests_properties(cryptopp-${test_name}-build PROPERTIES DEPENDS + cryptopp-${test_name}-configure) endforeach()