ninja: error: build.ninja: bad $-escape (literal $ must be written as $$) - c++

I am getting the following error while compiling SeqAn Framework:
1> [CMake] CMake Error:
1> [CMake] Running
1> [CMake]
1> [CMake] 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'C:/Users/pc/source/repos/seqan/out/build/x64-Clang-Debug' '-t' 'recompact'
1> [CMake]
1> [CMake] failed with:
1> [CMake]
1> [CMake] ninja: error: build.ninja:152: bad $-escape (literal $ must be written as $$)
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] CMake Generate step failed. Build files cannot be regenerated correctly.
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\pc\Source\Repos\seqan\out\install\x64-Clang-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\pc\Source\Repos\seqan" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\pc\Source\Repos\seqan\out\install\x64-Clang-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\pc\Source\Repos\seqan" 2>&1"' returned with exit code: 1'.
The following is my CMakeSettings_schema.json file:
{
"configurations": [
{
"name": "x64-Clang-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "clang_cl_x64_x64" ],
"variables": []
}
]
}
The following is the content of my build.ninja file from line # 152:
COMMAND = cmd.exe /C "cd /D C:\Users\pc\source\repos\seqan\out\build\x64-Clang-Debug && C:\Users\pc\source\repos\seqan\out\build\x64-Clang-Debug\bin\$(ConfigurationName)\alf.exe --write-ctd C:/Users/pc/source/repos/seqan/out/build/x64-Clang-Debug/workflow_plugin_dir/descriptors/alf.ctd"
What can I do to fix this?

Related

CMake when run from within Visual Studio 2022 couldn't detect compiler

