getdnsapi / getdns

A modern asynchronous DNS API https://getdnsapi.net/
Other
468 stars 126 forks source link

Skip check_c_source_runs when cross-compiling. #472

Closed chall37 closed 3 years ago

chall37 commented 4 years ago

Added a check for cross-compiling.

jonathanunderwood commented 4 years ago

Confirmed that this fixes #480 - please merge ahead of next release as this is needed for building on OpenWRT.

jonathanunderwood commented 4 years ago

@banburybill makes a very good point about this PR here: https://github.com/getdnsapi/getdns/issues/480#issuecomment-653609948

banburybill commented 4 years ago

To repeat my comment on the PR:

Is it possible to do what CMake wants? Namely manually check whether it does or doesn't work and pre-fill the cache with the answers. As it says in https://cmake.org/cmake/help/latest/command/try_run.html#id4, this will still build the test program but it won't run it; instead it will behave as if the test ran with the given exit code. E.g., for OpenWRT which I am pretty sure does have a working strptime():

$ cat $ cat precache.cmake set( STRPTIME_WORKS_EXITCODE 0 CACHE STRING "Result from TRY_RUN" FORCE) set( STRPTIME_WORKS_EXITCODE__TRYRUN_OUTPUT "" CACHE STRING "Output from TRY_RUN" FORCE) $ cmake -C precache.cmake .

Or am I missing something?

chall37 commented 4 years ago

@banburybill @jonathanunderwood

I assumed this was an oversight rather than working as intended. :) One man's feature...

From the CMake docs linked above:

In order to make cross compiling your project easier, use try_run only if really required. If you use try_run, use the RUN_OUTPUT_VARIABLE or OUTPUT_VARIABLE options only if really required.

I recognize that "really required" may mean different things to different people. To me it means "we cannot build this without knowing the answer." Since there is extant code in src/compat/strptime.c to handle the case that strptime() is not supported by the standard libraries, this signals to me that it's not a required check, just potentially useful to know.