osmanip: Unable to compile examples and tests on MSVC (error got from CodeQL analysis workflow)

Hi @joeletho ,

I set up the CMake building process, but an error occurs when trying to compile with MSVC and it seems it is related to output_redirector.cpp. As you can see from running the CodeQL workflow for Windows, this error occurs:

D:\a\osmanip\osmanip\src\utility\output_redirector.cpp(76,4): error C2512: 'std::basic_ostream<char,std::char_traits<char>>': no appropriate default constructor available [D:\a\osmanip\osmanip\build\osmanip.vcxproj]

and subsequently:

D:\a\osmanip\osmanip\src\utility\output_redirector.cpp(73,13): error C2665: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string': no overloaded function could convert all the argument types [D:\a\osmanip\osmanip\build\osmanip.vcxproj]

Do you have any idea of what’s happening? Could you please investigate this issue and try to fix it? Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (21 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @JustWhit3,

I hope you had a good holiday!

I have put some hours into this issue and I can’t seem to figure out what is going on. doctest is giving me the most grief. However, I feel like the underlying issue is the real problem. Here is the log output:

-- The CXX compiler identification is MSVC 19.33.31630.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at deps/doctest/CMakeLists.txt:19 (find_package):
  By not providing "Finddoctest.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "doctest", but
  CMake did not find one.

  Could not find a package configuration file provided by "doctest" with any
  of the following names:

    doctestConfig.cmake
    doctest-config.cmake

  Add the installation prefix of "doctest" to CMAKE_PREFIX_PATH or set
  "doctest_DIR" to a directory containing one of the above files.  If
  "doctest" provides a separate development package or SDK, be sure it has
  been installed.


-- Fetching doctest...
CMake Error: The current CMakeCache.txt directory C:/Users/Joel/Dev/cpp/osmanip_repos/osmanip_issue30/cmake-build-debug/_deps/doctest-subbuild/CMakeCache.txt is different than the directory c:/Users/Joel/Dev/osmanip_repos/osmanip_issue30/cmake-build-debug/_deps/doctest-subbuild where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt

CMake Error at C:/Program Files/JetBrains/CLion 2021.3.1/bin/cmake/win/share/cmake-3.23/Modules/FetchContent.cmake:1076 (message):
  CMake step for doctest failed: 1

Call Stack (most recent call first):
  C:/Program Files/JetBrains/CLion 2021.3.1/bin/cmake/win/share/cmake-3.23/Modules/FetchContent.cmake:1217:EVAL:2 (__FetchContent_directPopulate)
  C:/Program Files/JetBrains/CLion 2021.3.1/bin/cmake/win/share/cmake-3.23/Modules/FetchContent.cmake:1217 (cmake_language)
  C:/Program Files/JetBrains/CLion 2021.3.1/bin/cmake/win/share/cmake-3.23/Modules/FetchContent.cmake:1260 (FetchContent_Populate)
  deps/doctest/CMakeLists.txt:29 (FetchContent_MakeAvailable)

If you read the error after attempting to fetch doctest, CMake seems to be having trouble differentiating between doctest’s CMakeCache and osmanip’s ` CMakeCache. This error is thrown from the following block from deps/doctest/CMakeLists.txt:

# Fetch the package
find_package( doctest )

if( NOT doctest_FOUND )
    include(FetchContent)
    FetchContent_Declare(
      doctest
      GIT_REPOSITORY "https://github.com/doctest/doctest"
      GIT_TAG master
    )
    message( STATUS "Fetching doctest..." )
    FetchContent_MakeAvailable( doctest ) # error occurs here
endif()

This also happens to arsenalgear whether it is installed or not.

So, I think the issue boils down to a problem with the code in the CMakeLists.txt script or a problem with the pathing. I cannot get any resolve when experimenting with and setting/appending paths, CMake never finds arsenalgear or doctest even though both have been fetched and can be found in the build/_deps. Do you have any ideas?

Hi @JustWhit3,

I will do some investigating and see what I can find. It may be a few days, but I will let know what I find.

Hi @joeletho, I thought so too, but even after reinstalling arsenalgear the problem still occurred. Could it be a pathing to the install directory? It will be different on Windows than on Linux.

And yes, output_redirector has been corrected.