So after installing VS 2022 and downloading and compiling boost 1.82, I was trying to get a test project running, one that is supposed to compile cross platform (new feature in VS 2022 or was it there in previous versions as well??). I created a new VC++ project and solution from within VS as File > New > Project > CMake Project.
And after modifying the CMakeLists.txt file as:
...
set (BOOST_ROOT "C:/boost/boost")
set (BOOST_INCLUDEDIR "C:/boost/boost/include")
set (BOOST_LIBRARYDIR "C:/boost/boost/stage/lib")
set (BOOST_MIN_VERSION "1.82.0")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_DEBUG ON)
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS date_time REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Fatal error: Boost (version >= ${BOOST_MIN_VERSION}) required.")
endif()
include_directories(${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
...
And then did Project > Delete Cache And Reconfigure
The trouble is that it is not able to find the boost libraries and I believe it is because it couldn't figure out what the compiler is:
....
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1862 ] Boost_VERSION_MAJOR = "1"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1863 ] Boost_VERSION_MINOR = "82"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1864 ] Boost_VERSION_PATCH = "0"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1865 ] Boost_VERSION_COUNT = "3"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1889 ] Boost_LIB_PREFIX = ""
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1890 ] Boost_NAMESPACE = "boost"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:953 ] _boost_COMPILER = "" (guessed)
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1926 ] _boost_MULTITHREADED = "-mt"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2004 ] _boost_ARCHITECTURE_TAG = "" (detected)
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2008 ] _boost_RELEASE_ABI_TAG = "-"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2009 ] _boost_DEBUG_ABI_TAG = "-d"
....
Here the _boost_COMPILER was detected as _boost_COMPILER = "" (guessed).
Any idea what could be wrong here.. VS is supposed to tell CMake about itself right since I am calling CMake from within it?
EDIT: Attaching entire output from CMake
1> CMake generation started for default configuration: 'x64-Debug'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\johns\source\repos\LogMon\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\Ninja\ninja.exe" "C:\Users\johns\source\repos\LogMon" 2>&1"
1> Working directory: C:\Users\johns\source\repos\LogMon\out\build\x64-Debug
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1689 ] _boost_TEST_VERSIONS = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1690 ] Boost_USE_MULTITHREADED = "ON"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1691 ] Boost_USE_STATIC_LIBS = "ON"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1692 ] Boost_USE_STATIC_RUNTIME = "OFF"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1693 ] Boost_ADDITIONAL_VERSIONS = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1694 ] Boost_NO_SYSTEM_PATHS = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1726 ] BOOST_ROOT = "C:/boost/boost"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1727 ] ENV{BOOST_ROOT} = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1728 ] BOOST_INCLUDEDIR = "C:/boost/boost/include"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1729 ] ENV{BOOST_INCLUDEDIR} = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1730 ] BOOST_LIBRARYDIR = "C:/boost/boost/stage/lib"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1731 ] ENV{BOOST_LIBRARYDIR} = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1803 ] _boost_INCLUDE_SEARCH_DIRS = "C:/boost/boost/include;C:/boost/boost/include;C:/boost/boost;PATHS;C:/boost/include;C:/boost;/sw/local/include"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1804 ] _boost_PATH_SUFFIXES = <unset>
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1819 ] location of version.hpp: C:/boost/boost/boost/version.hpp
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1859 ] Boost_VERSION = "108200"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1860 ] Boost_VERSION_STRING = "1.82.0"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1861 ] Boost_VERSION_MACRO = "108200"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1862 ] Boost_VERSION_MAJOR = "1"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1863 ] Boost_VERSION_MINOR = "82"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1864 ] Boost_VERSION_PATCH = "0"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1865 ] Boost_VERSION_COUNT = "3"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1889 ] Boost_LIB_PREFIX = "lib"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1890 ] Boost_NAMESPACE = "boost"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:953 ] _boost_COMPILER = "" (guessed)
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1926 ] _boost_MULTITHREADED = "-mt"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2004 ] _boost_ARCHITECTURE_TAG = "" (detected)
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2008 ] _boost_RELEASE_ABI_TAG = "-"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2009 ] _boost_DEBUG_ABI_TAG = "-d"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2069 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = "C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/../lib;C:/boost/boost/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2070 ] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/../lib;C:/boost/boost/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
1> [CMake] CMake Warning at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1384 (message):
1> [CMake] New Boost version may have incorrect or missing dependencies and imported
1> [CMake] targets
1> [CMake] Call Stack (most recent call first):
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:1507 (_Boost_COMPONENT_DEPENDENCIES)
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2118 (_Boost_MISSING_DEPENDENCIES)
1> [CMake] CMakeLists.txt:14 (find_package)
1> [CMake]
1> [CMake]
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2255 ] Searching for DATE_TIME_LIBRARY_RELEASE: libboost_date_time-mt-1_82;libboost_date_time-mt;libboost_date_time-mt;libboost_date_time-mt;libboost_date_time
1> [CMake] -- [ C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2310 ] Searching for DATE_TIME_LIBRARY_DEBUG: libboost_date_time-mt-d-1_82;libboost_date_time-mt-d;libboost_date_time-mt-d;libboost_date_time-mt;libboost_date_time
1> [CMake] CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
1> [CMake] Could NOT find Boost (missing: date_time) (found suitable version "1.82.0",
1> [CMake] minimum required is "1.82.0")
1> [CMake] Call Stack (most recent call first):
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.24/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
1> [CMake] CMakeLists.txt:14 (find_package)
1> [CMake] -- Configuring incomplete, errors occurred!
1> 'C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\johns\source\repos\LogMon\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\Ninja\ninja.exe" "C:\Users\johns\source\repos\LogMon" 2>&1"' execution failed with error: ''C:\WINDOWS\system32\cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\johns\source\repos\LogMon\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\Microsoft\CMake\Ninja\ninja.exe" "C:\Users\johns\source\repos\LogMon" 2>&1"' returned with exit code: 1'.
After skimming through the entire log the issue seems to be elsewhere than you'd expect.
...
find_package(Boost ${BOOST_MIN_VERSION} COMPONENTS date_time REQUIRED) #<---
...
It says so at the bottom of the log:
#Missing date_time... i.e. it can't find a REQUIRED component
1> [CMake] Could NOT find Boost (missing: date_time) (found suitable version "1.82.0",
1> [CMake] minimum required is "1.82.0")
To properly debug this issue I would recommend going through the paths outputed by these variables here:
1> [...] _boost_LIBRARY_SEARCH_DIRS_RELEASE = "C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/../lib;C:/boost/boost/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
1> [...] _boost_LIBRARY_SEARCH_DIRS_DEBUG = "C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/stage/lib;C:/boost/boost/lib;C:/boost/boost/../lib;C:/boost/boost/stage/lib;PATHS;C:/boost/lib;C:/boost;/sw/local/lib"
and double check that these libraries are present in the directories (they probably wont)
1> [...] Searching for DATE_TIME_LIBRARY_RELEASE: libboost_date_time-mt-1_82;libboost_date_time-mt;libboost_date_time-mt;libboost_date_time-mt;libboost_date_time
1> [...] Searching for DATE_TIME_LIBRARY_DEBUG: libboost_date_time-mt-d-1_82;libboost_date_time-mt-d;libboost_date_time-mt-d;libboost_date_time-mt;libboost_date_time
I would then check if these libraries exist in the boost folder at all. Chances are they won't and it will most likely be because they are either part of a different component or are just missing from your boost installation.
Try including whole boost to see if that is the case:
find_package(Boost ${BOOST_MIN_VERSION})
Hope it helps!
EDIT: I've managed to replicate your issue and truly it is due to the undetected compiler most likely. As when building the boost it appends the compiler as a suffix (or somewhere mid name) to the library. I.e. if you check the lib dir you can deduct which compiler was being used and perhaps force set the variable through set(Boost_COMPILER "-vcXYZ").
Note that the libboost_date_time-mt-d-1_82 is missing the compiler due to this unset variable. It should look like libboost_date_time-vc142-mt-d-1_82 (if you compiled with vc142)

