cpp-best-practices / gui_starter_template

A template CMake project to get you started with C++ and tooling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure upon building the project on OSX

ClausKlein opened this issue · comments

I have problems with the default project options on OSX:

The clang-tidy check issue an warning:

clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/cpp_starter_project/build /Users/clausklein/Workspace/cpp/cpp_starter_project/test/tests.cpp
80735 warnings generated.
Suppressed 80741 warnings (80735 in non-user code, 6 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/cpp_starter_project/build /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp
80745 warnings generated.
161480 warnings generated.
Suppressed 161492 warnings (161480 in non-user code, 12 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/cpp_starter_project/build /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp
80745 warnings generated.
161480 warnings generated.
Suppressed 161492 warnings (161480 in non-user code, 12 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/cpp_starter_project/build /Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp
/Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp:30:5: warning: an exception may be thrown in function 'main' which should not throw exceptions [bugprone-exception-escape]
int main(int argc, const char **argv)
    ^
92141 warnings generated.
Suppressed 92140 warnings (92140 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/cpp_starter_project/build /Users/clausklein/Workspace/cpp/cpp_starter_project/test/catch_main.cpp
114461 warnings generated.
Suppressed 114467 warnings (114461 in non-user code, 6 NOLINT).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
bash-3.2$ 

But the build generates an error for this?

bash-3.2$ ninja -j1
[1/2] Building CXX object src/CMakeFiles/intro.dir/main.cpp.o
FAILED: src/CMakeFiles/intro.dir/main.cpp.o 
/usr/local/Cellar/cmake/3.22.1/bin/cmake -E __run_co_compile --launcher=/usr/local/bin/ccache --tidy="/usr/local/opt/llvm/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-extra-arg=-std=c++20;-warnings-as-errors=*;--extra-arg-before=--driver-mode=g++" --cppcheck="/usr/local/bin/cppcheck;--enable=style,performance,warning,portability;--inline-suppr;--suppress=internalAstError;--suppress=unmatchedSuppression;--inconclusive;--std=c++20;--error-exitcode=2" --source=/Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DFMT_HEADER_ONLY=1 -DSPDLOG_FMT_EXTERNAL -I/Users/clausklein/Workspace/cpp/cpp_starter_project/build -isystem /Users/clausklein/.conan/data/docopt.cpp/0.6.3/_/_/package/7b8b36b26e865073230053156be1ef16701be0b5/include -isystem /Users/clausklein/.conan/data/fmt/8.1.1/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /Users/clausklein/.conan/data/spdlog/1.9.2/_/_/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -fcolor-diagnostics -fsanitize=address,undefined -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Werror -std=c++2a -MD -MT src/CMakeFiles/intro.dir/main.cpp.o -MF src/CMakeFiles/intro.dir/main.cpp.o.d -o src/CMakeFiles/intro.dir/main.cpp.o -c /Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp
/Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp:30:5: error: an exception may be thrown in function 'main' which should not throw exceptions [bugprone-exception-escape,-warnings-as-errors]
int main(int argc, const char **argv)
    ^
97310 warnings generated.
Suppressed 97309 warnings (97309 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
ninja: build stopped: subcommand failed.
bash-3.2$ 

with current project_options v0.18.0 I get this:

bash-3.2$ !cmake
cmake -B build -S . -G Ninja
-- The CXX compiler identification is AppleClang 13.0.0.13000029
-- The C compiler identification is AppleClang 13.0.0.13000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Developer mode is ON. For production, use `-DENABLE_DEVELOPER_MODE:BOOL=OFF`. Building the project for the developer...
-- Setting build type to 'RelWithDebInfo' as none was specified.
-- /usr/local/bin/ccache found and enabled
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
Building Tests. Be sure to check out test/constexpr_tests for constexpr
testing
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/clausklein/Workspace/cpp/cpp_starter_project/build
bash-3.2$ ninja -C build
ninja: Entering directory `build'
[1/9] Building CXX object test/CMakeFiles/tests.dir/tests.cpp.o
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/tests.cpp ...
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/tests.cpp: NDEBUG=1...
[2/9] Building CXX object test/CMakeFiles/relaxed_constexpr_tests.dir/constexpr_tests.cpp.o
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp ...
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp: CATCH_CONFIG_RUNTIME_STATIC_REQUIRE=1;NDEBUG=1...
[3/9] Building CXX object test/CMakeFiles/constexpr_tests.dir/constexpr_tests.cpp.o
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp ...
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/constexpr_tests.cpp: NDEBUG=1...
[4/9] Building CXX object src/CMakeFiles/intro.dir/main.cpp.o
FAILED: src/CMakeFiles/intro.dir/main.cpp.o 
/usr/local/Cellar/cmake/3.22.1/bin/cmake -E __run_co_compile --launcher=/usr/local/bin/ccache --tidy="/usr/local/opt/llvm/bin/clang-tidy;-extra-arg=-Wno-unknown-warning-option;-warnings-as-errors=*;-extra-arg=-std=c++20;--extra-arg-before=--driver-mode=g++" --cppcheck="/usr/local/bin/cppcheck;--template=gcc;--enable=style,performance,warning,portability;--inline-suppr;--suppress=internalAstError;--suppress=unmatchedSuppression;--inconclusive;--error-exitcode=2;--std=c++20" --source=/Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp -- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DFMT_LOCALE -DFMT_SHARED -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -I/Users/clausklein/Workspace/cpp/cpp_starter_project/build -isystem /usr/local/include/docopt -isystem /usr/local/include -O2 -g -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk -fcolor-diagnostics -fsanitize=address,undefined -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Werror -std=c++2a -MD -MT src/CMakeFiles/intro.dir/main.cpp.o -MF src/CMakeFiles/intro.dir/main.cpp.o.d -o src/CMakeFiles/intro.dir/main.cpp.o -c /Users/clausklein/Workspace/cpp/cpp_starter_project/src/main.cpp
/usr/local/include/spdlog/tweakme.h:74:9: error: 'SPDLOG_FMT_EXTERNAL' macro redefined [clang-diagnostic-macro-redefined,-warnings-as-errors]
#define SPDLOG_FMT_EXTERNAL
        ^
note: previous definition is here
91756 warnings generated.
Suppressed 91755 warnings (91755 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
1 warning treated as error
[5/9] Building CXX object test/CMakeFiles/catch_main.dir/catch_main.cpp.o
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/catch_main.cpp ...
Checking /Users/clausklein/Workspace/cpp/cpp_starter_project/test/catch_main.cpp: NDEBUG=1...
ninja: build stopped: subcommand failed.
bash-3.2$ 

This should all be fixed now as we have gone to great lengths to test on as many platforms as we can. Can you verify?

Yes, it works now. Thanks