【发布时间】:2019-01-18 08:25:10
【问题描述】:
我们使用 GNUmakefile 作为我们的主要构建系统。 makefile 使用源文件中的测试程序执行功能测试:
$ ls TestPrograms/
dump2def.cxx test_arm_sm4.cxx test_x86_avx.cxx
test_32bit.cxx test_cxx.cxx test_x86_avx2.cxx
test_64bit.cxx test_mixed_asm.cxx test_x86_avx512.cxx
...
测试程序是人们所期望的:
$ cat test_cxx.cxx
#include <string>
int main(int argc, char* argv[])
{
unsigned int x=0;
return x;
}
我们支持 Debian 和 Fedora 等发行版的 Autotools。我们希望 Autotools 使用 GNUmakefile 和 CMake 等测试程序。 AC_COMPILE_IFELSE 上的 Autools 文档是 here,但它像往常一样可悲。它不讨论主题或提供示例。
在黑暗中刺伤:
CXXFLAGS="-msse2"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS and Foo Bar])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([TestPrograms/test_x86_sse2.cxx])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
结果:
checking if g++ supports -msse2 and Foo Bar... no
与cat'将文件转换成字符串的结果相同:
CXXFLAGS="-msse2"
AC_MSG_CHECKING([if $CXXNAME supports $CXXFLAGS and Foo Bar])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(`cat TestPrograms/test_x86_sse2.cxx`)],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])]
)
Skylake 机器上的结果不正确。 SSE2 是核心指令集的一部分,始终可用:
$ g++ -msse2 TestPrograms/test_x86_sse2.cxx
$
我们如何告诉 Autoconf 编译测试文件?
【问题讨论】:
标签: compilation autotools autoconf