Build failed after change architecture from x64 to x86_64 using cmake preset on windows

I'm building a project using cmake preset in vs2019.
My CMakePresets.json as follows:
{
"name": "windows-x86_64-release",
"displayName": "Windows x86_64 Release",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"architecture": {
"value": "x64",
"strategy": "external"
},
My windows is 64 bit. The settings above works well.
Because VS is alway 32 bit, so I change architecture value to x86_64, then I get an error when cmake init:
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
1> [CMake] The C compiler
1> [CMake]
1> [CMake] "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/HostX64/x86/cl.exe"
1> [CMake]
1> [CMake] is not able to compile a simple test program.
1> [CMake]
1> [CMake] It fails with the following output:
1> [CMake]
1> [CMake] Change Dir: D:/code_repo/repo_sun/qrlib/alib/code/build/windows-x86_64-release/CMakeFiles/CMakeTmp
1> [CMake]
1> [CMake] Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_c3232 && [1/2] Building C object CMakeFiles\cmTC_c3232.dir\testCCompiler.c.obj
1> [CMake] [2/2] Linking C executable cmTC_c3232.exe
1> [CMake] FAILED: cmTC_c3232.exe
1> [CMake] cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_c3232.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1428~1.299\bin\HostX64\x86\link.exe /nologo CMakeFiles\cmTC_c3232.dir\testCCompiler.c.obj /out:cmTC_c3232.exe /implib:cmTC_c3232.lib /pdb:cmTC_c3232.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
1> [CMake] RC Pass 1: command "rc /fo CMakeFiles\cmTC_c3232.dir/manifest.res CMakeFiles\cmTC_c3232.dir/manifest.rc" failed (exit code 0) with the following output:
1> [CMake] 系统找不到指定的文件。
1> [CMake] ninja: build stopped: subcommand failed.
Mean while, the follow script works well in cmd prompt:
set build_type=windows-x86_64-release
md build
cd build
cmake .. --preset=%build_type%
cd %build_type%
ninja install
Any idea about that?

Can't generate CMake files with Visual Studio

I'm trying to use CMake with Visual Studio for a 3D class, but whenever I open the provided CMake project, Visual Studio can't generate CMake files. I get the following error (some parts of the output were in French so I translated them):
CMake generation started with the default configuration: 'x64-Debug (par défaut)'.
1> Command line: "cmd.exe" /c ""c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented\out\install\x64-Debug (par défaut)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented" 2>&1"
1> Working directory: D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented\out\build\x64-Debug (par défaut)
1> [CMake] -- The C compiler identification is MSVC 19.26.28805.0
1> [CMake] -- The CXX compiler identification is MSVC 19.26.28805.0
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe
1> [CMake] -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe - broken
1> [CMake] CMake Error at C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.17/Modules/CMakeTestCCompiler.cmake:60 (message):
1> [CMake] The C compiler
1> [CMake]
1> [CMake] "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe"
1> [CMake]
1> [CMake] is not able to compile a simple test program.
1> [CMake]
1> [CMake] It fails with the following output:
1> [CMake]
1> [CMake] Change Dir: D:/Scolaire/11 - 2A/INF443/1 - Tutoriels/create_window_commented/out/build/x64-Debug (par défaut)/CMakeFiles/CMakeTmp
1> [CMake]
1> [CMake] Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_cbae0 && [1/2] Building C object CMakeFiles\cmTC_cbae0.dir\testCCompiler.c.obj
1> [CMake] [2/2] Linking C executable cmTC_cbae0.exe
1> [CMake] FAILED: cmTC_cbae0.exe
1> [CMake] cmd.exe /C "cd . && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_cbae0.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~1\2019\COMMUN~1\VC\Tools\MSVC\1426~1.288\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_cbae0.dir\testCCompiler.c.obj /out:cmTC_cbae0.exe /implib:cmTC_cbae0.lib /pdb:cmTC_cbae0.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
1> [CMake] RC Pass 1: command "rc /fo CMakeFiles\cmTC_cbae0.dir/manifest.res CMakeFiles\cmTC_cbae0.dir/manifest.rc" failed (exit code 0) with the following output:
1> [CMake] The specified file could not be found
1> [CMake] ninja: build stopped: subcommand failed.
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] CMake will not be able to correctly generate this project.
1> [CMake] Call Stack (most recent call first):
1> [CMake] CMakeLists.txt:3 (project)
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "D:/Scolaire/11 - 2A/INF443/1 - Tutoriels/create_window_commented/out/build/x64-Debug (par défaut)/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "D:/Scolaire/11 - 2A/INF443/1 - Tutoriels/create_window_commented/out/build/x64-Debug (par défaut)/CMakeFiles/CMakeError.log".
1> Execution failed 'cmd.exe' '/c ""c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented\out\install\x64-Debug (par défaut)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented" 2>&1"'. Error: ''cmd.exe' '/c ""c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented\out\install\x64-Debug (par défaut)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.26.28801/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\commonextensions\microsoft\cmake\Ninja\ninja.exe" "D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented" 2>&1"' was returned with end code: 1'.
Other people in my class are using the same provided files and don't have errors so the problem can't be from this. I use Windows 10 and the latest version of Visual Studio (I tried to uninstall and reinstall it). The C++ and CMake tools are installed within Visual Studio.
The provided project should only open an empty windows, it looks like this:
PS D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented> ls
Répertoire : D:\Scolaire\11 - 2A\INF443\1 - Tutoriels\create_window_commented
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 25/05/2020 14:09 .vs
d----- 25/05/2020 14:09 out
d----- 03/08/2018 15:10 src
-a---- 11/03/2020 08:59 175 CMakeLists.txt
-a---- 02/03/2020 17:37 214 Makefile
-a---- 02/03/2020 17:37 229 meson.build
-a---- 11/03/2020 08:59 847 README
Do you know what the cause could be ? Thanks!
The problem was from the CMakeLists.txt, the parameters inside this file were for Unix instead of Windows.
Edit: the CMakeLists.txt that didn't work was this:
cmake_minimum_required(VERSION 2.8)
project(pgm)
set(CMAKE_CXX_FLAGS "-O2 -g -std=c++11 -Wall -Wextra")
add_executable(pgm src/main.cpp)
target_link_libraries(pgm glfw)
I made the following changes.
From set(CMAKE_CXX_FLAGS "-O2 -g -std=c++11 -Wall -Wextra") to:
set(CMAKE_BUILD_TYPE Debug)
set(GLFW_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/lib_windows/glfw3_win/include")
include_directories(${GLFW_INCLUDE_DIRS})
set(GLFW_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/lib_windows/glfw3_win/lib/glfw3.lib") # Set directory to precompiled version of glfw3
From target_link_libraries(pgm glfw) to:
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${source_files}) # Allow to explore source directories as a tree
target_link_libraries(pgm ${GLFW_LIBRARIES})
I didn't write this code, I just understood that the wrong lines of code were meant for Unix so I replaced them with the right lines of code from another CMakeLists.txt from a similar provided OpenGL project.
My solution — add this right before 'project' in top cmake file:
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")

Build project using CMake, Ninja and clang for VS 2019

So, I want to build my project using CMake and clang as a frontend for VS2019. What I already try:
CMakeLists.txt
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
#(CMAKE_INSTALL_PREFIX "C:\\Program Files\\LLVM\\bin")
project(sink)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++17 -pedantic")
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}/bin")
file(GLOB SOURCES "${SRC_DIR}/*.cpp" "${SRC_DIR}/*.cc" "${SRC_DIR}/*.c")
file(GLOB HEADERS "${INCLUDE_DIR}/*.h" "${INCLUDE_DIR}/*.hpp")
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
CMakeSettings.json
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64" ],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-H. -G Ninja -Bbuild -DCMAKE_CXX_COMPILER:PATH=\"C:\\Program Files\\LLVM\\bin\\clang-cl.exe\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": []
}
]
}
And which errors I get:
1> CMake generation started.
1> Command line: E:\VS19\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\theha\CMakeBuilds\7c084052-2033-9235-9a50-93f9ca5000be\install\x64-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe" -H. -G Ninja -Bbuild -DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="E:\VS19\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\theha\projects\sink"
1> Working directory: C:\Users\theha\CMakeBuilds\7c084052-2033-9235-9a50-93f9ca5000be\build\x64-Debug
1> [CMake] -- The C compiler identification is MSVC 19.20.27404.0
1> [CMake] -- The CXX compiler identification is Clang 7.0.1
1> [CMake] -- Check for working C compiler: E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe
1> [CMake] -- Check for working C compiler: E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe -- works
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe
1> [CMake] -- Check for working CXX compiler: C:/Program Files/LLVM/bin/clang-cl.exe -- broken
1> [CMake] CMake Error at E:/VS19/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.13/Modules/CMakeTestCXXCompiler.cmake:45 (message):
1> [CMake] The C++ compiler
1> [CMake]
1> [CMake] "C:/Program Files/LLVM/bin/clang-cl.exe"
1> [CMake]
1> [CMake] is not able to compile a simple test program.
1> [CMake]
1> [CMake] It fails with the following output:
1> [CMake]
1> [CMake] Change Dir: C:/Users/theha/CMakeBuilds/7c084052-2033-9235-9a50-93f9ca5000be/build/x64-Debug/build/CMakeFiles/CMakeTmp
1> [CMake]
1> [CMake] Run Build Command:"E:\VS19\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "cmTC_9e38f"
1> [CMake] [1/2] Building CXX object CMakeFiles\cmTC_9e38f.dir\testCXXCompiler.cxx.obj
1> [CMake] FAILED: CMakeFiles/cmTC_9e38f.dir/testCXXCompiler.cxx.obj
1> [CMake] C:\PROGRA~1\LLVM\bin\clang-cl.exe /nologo -TP /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /JMC /showIncludes /FoCMakeFiles\cmTC_9e38f.dir\testCXXCompiler.cxx.obj /FdCMakeFiles\cmTC_9e38f.dir\ -c testCXXCompiler.cxx
1> [CMake] clang-cl.exe: error: no such file or directory: '/JMC'
1> [CMake] ninja: build stopped: subcommand failed.
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake]
1> [CMake] CMake will not be able to correctly generate this project.
1> [CMake] Call Stack (most recent call first):
1> [CMake] CMakeLists.txt:5 (project)
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/Users/theha/CMakeBuilds/7c084052-2033-9235-9a50-93f9ca5000be/build/x64-Debug/build/CMakeFiles/CMakeOutput.log".
1> [CMake] See also "C:/Users/theha/CMakeBuilds/7c084052-2033-9235-9a50-93f9ca5000be/build/x64-Debug/build/CMakeFiles/CMakeError.log".
1> [CMake]
1> CMake generation finished.
1> E:\VS19\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\theha\CMakeBuilds\7c084052-2033-9235-9a50-93f9ca5000be\install\x64-Debug" -DCMAKE_CXX_COMPILER:FILEPATH="E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe" -DCMAKE_C_COMPILER:FILEPATH="E:/VS19/VC/Tools/MSVC/14.20.27404/bin/HostX86/x64/cl.exe" -H. -G Ninja -Bbuild -DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MAKE_PROGRAM="E:\VS19\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\theha\projects\sink" returned with exit code: 1
So, how I can fix that? Maybe I'm doing something wrong but I cannot understand what actually? I also see advices with using vcvarsall.bat and set CXX and CXXFLAGS but it isn't help.
There are two problems with your solution:
You are defining a build directory with "-Bbuild", which is different than the one defined in CMakeSettings.json in the "buildRoot" property. This would make Visual Studio misbehave, as e.g. it will look for CMakeCache.txt in the '${buildRoot}', not in '${buildRoot}/build'.
You are passing two definitions of CMAKE_CXX_COMPILER to CMake, one with "cl.exe", another with "clang-cl.exe".
You can solve both problems by passing these values instead:
{
"configurations": [
{
"name": "Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"msvc_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_CXX_COMPILER",
"type": "PATH",
"value": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe"
},
{
"name": "CMAKE_C_COMPILER",
"type": "PATH",
"value": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe"
}
]
}
]
}
Regarding the error related to /JMC unrecognized flag being passed to clang-cl.exe, that flag is not currently supported by clang-cl.exe, so you need to apply this patch to your local CMake installation (located under
VS_INSTALLATION_FOLDER\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake)
Ok, maybe someone will find my solution useful.
How I change my CMakeLists.txt:
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(sink)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Xclang -std=c++17 -Xclang -pedantic")
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}/bin")
file(GLOB SOURCES "${SRC_DIR}/*.cpp" "${SRC_DIR}/*.cc" "${SRC_DIR}/*.c")
file(GLOB HEADERS "${INCLUDE_DIR}/*.h" "${INCLUDE_DIR}/*.hpp")
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
And CMakeSettings.json:
{
"configurations": [
{
"name": "Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64" ],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DCMAKE_CXX_COMPILER:PATH=\"C:\\Program Files\\LLVM\\bin\\clang-cl.exe\" -DCMAKE_CXX_FLAGS:STRING=\"/DWIN32 /D_WINDOWS /GR /EHsc\" -DCMAKE_CXX_FLAGS_DEBUG:STRING=\"/MDd /Zi /Ob0 /Od /RTC1\"",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": []
}
]
}
For now all works.

