I have been trying to integrate googletest into my solution, but I get either nasty linker errors or can't add it at all.
googletest was added as a submodule: git submodule add 'https://github.com/google/googletest.git'
Have been trying configuring premake5 like so:
...
project "libtest"
    location "libtest"
    kind "ConsoleApp"
    language "C++"
    targetdir ("bin/" .. outputdir .. "/%{prj.name}")
    objdir ("bin-int/" .. outputdir .. "/%{prj.name}")
    files
    {
        "%{prj.name}/src/**.h",
        "%{prj.name}/src/**.cpp",
        "libtest/vendor/googletest/googletest/**.h",
        "libtest/vendor/googletest/googletest/**.hpp",
        "libtest/vendor/googletest/googletest/src/gtest-all.cc"
    }
    includedirs
    {
        "mylib", // DLL
        "libtest/vendor/googletest/googletest/include/gtest",
        "libtest/vendor/googletest/googletest/include",
        "libtest/vendor/googletest/googletest"
    }
 ...
and I get LNK2019  unresolved external symbol main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)    libtest C:\dev\mylib\libtest\LIBCMTD.lib(exe_main.obj)  1    
Finally managed to fix it :)
adding some extra file with:
int main(int argc, char** argv)
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}
fixed linking problem, and cleaning up:
"libtest/vendor/googletest/googletest/include/gtest",
"libtest/vendor/googletest/googletest/include",
"libtest/vendor/googletest/googletest"
to this
"libtest/vendor/googletest/googletest/include",
"libtest/vendor/googletest/googletest/"
is enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With