I’m writing a find module for php-config
. I need to run a bunch of commands to gather what I need e.g.
php-config --includes
php-config --ldflags
php-config --libs
php-config --version
So, I have an execute_process
for each of them. In the past I’ve used something like find_package_handle_standard_args
to handle these, but in this case it’s fine if they are empty. For instance, on the PHP 8.1.0rc1 release I just built --ldflags
is empty because all libs used were in standard locations.
For now I have a series of checks for the RESULT_VARIABLE
e.g.
if(PhpConfig_INCLUDES_RESULT AND NOT PhpConfig_INCLUDES_RESULT EQUAL 0)
return()
endif()
if(PhpConfig_LDFLAGS_RESULT AND NOT PhpConfig_LDFLAGS_RESULT EQUAL 0)
return()
endif()
if(PhpConfig_LIBS_RESULT AND NOT PhpConfig_LIBS_RESULT EQUAL 0)
return()
endif()
if(PhpConfig_VERSION_RESULT AND NOT PhpConfig_VERSION_RESULT EQUAL 0)
return()
endif()
Is there a more elegant way to handle this?