filipdutescu / modern-cpp-template Goto Github PK
View Code? Open in Web Editor NEWA template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
License: The Unlicense
A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
License: The Unlicense
Describe the bug
In the file merged from #5, according to GitHub, INSTALL_LOCATION: "d:/a/.local",
is invalid YAML syntax:
Invalid workflow file
You have an error in your yaml syntax on line 26.
To Reproduce
Steps to reproduce the behaviour:
.github/workflows/build.yml
,Merge pull request #5 from thebino/Feature/PipelineRefactor
,Expected behavior
The workflow is expected to run (on the creation of a tag) and create a release with artefacts from the build results.
Screenshots
N/A
Desktop (please complete the following information):
Rather than a PC, the following refers to the GitHub Actions' container:
Additional context
C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat
Describe the bug
when using the BUILD_HEADERS_ONLY option, cmake fails
To Reproduce
Steps to reproduce the behavior:
add
FUNCTION IN ./include/project/temp.hpp
-- Found the following headers:
CMake Error at CMakeLists.txt:89 (foreach):
Unknown argument:
LIST
-- *
CMake Error at CMakeLists.txt:91 (endforeach):
endforeach An ENDFOREACH command was found outside of a proper FOREACH
ENDFOREACH structure. Or its arguments did not match the opening FOREACH
command.
Expected behavior
Generation should work without any error.
Desktop:
Suggested Fix
In ./CMakeLists.txt
line 89 Add S
to LIST
change foreach(header IN LIST headers)
to foreach(header IN LISTS headers)
Getting this in the logs:
[cmake] -- Applied compiler warnings. Using standard .
Describe the bug
In the projects CMakeLists.txt
, there are calls to:
verbose_message(${sources})
verbose_message(${exe_sources})
verbose_message(${headers})
where the variables are lists set in SourcesAndHeaders.cmake
.
However, when the messages are displayed in the console, only the first file is displayed in the list. E.g. if you have multiple sources, only the first file will be displayed.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Should display all the values in a list.
Hello, I am a newbie to cmake, I tried to clone the project and use vs2022 preview to generate it, but I got the error that gtest could not be found, I did not change any code.Do I need to manually download gtest and link to it somewhere.
The system is: Windows - 10.0.19043 - AMD64
Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
Compiler: C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/MSVC/14.30.30423/bin/Hostx64/x64/cl.exe
Build flags:
Id flags:
1> [CMake] -- Build unit tests for the project. Tests should always be found in the test folder
1> [CMake]
1> [CMake] CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
1> [CMake] Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
1> [CMake] GTEST_MAIN_LIBRARY)
1> [CMake] Call Stack (most recent call first):
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
1> [CMake] C:/Program Files/Microsoft Visual Studio/2022/Preview/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.20/Modules/FindGTest.cmake:255 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
1> [CMake] test/CMakeLists.txt:46 (find_package)
1> [CMake] -- Configuring incomplete, errors occurred!
Describe the bug
If I try to build executable by setting -DProject_BUILD_EXECUTABLE=On, the cmake step fails with
CMake Error at test/CMakeLists.txt:51 (target_link_libraries):
Target "Project" of type EXECUTABLE may not be linked into another target.
One may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
executables with the ENABLE_EXPORTS property set.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I'm just trying to build a simple executable, not a library
Desktop (please complete the following information):
cmake --version
cmake version 3.16.3
Additional context
Coming back to C++ after forever away, just learning about the build tooling etc, so it could be a basic mistake on my end. Just want to build an executable program not a library. I failed after tweaking things for my project, and then got the same failure in the vanilla template project with no tweaks.
clang-tidy has set of checks and putted under the some flags. I think it's better to be explicit about which checks are available. I think it's better to list them in the corresponding CMake module of the template, StaticAnalyzers.cmake.
I make a commit, which available in here: https://github.com/p1v0t/modern-cpp-template/commit/f64f3d3ec76078f8200ac5c794c5e80661a71da3
I can pull it, if you people are see whether its useful or not.
Describe the bug
Building with Project_BUILD_HEADERS_ONLY=ON results in an error.
CMake Error at cmake/CompilerWarnings.cmake:93 (target_compile_options): target_compile_options may only set INTERFACE properties on INTERFACE targets
To Reproduce
cmake -DProject_BUILD_HEADERS_ONLY=ON
Expected behavior
This should succeed.
Hi.
This C++ project template is useful to me. Thanks!
Unfortunately, the unit test module failed to compile.
You may need to add the following to test/cmakelists.txt:
target_include_directories(
${test_name}_Tests
PUBLIC ${CMAKE_SOURCE_DIR}/include
PRIVATE ${CMAKE_SOURCE_DIR}/src
)
Describe the bug
After installing conan with pip and enabling conan support for project, several things are not working properly:
${PROJECT_NAME}_CONAN_REQUIRES
and ${PROJECT_NAME}_CONAN_OPTIONS
are not being detected.Already managed to fix that, so you can apply that @filipdutescu:
${CONAN_REQUIRES}
with ${${PROJECT_NAME}_CONAN_REQUIRES}
in Conan.cmake
- just a typo :) apply same for ${CONAN_OPTIONS}
conan_basic_setup()
needs to be called within Conan.cmake
.To Reproduce
Steps to reproduce the behavior:
cmake/StandardSettings.cmake
cmake/Conan.cmake
, like set(${PROJECT_NAME}_CONAN_REQUIRES "boost/1.77.0")
#include <boost/archive/text_oarchive.hpp>
in include/project/tmp.hpp
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
Add any other context about the problem here.
Threr are many third party libraries in my project, I just let compilation warnings to work for my code,not work for third party libraries. Could you please tell me what should I do?
Describe the bug
make install,failed
To Reproduce
make install
Desktop (please complete the following information):
Additional context
include/${PROJECT_NAME} doesn't exist, the correct include path is include/tmp
So make install would failed
Describe the bug
cmake build stage failed with the error msg below:
[main] Building folder: QuicPlus
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.exe" --build d:/VS2019/QuicPlus/build --config Debug --target all -j 24 --
[build] [1/2 50% :: 0.886] Building CXX object test\CMakeFiles\tmp_test_Tests.dir\src\tmp_test.cpp.obj
[build] [2/2 100% :: 1.036] Linking CXX executable test\tmp_test_Tests.exe
[build] FAILED: test/tmp_test_Tests.exe
[build] cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=test\CMakeFiles\tmp_test_Tests.dir --rc="D:\Windows Kits\10\bin\10.0.19041.0\x86\rc.exe" --mt="D:\Windows Kits\10\bin\10.0.19041.0\x86\mt.exe" --manifests -- "D:\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe" /nologo test\CMakeFiles\tmp_test_Tests.dir\src\tmp_test.cpp.obj /out:test\tmp_test_Tests.exe /implib:test\tmp_test_Tests.lib /pdb:test\tmp_test_Tests.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console lib\Debug\QuicPlus.lib D:\vcpkg\installed\x64-windows-static\debug\lib\manual-link\gtest_maind.lib D:\vcpkg\installed\x64-windows-static\debug\lib\gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D D:\VS2019\QuicPlus\build\test && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file D:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary D:/VS2019/QuicPlus/build/test/tmp_test_Tests.exe -installedDir D:/vcpkg/installed/x64-windows-static/debug/bin -OutVariable out""
[build] LINK Pass 1: command "D:\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\Hostx86\x64\link.exe /nologo test\CMakeFiles\tmp_test_Tests.dir\src\tmp_test.cpp.obj /out:test\tmp_test_Tests.exe /implib:test\tmp_test_Tests.lib /pdb:test\tmp_test_Tests.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console lib\Debug\QuicPlus.lib D:\vcpkg\installed\x64-windows-static\debug\lib\manual-link\gtest_maind.lib D:\vcpkg\installed\x64-windows-static\debug\lib\gtestd.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:test\CMakeFiles\tmp_test_Tests.dir/intermediate.manifest test\CMakeFiles\tmp_test_Tests.dir/manifest.res" failed (exit code 1169) with the following output:
[build] gtestd.lib(gtest-all.cc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: struct _Cvtvec __cdecl std::_Locinfo::_Getcvt(void)const " (?_Getcvt@_Locinfo@std@@QEBA?AU_Cvtvec@@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: bool __cdecl std::ios_base::good(void)const " (?good@ios_base@std@@QEBA_NXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: int __cdecl std::ios_base::flags(void)const " (?flags@ios_base@std@@QEBAHXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __cdecl std::ios_base::width(void)const " (?width@ios_base@std@@QEBA_JXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __cdecl std::ios_base::width(__int64)" (?width@ios_base@std@@QEAA_J_J@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::basic_streambuf<char,struct std::char_traits<char> >(void)" (??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: virtual __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::~basic_streambuf<char,struct std::char_traits<char> >(void)" (??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: int __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __int64 __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,__int64)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::eback(void)const " (?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::gptr(void)const " (?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::pbase(void)const " (?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::pptr(void)const " (?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::egptr(void)const " (?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::gbump(int)" (?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::setg(char *,char *,char *)" (?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::epptr(void)const " (?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *)" (?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: void __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::setp(char *,char *,char *)" (?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: char * __cdecl std::basic_streambuf<char,struct std::char_traits<char> >::_Pninc(void)" (?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: virtual __cdecl std::basic_ios<char,struct std::char_traits<char> >::~basic_ios<char,struct std::char_traits<char> >(void)" (??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: void __cdecl std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __cdecl std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: char __cdecl std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "protected: __cdecl std::basic_ios<char,struct std::char_traits<char> >::basic_ios<char,struct std::char_traits<char> >(void)" (??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: void __cdecl std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: __cdecl std::basic_iostream<char,struct std::char_traits<char> >::basic_iostream<char,struct std::char_traits<char> >(class std::basic_streambuf<char,struct std::char_traits<char> > *)" (??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z) already defined in gtestd.lib(gtest-all.cc.obj)
[build] msvcprtd.lib(MSVCP140D.dll) : error LNK2005: "public: virtual __cdecl std::basic_iostream<char,struct std::char_traits<char> >::~basic_iostream<char,struct std::char_traits<char> >(void)" (??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ) already defined in gtestd.lib(gtest-all.cc.obj)
[build] libcpmtd.lib(locale0.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "void __cdecl std::_Facet_Register(class std::_Facet_base *)" (?_Facet_Register@std@@YAXPEAV_Facet_base@1@@Z) already defined in msvcprtd.lib(locale0_implib.obj)
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPEAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(bool)" (?_Init@locale@std@@CAPEAV_Locimp@12@_N@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPEAV12@PEBD@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPEAV12@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Locimp::_New_Locimp(class std::locale::_Locimp const &)" (?_New_Locimp@_Locimp@locale@std@@CAPEAV123@AEBV123@@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(cout.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(cerr.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(locale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(locale.obj) : error LNK2005: "private: static void __cdecl std::locale::_Locimp::_Locimp_Addfac(class std::locale::_Locimp *,class std::locale::facet *,unsigned __int64)" (?_Locimp_Addfac@_Locimp@locale@std@@CAXPEAV123@PEAVfacet@23@_K@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(iosptrs.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xlock.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xlock.obj) : error LNK2005: "public: __cdecl std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QEAA@H@Z) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xlock.obj) : error LNK2005: "public: __cdecl std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QEAA@XZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(wlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(wlocale.obj) : error LNK2005: "public: char const * __cdecl std::_Locinfo::_Getdays(void)const " (?_Getdays@_Locinfo@std@@QEBAPEBDXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(wlocale.obj) : error LNK2005: "public: char const * __cdecl std::_Locinfo::_Getmonths(void)const " (?_Getmonths@_Locinfo@std@@QEBAPEBDXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(wlocale.obj) : error LNK2005: "public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (?_W_Getdays@_Locinfo@std@@QEBAPEBGXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(wlocale.obj) : error LNK2005: "public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (?_W_Getmonths@_Locinfo@std@@QEBAPEBGXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xlocale.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xlocale.obj) : error LNK2005: "public: char const * __cdecl std::_Locinfo::_Getdays(void)const " (?_Getdays@_Locinfo@std@@QEBAPEBDXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xlocale.obj) : error LNK2005: "public: char const * __cdecl std::_Locinfo::_Getmonths(void)const " (?_Getmonths@_Locinfo@std@@QEBAPEBDXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xlocale.obj) : error LNK2005: "public: unsigned short const * __cdecl std::_Locinfo::_W_Getdays(void)const " (?_W_Getdays@_Locinfo@std@@QEBAPEBGXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xlocale.obj) : error LNK2005: "public: unsigned short const * __cdecl std::_Locinfo::_W_Getmonths(void)const " (?_W_Getmonths@_Locinfo@std@@QEBAPEBGXZ) already defined in msvcprtd.lib(MSVCP140D.dll)
[build] libcpmtd.lib(xstol.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xstoul.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xstoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xstoull.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xmtx.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xstrcoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xdateord.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xwcscoll.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xwcsxfrm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xgetwctype.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xtowlower.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xtowupper.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(xstrxfrm.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(StlCompareStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(StlCompareStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(StlLCMapStringW.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] libcpmtd.lib(StlLCMapStringA.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in tmp_test.cpp.obj
[build] LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
[build] test\tmp_test_Tests.exe : fatal error LNK1169: one or more multiply defined symbols found
[build] ninja: build stopped: subcommand failed.
[build] Build finished with exit code 1
The problem is casued by the missing of setup of msvc runtime library.
To Reproduce
vcpkg.exe install gtest:x64-windows-static
..vscode
in the root folder and create a settings.json
file in .vscode
folder with the below content:{
"cmake.configureSettings": {
// "CMAKE_BUILD_TYPE": "Release", this does not take effetc. so use the vscode gui to control the build type
"BUILD_SHARED_LIBS": "OFF",
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_TOOLCHAIN_FILE": "D:/vcpkg/scripts/buildsystems/vcpkg.cmake"
}
}
Change D:/vcpkg/scripts/buildsystems/vcpkg.cmake
to your own path.
7. config and build the project via vscode gui.
Expected behavior
config and build shoudl succeed. and tests shoudl all passed.
Desktop (please complete the following information):
Additional context
I fixed up the issue by adding this line in my fork
I am happy to create a PR when the issue is discussed and got alignment with the author.
Describe the bug
Starting from fresh template, if use gmock option is selected, cmake generate fails.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Generation should work without any error
Desktop (please complete the following information):
Additional context
Might be CMake issue though, does the CPPCHECK feature also work for MSVC compiler? At least I did not get it working.
Describe the confusion
I am confused about the below cmake snippets in StandardSettings.cmake
:
# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
As cmake tool will build all the libraries as shared library when BUILD_SHARED_LIBS
is ON, my understnading is that we should overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS
when ${PROJECT_NAME}_BUILD_SHARED_LIBS
is ON. Something looks like this:
# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libraries except when explicitely set to static" FORCE)
endif()
Let me know what you think it.
Expected behavior
Overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS
when ${PROJECT_NAME}_BUILD_SHARED_LIBS
is ON
Desktop (please complete the following information):
Is your feature request related to a problem? Please describe.
No one should do manual deployments.
Describe the solution you'd like
Create a new tag or push on a release branch to trigger an automated release
Provide usage examples
There are already actions for the different tasks available:
https://github.com/actions/create-release
https://github.com/actions/upload-release-asset
And filtering for specific branches and tags can be achieved by:
on:
push:
branches:
- master
tags:
- v1
P.S.: Amazing work on the template. Working on a similar approach but using a strategy matrix
https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
I am probably doing something wrong, because I'm very new to C++ and wanted to start from a sensible template. (This template is awesome, by the way! It got me started very well, and I am much happier with the state of my learning project than I could imagine if I started from scratch. I just like myself a good build/package structure.)
Describe the bug
Following the instructions, I had a Conan provided library not linked, so I got undefined reference to boost::read_graphml(std::istream&, boost::mutate_graph&, unsigned long)'
from ld
.
To Reproduce
Steps to reproduce the behavior:
I am trying to play around with graphs, so I included Conan in the cmake configuration
option(${PROJECT_NAME}_ENABLE_CONAN "Enable the Conan package manager for this project." ON)
and changed the Conan.cmake
to include boost
set(${PROJECT_NAME}_CONAN_REQUIRES "boost/1.79.0")
I set the project to compile executables and wrote a small main.cpp
to load a graph from a GraphML file
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_concepts.hpp>
#include <boost/graph/graphml.hpp>
#include <ios>
#include <list>
#include "cmcmc/tmp.hpp"
using namespace std;
int main(int argc, char *argv[])
{
using Graph = boost::adjacency_list<>;
Graph g;
boost::dynamic_properties dp{ boost::ignore_other_properties };
if (argc > 1)
{
ifstream in{ argv[1] };
boost::read_graphml(in, g, dp, 0);
}
}
💥
/usr/bin/ld: CMakeFiles/CMCMC.dir/src/main.cpp.o: in function `void boost::read_graphml<boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, boost::no_property, boost::listS> >(std::istream&, boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, boost::no_property, boost::listS>&, boost::dynamic_properties&, unsigned long)':
/home/anaphory/.conan/data/boost/1.79.0/_/_/package/1671931156455a119d7c3f14d951ac5fdbc5cd10/include/boost/graph/graphml.hpp:229: undefined reference to `boost::read_graphml(std::istream&, boost::mutate_graph&, unsigned long)'
collect2: error: ld returned 1 exit status
Expected behavior
I thought with this setup, Conan would pull in Boost to a known location, and cmake would ensure it gets linked to. (I had some version of Boost headers available before installing Boost using Conan, so that may have complicated the impression I got.)
Workaround
I added conan_target_link_libraries(${PROJECT_NAME})
as last line to my CMakeList.txt
and it works fine. So I assume the issue is more how I use the template and associated software – which, fair, I don't really understand well enough – and not an actual issue with the template, but maybe it is an issue worth pointing out?
Environment
I'm happy to provide version strings and other similar items, I just don't know what is useful.
I enabled vcpkg support in my project (which downloaded the appropriate cmake file), created vcpkg.json to specify the dependencies that should be installed, but... they're not being installed. How do I plug in vcpkg to automatically install the dependencies?
Is your feature request related to a problem? Please describe.
This is not really a problem, but you may not have to manually install cmake from source in the Dockerfile
Describe the solution you'd like
You can install cmake via pip
Describe alternatives you've considered
N/A
Provide usage examples
e.g. pip3 install cmake
Additional context
https://cmake-python-distributions.readthedocs.io/en/latest/index.html
Is your feature request related to a problem? Please describe.
Typo fixes in one of the *.md files will rerun the entire CI pipeline. Depending on how long the pipeline takes to run, this may become an issue.
Describe the solution you'd like
Control what triggers the CI pipeline via config.
Describe alternatives you've considered
Github actions doesn't seem to support skipping via a keyword in the commit message, so not sure there is an alternative.
Provide usage examples
See documentation link above
Additional context
I would create a PR, but I don't know if you want to implement a whilelist or a blacklist.
_DEBUG macro is available in MS VC plaform for debug specific code.
however same macro is not available in Linux.
It should be available
Describe the bug
Some of the github actions are outdated.
To Reproduce
Look at the last commit
Desktop:
Adding new files in SourcesAndHeaders.cmake clang-format target stop working, giving "No such file or directory".
It seems only one file can be define for both sources and headers cmake variables.
The name 'Project' is hard coded in the test CMakeLists.txt.
Is your feature request related to a problem? Please describe.
Some people may not have all the required libraries/compilers to compile the project.
However, they may have a container engine available.
Describe the solution you'd like
Add a Dockerfile that allows for simple compilation.
Additional context
https://docs.conan.io/en/latest/howtos/run_conan_in_docker.html
Describe the bug
The build actions do not reflect changes made in commit 38337bc
to the macro names. It is not registered as an error, but CMake warns about it:
CMake Warning: Manually-specified variables were not used by the project: ENABLE_CODE_COVERAGE
To Reproduce
Steps to reproduce the behaviour:
Ubuntu
action,build
job and open the configure
step,Expected behaviour
All options provided to CMake should be name properly and should function as described in the cmake/StandardSettings.cmake
file.
Screenshots
N/A
Desktop (please complete the following information):
Rather than a PC, the following refers to the GitHub Actions' container:
Additional context
N/A
Describe the bug
Enable CONAN
option in StandardSettings.cmake
, then add conanfile.txt
:
[requires]
fmt/7.0.3
[generators]
cmake
To Reproduce
Steps to reproduce the behavior:
Reload
in CMake tabcmake-build-debug
directory
make
Scanning dependencies of target ADemo_LIB
[ 12%] Building CXX object CMakeFiles/ADemo_LIB.dir/src/tmp.cpp.o
Checking /mnt/d/sourcecode/cpp/modern-cpp-template-navono/src/tmp.cpp ...
/mnt/d/sourcecode/cpp/modern-cpp-template-navono/src/tmp.cpp:3:0: style: The function 'add' is never used. [unusedFunction]^
nofile:0:0: information: Unmatched suppression: missingInclude [unmatchedSuppression][ 25%] Linking CXX static library lib/libADemo_LIB.a
[ 25%] Built target ADemo_LIB
Scanning dependencies of target ADemo
[ 37%] Building CXX object CMakeFiles/ADemo.dir/src/main.cpp.o
Checking /mnt/d/sourcecode/cpp/modern-cpp-template-navono/src/main.cpp ...
/mnt/d/sourcecode/cpp/modern-cpp-template-navono/src/main.cpp:7:10: fatal error: fmt/format.h: No such file or directory
7 | #include <fmt/format.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/ADemo.dir/build.make:82: CMakeFiles/ADemo.dir/src/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:172: CMakeFiles/ADemo.dir/all] Error 2
make: *** [Makefile:160: all] Error 2
Disable Conan
option, add conan
integrat command and link library in root CMakeLists.txt
like this:
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
...
target_link_libraries(
${PROJECT_NAME}
PUBLIC
CONAN_PKG::fmt
)
reload cmake, and make
, it works.
Expected behavior
make
successful.
Screenshots
Desktop (please complete the following information):
Additional context
Clion connect WSL2 environment.
Just the vcpkg.cmake
file is being downloaded, however that is not the correct way to use vcpkg, see microsoft/vcpkg#22690.
Hello, I'd like to know how to run GTest and cppcheck in my local, not github. Thanks
The preferred spelling of ccache is “Ccache” or “ccache”, so I suggest using the former variant. Also, I think that it would be better to say “speed up rebuild time” instead of “speed up build time” since that’s more accurate.
Is your feature request related to a problem? Please describe.
IMHO: A template project with cmake files should be clean of cmake-lint
problems
Describe the solution you'd like
Add a .cmake-format
config file to your project root:
format:
dangle_parens: true
keyword_case: upper
line_ending: unix
line_width: 120
max_lines_hwrap: 3
max_pargs_hwrap: 8
max_rows_cmdline: 3
max_subgroups_hwrap: 4
min_prefix_chars: 8
separate_ctrl_name_with_space: false
separate_fn_name_with_space: false
tab_size: 2
markup:
bullet_char: '*'
enum_char: .
enable_markup: false
Provide usage examples
cmake-format -i cmake/*.cmake
cmake-lint cmake/*.cmake
Additional context
you may also use this:
https://github.com/TheLartians/Format.cmake#how-to-integrate
Is your feature request related to a problem? Please describe.
AddressSanitizer is a fast memory error detector. It consists of a compiler instrumentation module and a run-time library. see https://github.com/google/sanitizers/wiki/AddressSanitizer. The tool can detect the following types of bugs:
This tool is very fast. The average slowdown of the instrumented program is ~2x (see
And I think it's quite useful in C/C++ projects. You can simply enable it by compiling and linking your program with -fsanitize=address
flag.
Describe the solution you'd like
Maybe we can add it as an option in cmake/StandardSettings.cmake
?
For example, like this:
option(${PROJECT_NAME}_ENABLE_ASAN "Enable Address Sanitize to detect memory error." ON)
if(${PROJECT_NAME}_ENABLE_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
**Describe the issue **
I am confused about the below cmake snippets in StandardSettings.cmake
:
# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
As cmake tool will build all the libraries as shared library when BUILD_SHARED_LIBS
is ON, my understnading is that we should overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS
when ${PROJECT_NAME}_BUILD_SHARED_LIBS
is ON. Something looks like this:
# Export all symbols when building a shared library
if(${PROJECT_NAME}_BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
set(BUILD_SHARED_LIBS ON CACHE BOOL "build shared libraries except when explicitely set to static" FORCE)
endif()
Let me know what you think it.
To Reproduce
None
Expected behavior
Overwrite the cmake built-in cache variable of BUILD_SHARED_LIBS
when ${PROJECT_NAME}_BUILD_SHARED_LIBS
is ON
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.