I am trying to build googletest with the RISC-V gnu toolchain.
I understand that for a baremetal target certain gtest features must be disabled. I managed to get rid of undefined references to regexec etc by declaring the following in my toolchain file:
add_compile_definitions(GTEST_HAS_POSIX_RE=0 GTEST_HAS_CLONE=0 GTEST_HAS_EXCEPTIONS=0 GTEST_HAS_TR1_TUPLE=0 GTEST_HAS_STREAM_REDIRECTION=0 GTEST_HAS_RTTI=0)
However, I still get the errors:
/opt/riscv/bin/../lib/gcc/riscv32-unknown-elf/13.2.0/../../../../riscv32-unknown-elf/bin/ld: ../../lib/libgtest.a(gtest-all.cc.o): in function `.L0 ':
gtest-all.cc:(.text+0x296): undefined reference to `getcwd'
/opt/riscv/bin/../lib/gcc/riscv32-unknown-elf/13.2.0/../../../../riscv32-unknown-elf/bin/ld: gtest-all.cc:(.text+0xce0): undefined reference to `mkdir'
How can I resolve this? I have seen github issues where people define stubs for these functions, but I have attempted this without success, as I am trying to avoid having the gtest code locally, and instead use the FetchContent cmake module. This makes it hard to integrate the stubs I made.
Is there another gtest option to work around this problem?