Do not add -lm to Libs.private if WIN32 or APPLE In Windows and Apple operating systems, the functions declared in <math.h> are defined in the main standard C library rather than a separate libm. Do not add -lm to the Libs.private field in aom.pc if WIN32 or APPLE is true. This condition matches the condition under which we link the aom and aom_av1_rc libraries with -lm in CMakeLists.txt. Bug: 356153293 Change-Id: Ic42c84b0583aafa4491e393d691939c293415986 (cherry picked from commit 74c99dfe6d63535b9a033322c85581391eba913c)
diff --git a/build/cmake/pkg_config.cmake b/build/cmake/pkg_config.cmake index c4f9480..a229c00 100644 --- a/build/cmake/pkg_config.cmake +++ b/build/cmake/pkg_config.cmake
@@ -60,10 +60,11 @@ endif() file(APPEND "${pkgconfig_file}" "\nConflicts:\n") file(APPEND "${pkgconfig_file}" "Libs: -L\${libdir} -l${pkg_name}\n") -if(CONFIG_MULTITHREAD AND CMAKE_THREAD_LIBS_INIT) - file(APPEND "${pkgconfig_file}" - "Libs.private: -lm ${CMAKE_THREAD_LIBS_INIT}\n") -else() - file(APPEND "${pkgconfig_file}" "Libs.private: -lm\n") +file(APPEND "${pkgconfig_file}" "Libs.private:") +if(NOT WIN32 AND NOT APPLE) + file(APPEND "${pkgconfig_file}" " -lm") endif() -file(APPEND "${pkgconfig_file}" "Cflags: -I\${includedir}\n") +if(CONFIG_MULTITHREAD AND CMAKE_THREAD_LIBS_INIT) + file(APPEND "${pkgconfig_file}" " ${CMAKE_THREAD_LIBS_INIT}") +endif() +file(APPEND "${pkgconfig_file}" "\nCflags: -I\${includedir}\n")