Cmake cannot find glib-object.h

Hello! I am trying to package an upstream project and am running into issues building it in certain environments. I am not well versed in cmake, and am trying to package it without directly modifying the upstream. I have tried many combinations of cmake CLI variables and have been unsuccessful at completing a build. Here is some output from the build process for context

Executing action                                                                                                                                                                            
:: + cmake /root/parts/corectrl/src -G 'Unix Makefiles' -DCMAKE_EXE_LINKER_FLAGS:STRING=-Wl,--copy-dt-needed-entries -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DBINARY_PACKAGE_BUILD=ON -DCMAKE_INCLUDE_SYSTEM_FLAG_C=isystem -DCMAKE_INCLUDE_SYSTEM_FLAG_CXX=isystem '-DCMAKE_SYSTEM_PREFIX_PATH=/root/stage/usr;/snap/kf5-5-105-qt-5-15-9-core22-sdk/current/usr/;/usr'                                                                                                                                                                           
:: Using bundled fmt library                                                                                                                                                                
:: Using bundled pugixml library                                                                                                                                                            
:: Using bundled units library                                                                                                                                                              
:: Using bundled easyloggingpp library                                                                                                                                                      
:: D-Bus files will be installed into /root/parts/corectrl/install/usr/share/dbus-1                                                                                                         
:: -- Configuring done                                                                                                                                                                                                                                                                                   
::                                                                                                                                                                                                                                                                                                                                                              
:: -- Generating done                                                                                                                                                                       
:: CMake Warning:                                                                                                                                                                           
::   Manually-specified variables were not used by the project:                                                                                                                             
::                                                                                                                                                                                          
::     BINARY_PACKAGE_BUILD                                                                                                                                                                 
::     CMAKE_INCLUDE_SYSTEM_FLAG_C                                                                                                                                                          
::                                                                                                                                                                                          
::                                                                                                                                                                                          
:: -- Build files have been written to: /root/parts/corectrl/build                                                                                                                          
:: + cmake --build . -- -j16                                                                                                                                                                
:: [  0%] Automatic MOC for target corectrl_lib                                                                                                                                             
:: [  1%] Automatic MOC for target corectrl_helper                                                                                                                                          
:: [  1%] Automatic MOC for target corectrl_helperkiller                                                                                                                                    
:: [  1%] Built target corectrl_helperkiller_autogen                                                                                                                                        
:: [  1%] Built target corectrl_helper_autogen                                                                                                                                              
:: Consolidate compiler generated dependencies of target corectrl_helperkiller                                                                                                              
:: Consolidate compiler generated dependencies of target corectrl_helper                                                                                                                    
:: [  2%] Building CXX object src/helper/CMakeFiles/corectrl_helperkiller.dir/polkit.cpp.o                                                                                                  
:: [  2%] Built target corectrl_lib_autogen                                                                                                                                                 
:: [  3%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/procpidsolver.cpp.o                                                                                            
:: [  3%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/polkit.cpp.o                                                                                                        
:: [  4%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/processregistry.cpp.o                                                                                          
:: [  4%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/nlprocexecmonitor.cpp.o                                                                                        
:: [  4%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/nlprocexecsocket.cpp.o                                                                                         
:: [  4%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/appregistry.cpp.o                                                                                              
:: [  5%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/sysctl/sysfswriter.cpp.o                                                                                            
:: [  4%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/sysctl/msgreceiver.cpp.o                                                                                            
:: [  5%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/pmon/msgdispatcher.cpp.o                                                                                            
:: In file included from /usr/include/polkit-1/polkit/polkit.h:27,                                                                                                                          
::                  from /root/parts/corectrl/src/src/helper/polkit.cpp:7:                                                                                                                  
:: /usr/include/polkit-1/polkit/polkittypes.h:25:10: fatal error: glib-object.h: No such file or directory                                                                                  
::    25 | #include <glib-object.h>                                                                                                                                                         
::       |          ^~~~~~~~~~~~~~~                                                                                                                                                         
:: compilation terminated.                                                                                                                                                                  
:: gmake[2]: *** [src/helper/CMakeFiles/corectrl_helper.dir/build.make:104: src/helper/CMakeFiles/corectrl_helper.dir/polkit.cpp.o] Error 1                                                 
:: gmake[2]: *** Waiting for unfinished jobs....                                                                                                                                            
:: In file included from /usr/include/polkit-1/polkit/polkit.h:27,                                                                                                                          
::                  from /root/parts/corectrl/src/src/helper/polkit.cpp:7:                                                                                                                  
:: /usr/include/polkit-1/polkit/polkittypes.h:25:10: fatal error: glib-object.h: No such file or directory                                                                                  
::    25 | #include <glib-object.h>                                                                                                                                                         
::       |          ^~~~~~~~~~~~~~~                                                                                                                                                         
:: compilation terminated.                                                                                                                                                                  
:: gmake[2]: *** [src/helper/CMakeFiles/corectrl_helperkiller.dir/build.make:104: src/helper/CMakeFiles/corectrl_helperkiller.dir/polkit.cpp.o] Error 1                                     
:: gmake[1]: *** [CMakeFiles/Makefile2:254: src/helper/CMakeFiles/corectrl_helperkiller.dir/all] Error 2                                                                                    
:: gmake[1]: *** Waiting for unfinished jobs....                                                                                                                                            
:: Consolidate compiler generated dependencies of target corectrl_lib                                                                                                                       
:: [  5%] Linking CXX shared library libcorectrl.so                                                                                                                                         
:: [ 91%] Built target corectrl_lib                                                                                                                                                         
:: gmake[1]: *** [CMakeFiles/Makefile2:280: src/helper/CMakeFiles/corectrl_helper.dir/all] Error 2                                                                                          
:: gmake: *** [Makefile:136: all] Error 2                                                                                                                                                   

The missing header file is located here /snap/kf5-5-105-qt-5-15-9-core22-sdk/7/usr/include/glib-2.0/glib-object.h. What is the correct way to include this header file in the build process?

It appears as though the project in question is using polkit which is (probably) found via pkg-config. Something is missing to have pkg-config find the dependencies and add them to the interface. Within the environment that is doing the build, does querying pkg-config for polkit bits give back -I paths with glib-object.h in them? If so, then CMake (either project code or CMake itself) needs to do some work for this case). If it is not, then the environment is not satisfying the .pc dependencies properly. Or it’s something else completely.

This turned out to be an issue with some of the tooling overriding the CLI args and was fixed upstream.