AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.51k stars 191 forks source link

CMake fails in tests/CMakeLists.txt "No known features for CXX compiler" if -DAVIF_BUILD_TESTS=ON -DAVIF_BUILD_APPS=OFF #2300

Closed wantehchang closed 1 month ago

wantehchang commented 1 month ago

Steps to reproduce:

On a Linux computer, run the cmake command:

cmake .. -G Ninja -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=OFF -DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL -DAVIF_BUILD_APPS=OFF

It fails with these messages:

-- libavif(AVIF_GTEST=LOCAL): compiled library not found in ext/googletest; using FetchContent
-- libavif(AVIF_LOCAL_GTEST): fetching and configuring googletest
-- Found Python3: /usr/bin/python3 (found version "3.11.8") found components: Interpreter 
-- libavif(AVIF_LOCAL_GTEST): fetching and configuring googletest - complete
-- Some tests are skipped because libsharpyuv is unavailable.
-- FuzzTest targets are disabled because AVIF_ENABLE_FUZZTEST is OFF.
-- Configuring done (26.6s)
CMake Error in tests/CMakeLists.txt:
  No known features for CXX compiler

  ""

  version .

CMake Generate step failed.  Build files cannot be regenerated correctly.

If I run the cmake command again, it succeeds, and I can build and run the tests (using ctest) successfully.

If I change -DAVIF_BUILD_APPS=OFF to -DAVIF_BUILD_APPS=ON, it also works.

wantehchang commented 1 month ago

Here is a variant of this bug. Run the command:

cmake .. -G Ninja -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=OFF -DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=LOCAL

I get these CMake error messages:

-- Configuring done (0.9s)
CMake Error: CMake can not determine linker language for target: aviftest_helpers
CMake Error: CMake can not determine linker language for target: aviftest_helpers_internal
CMake Error: CMake can not determine linker language for target: avifincrtest_helpers
CMake Error: CMake can not determine linker language for target: avifallocationtest
CMake Error: CMake can not determine linker language for target: avifalphanoispetest
...
CMake Error: CMake can not determine linker language for target: avifutilstest
CMake Error: CMake can not determine linker language for target: avify4mtest
-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
vrabaud commented 1 month ago

The other related error is if everything is compiled as C, repro_avif_decode_fuzzer in the tests still requires C++.

cmake .. -G Ninja -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=OFF -DAVIF_BUILD_TESTS=ON -DAVIF_GTEST=OFF -DAVIF_ENABLE_GTEST=OFF

triggers:

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILE_OBJECT