CMake found Boost but not requested libraries

I am trying to add Boost to a C++ application using CMake. I have read through all relevant questions I can find on SO, and I feel I am getting closer to a solution. But the CMake still can't find the requested Boost library for some reasons.
I am trying to find "boost_filesystem". The debug shows CMake is looking for "boost_filesystem-vc141-mt-gd-1_65_1". I do have the file "libboost_filesystem-vc141-mt-gd-1_65_1.lib" in the folder "C:\boost\boost_1_65_1\stage\lib". I suppose this is the file CMake is looking for, but for some reasons CMake says it can't find it.
Here is the procedure I used to build the Boost. This may be too much details for most people but I suspect it may be helpful to another newbie.
download and extract Boost 1.65.1 in folder C:\boost\boost_1_65_1
go to developer prompt command line and run bootstrap.bat under the above folder.
updated file visualc.hpp under C:\boost\boost_1_65_1\boost\config\compiler (see Unknown compiler version while compiling Boost with MSVC 14.0 (VS 2015)!
Replaced the lines in the bottom of the file visualc.hpp :
// last known and checked version is 19.11.25506 (VC++ 2017.3):
#if (_MSC_VER > 1911)
with
// last known and checked version is 19.13.26128 (VC++ 2017.5.6):
#if (_MSC_VER > 1913)
Open another file project-config.jam under the folder boost_1_65_1 and updated the second line to the following:
using msvc : 14.1 : "C:\Program Files (x86)\Microsoft Visual Studio\2017
\Professional\VC\Tools\MSVC\14.13.26128\bin\Hostx64\x64\cl.exe" ;
Go back to developer prompt command line and run the following to build Boost:
b2 toolset=msvc-14.1 address-model=64
It seems I have done the following items correctly:
properly built the libraries, though not using the default directory. I confirmed that the requested library is built.
assigned the path correctly to the CMake designated directories
used CMake find_package() correctly
Here are the relevant versions I am using:
VS: 2017 v15.6.1 with CMake 3.10
Boost version: 1.65.1, built with tool MSVC 14.1
Here is the CMakelist.txt:
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(test)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_DEBUG ON)
set(BOOST_ROOT C:\\boost\\boost_1_65_1)
set(BOOST_INCLUDEDIR C:\\boost\\boost_1_65_1)
set(BOOST_LIBRARYDIR C:\\boost\\boost_1_65_1\\stage\\lib)
set(Boost_DEBUG 1)
find_package(Boost COMPONENTS filesystem REQUIRED)
message(STATUS "Boost LIBRARIES: " ${Boost_LIBRARIES})
add_executable(test_Boost main.cpp)
target_link_libraries(test_Boost ${Boost_LIBRARIES})
here is part of the output that may be relevant:
1> Command line: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\david\CMakeBuilds\94321a3b-9fa8-083f-a86f-e151c3abae79\install\x64-Release" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "E:\computer\boost\cmake"
1> Working directory: C:\Users\david\CMakeBuilds\94321a3b-9fa8-083f-a86f-e151c3abae79\build\x64-Release
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1073 ] _boost_TEST_VERSIONS = 1.65.1;1.65.0;1.65;1.64.0
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1075 ] Boost_USE_MULTITHREADED = ON
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1077 ] Boost_USE_STATIC_LIBS = OFF
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1079 ] Boost_USE_STATIC_RUNTIME = OFF
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1081 ] Boost_ADDITIONAL_VERSIONS =
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1083 ] Boost_NO_SYSTEM_PATHS =
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1151 ] Declared as CMake or Environmental Variables:
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1153 ] BOOST_ROOT = C:\boost\boost_1_65_1
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1155 ] BOOST_INCLUDEDIR = C:\boost\boost_1_65_1
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1157 ] BOOST_LIBRARYDIR = C:\boost\boost_1_65_1\stage\lib
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1159 ] _boost_TEST_VERSIONS = 1.65.1;1.65.0;1.65;1.64.0;...
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1258 ] location of version.hpp: C:/boost/boost_1_65_1/boost/version.hpp
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1282 ] version.hpp reveals boost 1.65.1;...
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1368 ] guessed _boost_COMPILER = -vc141;-vc140
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1378 ] _boost_MULTITHREADED = -mt
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1422 ] _boost_RELEASE_ABI_TAG = -
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1424 ] _boost_DEBUG_ABI_TAG = -gd
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1486 ] _boost_LIBRARY_SEARCH_DIRS_RELEASE = C:\boost\boost_1_65_1\stage\lib;C:\boost\boost_1_65_1/lib;...
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1636 ] Searching for FILESYSTEM_LIBRARY_RELEASE: boost_filesystem-vc141-mt-1_65_1;boost_filesystem-vc141-mt
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1687 ] Searching for FILESYSTEM_LIBRARY_DEBUG: boost_filesystem-vc141-mt-gd-1_65_1;boost_filesystem-vc141-mt-gd
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1636 ] Searching for SYSTEM_LIBRARY_RELEASE: boost_system-vc141-mt-1_65_1;boost_system-vc141-mt
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1687 ] Searching for SYSTEM_LIBRARY_DEBUG: boost_system-vc141-mt-gd-1_65_1;boost_system-vc141-mt-gd
1> -- [ C:/Program Files (x86)/.../FindBoost.cmake:1762 ] Boost_FOUND = 1
1> -- Boost LIBRARIES:
1> CMake Error at C:/Program Files (x86)/.../FindBoost.cmake:1923 (message):
1> Unable to find the requested Boost libraries.
1>
1> Boost version: 1.65.1
1>
1> Boost include path: C:/boost/boost_1_65_1
1>
1> Could not find the following Boost libraries:
1>
1> boost_filesystem
1>
1> Some (but not all) of the required Boost libraries were found. You may
1> need to install these additional Boost libraries. Alternatively, set
1> BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
1> to the location of Boost.
1> Call Stack (most recent call first):
1> CMakeLists.txt(17): (find_package)
1>
1>
1> -- Configuring incomplete, errors occurred!
1> See also "C:/Users/david/CMakeBuilds/94321a3b-9fa8-083f-a86f-e151c3abae79/build/x64-Release/CMakeFiles/CMakeOutput.log".
1> C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe -G "Ninja" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\david\CMakeBuilds\94321a3b-9fa8-083f-a86f-e151c3abae79\install\x64-Release" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/HostX64/x64/cl.exe" -DCMAKE_C_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/HostX64/x64/cl.exe" -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\PROFESSIONAL\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "E:\computer\boost\cmake" returned with exit code: 1
CMake Error at C:/Program Files (x86)/.../FindBoost.cmake:1923 (message):
Unable to find the requested Boost libraries.
Boost version: 1.65.1
Boost include path: C:/boost/boost_1_65_1
Could not find the following Boost libraries:
boost_filesystem
Some (but not all) of the required Boost libraries were found. You may
need to install these additional Boost libraries. Alternatively, set
BOOST_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT
to the location of Boost.
Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)
libboost_filesystem-vc141-mt-gd-1_65_1.lib is the static version of the filesystem library (the name starts with lib)
In CMake you are searching for the dynamic version:
set(Boost_USE_STATIC_LIBS OFF)
This cannot work. Now you have to options:
switch the OFF to ON
rebuild boost with the following addition:
b2 toolset=msvc-14.1 address-model=64 --build-type=complete
The command --build-type=complete build all supported variants of the libraries. Just to be on the safe side ;-)