specify what OS is used in the CMake quickstart
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
**Describe the bug**
I was following [quickstart-cmake](https://google.github.io/googletest/quickstart-cmake.html) tutorial and after `cmake --build build` command I was getting this build errors:
```
In file included from D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-internal.h:40:0,
from D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/gtest.h:62,
from D:\Program Files\Git\delete_me\build\_deps\googletest-src\googletest\src\gtest-all.cc:38:
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::StrCaseCmp(const char*, const char*)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h:1985:25: error: '_stricmp' was not declared in this scope
return _stricmp(s1, s2);
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h: In function 'char* testing::internal::posix::StrDup(const char*)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h:1987:58: error: '_strdup' was not declared in this scope
inline char* StrDup(const char* src) { return _strdup(src); }
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h:1995:52: error: '_fileno' was not declared in this scope
inline int FileNo(FILE* file) { return _fileno(file); }
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/include/gtest/internal/gtest-port.h:2072:71: error: 'fdopen' was not declared in this scope
inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
^
In file included from D:\Program Files\Git\delete_me\build\_deps\googletest-src\googletest\src\gtest-all.cc:41:0:
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest.cc: In static member function 'static bool testing::internal::String::CaseInsensitiveWideCStringEquals(const wchar_t*, const wchar_t*)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest.cc:2086:27: error: '_wcsicmp' was not declared in this scope
return _wcsicmp(lhs, rhs) == 0;
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest.cc: In member function 'int testing::UnitTest::Run()':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest.cc:5264:21: error: '_OUT_TO_STDERR' was not declared in this scope
_set_error_mode(_OUT_TO_STDERR);
^~~~~~~~~~~~~~
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest.cc:5264:35: error: '_set_error_mode' was not declared in this scope
_set_error_mode(_OUT_TO_STDERR);
^
In file included from D:\Program Files\Git\delete_me\build\_deps\googletest-src\googletest\src\gtest-all.cc:42:0:
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc: In function 'void testing::internal::DeathTestAbort(const string&)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:297:12: error: '_exit' was not declared in this scope
_exit(1);
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc: In member function 'virtual void testing::internal::DeathTestImpl::Abort(testing::internal::DeathTest::AbortReason)':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:528:10: error: '_exit' was not declared in this scope
_exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc: In member function 'virtual testing::internal::DeathTest::TestRole testing::internal::WindowsDeathTest::AssumeRole()':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:772:24: error: '_MAX_PATH' was not declared in this scope
char executable_path[_MAX_PATH + 1]; // NOLINT
^~~~~~~~~
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:774:65: error: 'executable_path' was not declared in this scope
executable_path,
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:309:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
if (!::testing::internal::IsTrue(expression)) { \
^~~~~~~~~~
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:798:11: error: 'executable_path' was not declared in this scope
executable_path, const_cast(command_line.c_str()),
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-death-test.cc:309:38: note: in definition of macro 'GTEST_DEATH_TEST_CHECK_'
if (!::testing::internal::IsTrue(expression)) { \
^~~~~~~~~~
In file included from D:\Program Files\Git\delete_me\build\_deps\googletest-src\googletest\src\gtest-all.cc:43:0:
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-filepath.cc: In static member function 'static testing::internal::FilePath testing::internal::FilePath::GetCurrentDir()':
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-filepath.cc:49:26: error: '_MAX_PATH' was not declared in this scope
# define GTEST_PATH_MAX_ _MAX_PATH
^
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-filepath.cc:101:12: note: in expansion of macro 'GTEST_PATH_MAX_'
char cwd[GTEST_PATH_MAX_ + 1] = { '\0' };
^~~~~~~~~~~~~~~
D:/PROGRA~1/Git/DELETE~1/build/_deps/GOOGLE~2/GOOGLE~2/src/gtest-filepath.cc:102:27: error: 'cwd' was not declared in this scope
return FilePath(_getcwd(cwd, sizeof(cwd)) == nullptr ? "" : cwd);
^~~
make[2]: *** [_deps\googletest-build\googletest\CMakeFiles\gtest.dir\build.make:76: _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[1]: *** [CMakeFiles\Makefile2:215: _deps/googletest-build/googletest/CMakeFiles/gtest.dir/all] Error 2
make: *** [Makefile:145: all] Error 2
```
**Steps to reproduce the bug**
Follow the tutorial linked above.
```
cmake_minimum_required(VERSION 3.14)
project(my_project)
# GoogleTest requires at least C++11
set(CMAKE_CXX_STANDARD 11)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(
hello_test
hello_test.cc
)
target_link_libraries(
hello_test
gtest_main
)
include(GoogleTest)
gtest_discover_tests(hello_test)
```
**Does the bug persist in the most recent commit?**
Yes.
**What operating system and version are you using?**
- Windows 7
**What compiler and version are you using?**
gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
**What build system are you using?**
cmake version 3.22.0-rc2
**Aditional settings**
- Mingw64
Contributor guide
Research direction
Open the linked quickstart-cmake tutorial and review the build instructions around `cmake --build build`, using the reported Windows 7 and MinGW GCC 6.3.0 setup as context. Update the tutorial to state which operating systems and toolchains its steps cover, then verify that the documented prerequisites and commands are clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100