Closed jonathanunderwood closed 3 years ago
Contents of the TRY_RUN file:
# This file was generated by CMake because it detected TRY_RUN() commands
# in crosscompiling mode. It will be overwritten by the next CMake run.
# Copy it to a safe location, set the variables to appropriate values
# and use it then to preset the CMake cache (using -C).
# STRPTIME_WORKS_EXITCODE
# indicates whether the executable would have been able to run on its
# target platform. If so, set STRPTIME_WORKS_EXITCODE to
# the exit code (in many cases 0 for success), otherwise enter "FAILED_TO_RUN".
# STRPTIME_WORKS_EXITCODE__TRYRUN_OUTPUT
# contains the text the executable would have printed on stdout and stderr.
# If the executable would not have been able to run, set STRPTIME_WORKS_EXITCODE__TRYRUN_OUTPUT empty.
# Otherwise check if the output is evaluated by the calling CMake code. If so,
# check what the source file would have printed when called with the given arguments.
# The STRPTIME_WORKS_COMPILED variable holds the build result for this TRY_RUN().
#
# Source file : /home/xxx/Projects/openwrt-workspace/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64/build_dir/target-x86_64_musl/getdns-1.6.0/CMakeFiles/CMakeTmp/src.c
# Executable : /home/xxx/Projects/openwrt-workspace/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64/build_dir/target-x86_64_musl/getdns-1.6.0/CMakeFiles/cmTC_f69e3-STRPTIME_WORKS_EXITCODE
# Run arguments :
# Called from: [2] /home/xxx/Projects/openwrt-workspace/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64/staging_dir/host/share/cmake-3.17/Modules/CheckCSourceRuns.cmake
# [1] /home/xxx/Projects/openwrt-workspace/openwrt-sdk-x86-64_gcc-8.4.0_musl.Linux-x86_64/build_dir/target-x86_64_musl/getdns-1.6.0/CMakeLists.txt
set( STRPTIME_WORKS_EXITCODE
"PLEASE_FILL_OUT-FAILED_TO_RUN"
CACHE STRING "Result from TRY_RUN" FORCE)
set( STRPTIME_WORKS_EXITCODE__TRYRUN_OUTPUT
"PLEASE_FILL_OUT-NOTFOUND"
CACHE STRING "Output from TRY_RUN" FORCE)
Rather than bake in a blanket assumption that strptime()
doesn't work on the target platform when cross-compiling, regardless of the platform, 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?
@banburybill you make a very good point, and I agree. I think you might want to raise that comment on PR #472 though, rather than this issue.
@cohall-2020 please see comment above.
PR Mergerd. I assume that if you have strptime during cross-compile time, it works. If this gives problems, people that cross-compile can still fill the cache in the way suggested by Jim above; or they compile with the strptime from compat which is fine too.
While attempting to build for OpenWRT I hit this: