Setting cmake's msvc compilers flags on command line using git bash - visual-c++

Can someone help with the following issue. I'm using Cmake + git bash and on the windows machine with msvc compiler. If I configure project in the following way cmake .. everything works fine and I can see the following output:
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.24.28319.0
-- The CXX compiler identification is MSVC 19.24.28319.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
However, when I try to set compiler flags cmake -DCMAKE_CXX_FLAGS="/MD" .. I get the following error:
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.24.28319.0
-- The CXX compiler identification is MSVC 19.24.28319.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.17/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/dev/projects/camshare/microservices/templates/microservice_cpp/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe cmTC_ce8fa.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=16.0 /v:m && Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28319 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
Program
cl /c /Zi /W1 /WX- /diagnostics:column /Od /Ob0 /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_ce8fa.dir\Debug\\" /Fd"cmTC_ce8fa.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue C:/Program Files/Git/MD C:\dev\projects\camshare\microservices\templates\microservice_cpp\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
c1xx : fatal error C1083: Cannot open source file: 'C:/Program': No such file or directory [C:\dev\projects\camshare\microservices\templates\microservice_cpp\build\CMakeFiles\CMakeTmp\cmTC_ce8fa.vcxproj]
MD
c1xx : fatal error C1083: Cannot open source file: 'Files/Git/MD': No such file or directory [C:\dev\projects\camshare\microservices\templates\microservice_cpp\build\CMakeFiles\CMakeTmp\cmTC_ce8fa.vcxproj]
testCXXCompiler.cxx
Generating Code...
CMake will not be able to correctly generate this project.
If I try to do the same with windows cmd everything works fine. Can you explain where is the problem and how I can fix it? Looks like compiler flags were incorrectly appended (strange Files/Git/MD on the command line). I've also tried `CXXFLAGS="/MD" cmake .." and got the same result.

The problem is in git bash mangling of forward slashes, solution can be easily found. Closing the question.

Related

Pico examples C/C++ build issues with cmake - Detecting C compiler ABI info - failed

I'm trying to build the examples for RP pico using Visual Studio Code 2022 on windows 11.
I have been following the "Getting started with raspberry pi pico" document and have succeeded up to the point where the nmake command is used to build the examples using developer command prompt.
It seems the first hurdle is "Detecting C compiler ABI info - failed" please see below for full output. I have searched all over the internet and stack overflow and tried various peoples fixes but nothing seems to help.
I have tried:
Setting cl.exe as administrator
Running developer command prompt as admin
Reinstalling VS code and cmake
Manually installed windows sdk (as it's not an option on the MSVC installer)
Running VsDevCmd.bat which fails with "Encountered errors" but nothing more useful. I have run the debug and output to txt file but I don't know what I'm looking at.
Thanks in advance.
Microsoft (R) Program Maintenance Utility Version 14.32.31329.0
Copyright (C) Microsoft Corporation. All rights reserved.
[ 0%] Built target bs2_default
[ 0%] Built target bs2_default_padded_checksummed_asm
[ 0%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is MSVC 19.32.31329.0
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/pico/Downloads/pico-examples/build/elf2uf2/CMakeFiles/CMakeTmp
Run Build Command(s):nmake -f Makefile /nologo cmTC_add02\fast && "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe" -f CMakeFiles\cmTC_add02.dir\build.make /nologo -L CMakeFiles\cmTC_add02.dir\build
Building C object CMakeFiles/cmTC_add02.dir/testCCompiler.c.obj
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_add02.dir\testCCompiler.c.obj.d --working-dir=C:\pico\Downloads\pico-examples\build\elf2uf2\CMakeFiles\CMakeTmp --filter-prefix="Note: including file: " -- C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\cl.exe #C:\Users\Dan\AppData\Local\Temp\nmE440.tmp
testCCompiler.c
Linking C executable cmTC_add02.exe
"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_add02.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x86\mt.exe --manifests -- C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo #CMakeFiles\cmTC_add02.dir\objects1.rsp #C:\Users\Dan\AppData\Local\Temp\nmE49F.tmp
LINK Pass 1: command "C:\PROGRA~2\MICROS~4\2022\BUILDT~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo #CMakeFiles\cmTC_add02.dir\objects1.rsp /out:cmTC_add02.exe /implib:cmTC_add02.lib /pdb:C:\pico\Downloads\pico-examples\build\elf2uf2\CMakeFiles\CMakeTmp\cmTC_add02.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 /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_add02.dir/intermediate.manifest CMakeFiles\cmTC_add02.dir/manifest.res" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "C:/pico/Downloads/pico-examples/build/elf2uf2/CMakeFiles/CMakeOutput.log".
See also "C:/pico/Downloads/pico-examples/build/elf2uf2/CMakeFiles/CMakeError.log".
NMAKE : fatal error U1077: 'echo' : return code '0x1'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.32.31326\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
Stop.
I had a pretty similar issue in my project with Ninja.
The compilation is triggered with the next bat file (it's not full, just a part to generate CMake cache):
#echo off
SETLOCAL
set BUILD_TYPE=%~1
IF NOT "%BUILD_TYPE%"=="" GOTO BUILD_TYPE_OK
set BUILD_TYPE=Debug
:BUILD_TYPE_OK
set CMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe
set C_COMPILER=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
set CXX_COMPILER=C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
echo Build type: %BUILD_TYPE%
echo SBP_SBP_MSVC_QT64_DIR = %SBP_SBP_MSVC_QT64_DIR%
set PATH_X64=%PATH%;%SBP_SBP_MSVC_QT64_DIR%
set PATH=%PATH_X64%
cmake -DCMAKE_BUILD_TYPE=%BUILD_TYPE% "-DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM%" "-DCMAKE_C_COMPILER=%C_COMPILER%" "-DCMAKE_CXX_COMPILER=%CXX_COMPILER%" -DPDB_DIR=../deploy-pdb/x64 -DCMAKE_INSTALL_PREFIX=../deploy/bin-x64 -G Ninja -S . -B ../build/x64
if %errorlevel% neq 0 exit /b %errorlevel%
echo Done.
ENDLOCAL
The original output looked like this:
Build type: Debug
SBP_SBP_MSVC_QT64_DIR = c:\Qt\5.15.2\msvc2019_64
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/CMakeTestCCompiler.cmake:69 (message):
The C compiler
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/Job/Code/Subpac/x1c1-multitool/build/x64/CMakeFiles/CMakeTmp
Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_3975f && [1/2] Building C object CMakeFiles\cmTC_3975f.dir\testCCompiler.c.obj
[2/2] Linking C executable cmTC_3975f.exe
FAILED: cmTC_3975f.exe
cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_3975f.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1432~1.313\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_3975f.dir\testCCompiler.c.obj /out:cmTC_3975f.exe /implib:cmTC_3975f.lib /pdb:cmTC_3975f.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 ."
RC Pass 1: command "rc /fo CMakeFiles\cmTC_3975f.dir/manifest.res CMakeFiles\cmTC_3975f.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/Test/build/x64/CMakeFiles/CMakeOutput.log".
See also "D:/Test/build/x64/CMakeFiles/CMakeError.log".
[process exited with code 1 (0x00000001)]
The issue was fixed when I added the next line to the build script:
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64. Below the part of the bat file with this line added:
#echo off
SETLOCAL
set BUILD_TYPE=%~1
IF NOT "%BUILD_TYPE%"=="" GOTO BUILD_TYPE_OK
set BUILD_TYPE=Debug
:BUILD_TYPE_OK
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
set CMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022....
Now the output looks like this, and when I add commands to deploy, all works fine:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.2.6
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
Build type: Debug
SBP_SBP_MSVC_QT64_DIR = c:\Qt\5.15.2\msvc2019_64
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- 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.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Test/build/x64
Done.
Hope it will help to solve your problem with nmake.

MSVC do not generate lib via cmake

CMakeLists:
if (MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()
add_library(${PROJECT_NAME} SHARED ${SOURCES})
CMake 2.8.12 + MSVC 2015
config outputs:
-- The C compiler identification is MSVC 19.0.24210.0
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMAKE_C_FLAGS_DEBUG is /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
CMAKE_C_FLAGS_RELEASE is /MD /O2 /Ob2 /D NDEBUG
CMAKE_C_FLAGS_RELWITHDEBINFO is /MD /Zi /O2 /Ob1 /D NDEBUG
CMAKE_C_FLAGS_MINSIZEREL is /MD /O1 /Ob1 /D NDEBUG
-- Configuring done
-- Generating done
Referred https://cmake.org/pipermail/cmake/2009-March/027990.html.
You most likely have not setup your classes and/or function calls to be
exported. If you have no exported classes/functions Visual Studio will not
generate an import library for you.
But adding CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON got the same result.
How to make MSVC generate lib & dll like mingw?
Update cmake 2.8 to 3.4 solves the problem.
https://cmake.org/cmake/help/v3.4/release/3.4.html?highlight=windows_export_all_symbols

MSVC 2017 missing libboost_filesystem-vc141-mt-gd-x32-1_66.lib error

I'm trying to create a dynamic library on Windows but I have a problem with Boost, I keep getting this error
1>LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc141-mt-gd-x32-1_66.lib'
The thing is, according to this http://www.boost.org/doc/libs/1_66_0/more/getting_started/windows.html#header-only-libraries the two librairies are supposed to be header only header only
the cmake i'm using
cmake_minimum_required(VERSION 3.8)
project(mod_autoindex)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
SET (BOOST_ROOT "C:/Program Files (x86)/boost/boost_1_66_0")
SET (BOOST_INCLUDEDIR "${BOOST_ROOT}/boost")
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
include_directories(${Boost_INCLUDE_DIR})
include_directories("../../include")
include_directories("../../include/sza")
include_directories("./include")
file(GLOB_RECURSE CPP_SRCS ${CMAKE_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_SOURCE_DIR}/include/*.hpp)
set(SOURCE_FILES ${CPP_SRCS} ${HEADERS})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME})
Any idea of wrang am i doing wrong ?
cmake output for cmake . -G "Visual Studio 15 2017 Win64"
-- The C compiler identification is MSVC 19.11.25547.0
-- The CXX compiler identification is MSVC 19.11.25547.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/bin/Hostx86/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Boost version: 1.65.1
-- Found the following Boost libraries:
-- filesystem
-- system
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/theo/Desktop/cpp_zia/modules/mod_autoindex
So the solution generation seems to work fine, but after that, when I try to build MSBuild mod_autoindex.sln i get the following error
LINK : fatal error LNK1104: cannot open file 'libboost_filesystem-vc141-mt-gd-1_65_1.lib' [C:\Users\theo\
Desktop\cpp_zia\modules\mod_autoindex\mod_autoindex.vcxproj]
#update here is my current cmake
cmake_minimum_required(VERSION 3.8)
project(mod_autoindex)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}")
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}")
set(BOOST_ROOT "C:/Program Files (x86)/boost/boost_1_65_1")
set(Boost_ADDITIONAL_VERSIONS 1.65.1)
set(BOOST_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS filesystem REQUIRED)
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
else()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
include_directories(${Boost_INCLUDE_DIR})
include_directories("../../include")
include_directories("../../include/sza")
include_directories("./include")
file(GLOB_RECURSE CPP_SRCS ${CMAKE_SOURCE_DIR}/src/*.cpp)
file(GLOB_RECURSE HEADERS ${CMAKE_SOURCE_DIR}/include/*.hpp)
MESSAGE( STATUS "BOOST libraries: " ${Boost_LIBRARIES} )
add_library(${PROJECT_NAME} SHARED ${CPP_SRCS} ${HEADERS})
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
Many Boost libraries indeed are header only, but filesystem is not.
Instead of doing things manually I would use the CMake way of adding library dependencies by using the appropriate find_package module:
set(BOOST_ROOT "C:/Program Files (x86)/boost/boost_1_65_1")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
...
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
Boost binaries for your compiler can be downloaded at https://sourceforge.net/projects/boost/files/boost-binaries/
If CMake does not find your Boost installation (CMake 3.10.2 versions FindBoost.cmake module does know about versions up to Boost 1.65.1) you can try to add before the find_package call
set(Boost_ADDITIONAL_VERSIONS 1.66.0)
but
Boost changed its naming scheme starting from version 1.66.0. CMake up to version 3.10.2 does not know this scheme and therefore cannot handle it. You need to use Boost 1.65.1 instead.
Edit according to the comment by #ComicSansMS:
Do not hardcode the Boost path to your CMakeLists.txt instead set it per environment variable BOOST_ROOT or provide it as argument to your CMake call.
So go to your project path (the path where your CMakeLists.txt is stored)
mkdir build
cd build
and either do
set BOOST_ROOT=C:\Program Files (x86)\boost\boost_1_65_1
cmake .. -G "Visual Studio 15 2017"
or call
cmake .. -G "Visual Studio 15 2017" -DBOOST_ROOT="C:\Program Files (x86)\boost\boost_1_65_1"
Later you can use the buildmode of CMake to build your entire project
cmake --build . --target ALL_BUILD --config Release -- /nologo /verbosity:minimal /maxcpucount

cmake error with a software bam-window software

I am trying to install the tool bam-window but I am getting cmake error. I downloaded the bam-window-master.zip in linux. The link of the tool is hosted in git https://github.com/genome-vendor/bam-window. I downloaded and follow the below commands.
unzip bam-window-master.zip
cd bam-window-master
mkdir build
cd build
cmake ..
On doing cmake .. After compiling I for a while I get an error
-- The C compiler identification is GNU 4.7.2
-- The CXX compiler identification is GNU 4.7.2
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Git: /usr/bin/git (found version "1.7.10.4")
CMake Error at cmake/GitHelper.cmake:15 (message):
Failed to get git revision, abort: fatal: Not a git repository (or any
parent up to mount point /scratch/GT)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
!
Call Stack (most recent call first):
CMakeLists.txt:9 (get_git_version_info)
How do I get rid of this and make the installation proper?
The CMakeLists.txt for this project assumes (unfortunately) that the source code is not downloaded as a zip file, but instead cloned from github.
So instead of using "Dowload ZIP" link, just clone it using regular GIT commands:
git clone https://github.com/genome-vendor/bam-window.git

Compiling cuda in VS2012: fatal error C1083: Cannot open compiler generated file, no such file or directory

I've installed Visual Studio 2012 and the CUDA 6.0 toolkit. I can start a new project and select the CUDA 6.0 Runtime, but when I try to compile, it apparently can't find the object file.
This is the output for the sample code that comes when creating a CUDA project, although I get the same problem even if it's just a normal C program without any CUDA syntax.
Here is the full output I get when building kernel.cu:
1>------ Build started: Project: Temp, Configuration: Debug Win32 ------
1>Build started 08/06/2014 13:14:40.
1>PrepareForBuild:
1> Creating directory "d:\my documents\visual studio 2012\Projects\Temp\Debug\".
1>InitializeBuildStatus:
1> Creating "Debug\Temp.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>CudaBuild:
1> Compiling CUDA source file kernel.cu...
1>
1> D:\Programming>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "D:\Programs\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj "d:\my documents\visual studio 2012\Projects\Temp\Temp\kernel.cu"
1>nvcc : warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.
1> kernel.cu
1>C:\Users\Mort\AppData\Local\Temp\tmpxft_00001d3c_00000000-20_kernel.ii : fatal error C1083: Cannot open compiler generated file: 'Debug/kernel.cu.obj': No such file or directory
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 6.0.targets(597,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2012 -ccbin "D:\Programs\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\kernel.cu.obj "d:\my documents\visual studio 2012\Projects\Temp\Temp\kernel.cu"" exited with code 1.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:03.36
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I'm running Win7 64 bit and VS 2012 Ultimate.
Thanks!
I'm making this an answer since it solved your problem: there seems to be a mismatch between NVCC's path (D:\Programming) and your project's path.
You might end up compiling stuff in the wrong directory and then failing to find the temporaries created by the previous phase. Make sure to fix those paths and the compilation should proceed just fine since everything else matches (i.e. bitness/include paths)

Resources