cmake_minimum_required(VERSION 3.7...3.16 FATAL_ERROR)
message(STATUS "Using CMake version ${CMAKE_VERSION}")
+# Collect command-line arguments for buildinfo.txt.
+# Must reside at the top of the script to work as expected.
+get_cmake_property(_cache_vars CACHE_VARIABLES)
+unset(_cmake_args)
+foreach(_cache_var ${_cache_vars})
+ get_property(_cache_var_helpstring CACHE ${_cache_var} PROPERTY HELPSTRING)
+ if(_cache_var_helpstring STREQUAL "No help, variable specified on the command line.")
+ get_property(_cache_var_type CACHE ${_cache_var} PROPERTY TYPE)
+ if(_cache_var_type STREQUAL "UNINITIALIZED")
+ set(_cache_var_type)
+ else()
+ set(_cache_var_type ":${_cache_var_type}")
+ endif()
+ set(_cmake_args "${_cmake_args} -D${_cache_var}${_cache_var_type}=\"${${_cache_var}}\"")
+ endif()
+endforeach()
+
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake;${CMAKE_MODULE_PATH}")
include(Utilities)
include(Macros)
project(CURL C)
-unset(_flags)
+unset(_target_flags)
if(APPLE)
- set(_flags "${_flags} APPLE")
+ set(_target_flags "${_target_flags} APPLE")
endif()
if(UNIX)
- set(_flags "${_flags} UNIX")
+ set(_target_flags "${_target_flags} UNIX")
endif()
if(WIN32)
- set(_flags "${_flags} WIN32")
+ set(_target_flags "${_target_flags} WIN32")
endif()
if(CYGWIN)
- set(_flags "${_flags} CYGWIN")
+ set(_target_flags "${_target_flags} CYGWIN")
endif()
if(MSYS)
- set(_flags "${_flags} MSYS")
+ set(_target_flags "${_target_flags} MSYS")
endif()
if(CMAKE_COMPILER_IS_GNUCC)
- set(_flags "${_flags} GCC")
+ set(_target_flags "${_target_flags} GCC")
endif()
if(MINGW)
- set(_flags "${_flags} MINGW")
+ set(_target_flags "${_target_flags} MINGW")
endif()
if(MSVC)
- set(_flags "${_flags} MSVC")
+ set(_target_flags "${_target_flags} MSVC")
endif()
if(VCPKG_TOOLCHAIN)
- set(_flags "${_flags} VCPKG")
+ set(_target_flags "${_target_flags} VCPKG")
+endif()
+if(CMAKE_CROSSCOMPILING)
+ set(_target_flags "${_target_flags} CROSS")
endif()
-message(STATUS "CMake platform flags:${_flags}")
-unset(_flags)
+message(STATUS "CMake platform flags:${_target_flags}")
if(CMAKE_CROSSCOMPILING)
message(STATUS "Cross-compiling: "
_EOF
])
+
+dnl CURL_GENERATE_BUILDINFO_TXT
+dnl -------------------------------------------------
+dnl Save build info for test runner to pick up and log
+
+AC_DEFUN([CURL_GENERATE_BUILDINFO_TXT], [
+ curl_pflags=""
+ case $host in
+ *-apple-*) curl_pflags="${curl_pflags} APPLE";;
+ esac
+ if test "$curl_cv_native_windows" = 'yes'; then
+ curl_pflags="${curl_pflags} WIN32"
+ else
+ case $host in
+ *-*-*bsd*|*-*-aix*|*-*-hpux*|*-*-interix*|*-*-irix*|*-*-linux*|*-*-solaris*|*-*-sunos*|*-apple-*|*-*-cygwin*|*-*-msys*)
+ curl_pflags="${curl_pflags} UNIX";;
+ esac
+ fi
+ case $host_os in
+ cygwin*|msys*) curl_pflags="${curl_pflags} CYGWIN";;
+ esac
+ case $host_os in
+ msys*) curl_pflags="${curl_pflags} MSYS";;
+ esac
+ if test "x$compiler_id" = 'xGNU_C'; then
+ curl_pflags="${curl_pflags} GCC"
+ fi
+ case $host_os in
+ mingw*) curl_pflags="${curl_pflags} MINGW";;
+ esac
+ if test "x$cross_compiling" = 'xyes'; then
+ curl_pflags="${curl_pflags} CROSS"
+ fi
+ squeeze curl_pflags
+ cat >./tests/buildinfo.txt <<_EOF
+[@%:@] This is a generated file. Do not edit.
+configure.tool: configure
+configure.args: $ac_configure_args
+host: $build
+host.os: $build_os
+host.cpu: $build_cpu
+host.vendor: $build_vendor
+target: $host
+target.os: $host_os
+target.cpu: $host_cpu
+target.vendor: $host_vendor
+target.flags: $curl_pflags
+compiler: $compiler_id
+compiler.version: $compiler_num
+_EOF
+])
+
+
dnl CURL_CPP_P
dnl
dnl Check if $cpp -P should be used for extract define values due to gcc 5
AC_OUTPUT
CURL_GENERATE_CONFIGUREHELP_PM
+CURL_GENERATE_BUILDINFO_TXT
SUPPORT_PROTOCOLS_LOWER=`echo "$SUPPORT_PROTOCOLS" | tr A-Z a-z`
1;
")
+# Save build info for test runner to pick up and log
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/buildinfo.txt" "# This is a generated file. Do not edit.
+configure.tool: cmake
+configure.command: ${CMAKE_COMMAND}
+configure.version: ${CMAKE_VERSION}
+configure.os: ${CMAKE_SYSTEM}
+configure.args:${_cmake_args}
+configure.generator: ${CMAKE_GENERATOR}
+configure.make: ${CMAKE_MAKE_PROGRAM}
+host.os: ${CMAKE_HOST_SYSTEM_NAME}
+host.cpu: ${CMAKE_HOST_SYSTEM_PROCESSOR}
+target: ${CMAKE_C_COMPILER_TARGET}
+target.os: ${CMAKE_SYSTEM_NAME}
+target.cpu: ${CMAKE_SYSTEM_PROCESSOR}
+target.flags:${_target_flags}
+compiler: ${CMAKE_C_COMPILER_ID}
+compiler.version: ${CMAKE_C_COMPILER_VERSION}
+")
+
add_runtests(test-quiet "-a -s")
add_runtests(test-am "-a -am")
add_runtests(test-full "-a -p -r")
checksystemfeatures();
}
+#######################################################################
+# Output information about the curl build
+#
+if(!$listonly) {
+ if(open(my $fd, "<", "buildinfo.txt")) {
+ while(my $line = <$fd>) {
+ chomp $line;
+ if($line && $line !~ /^#/) {
+ logmsg("* buildinfo.$line\n");
+ }
+ }
+ close($fd);
+ }
+}
+
#######################################################################
# initialize configuration needed to set up servers
# TODO: rearrange things so this can be called only in runner_init()