Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent use of ProjectOptions_SRC_DIR as cache var #154

Merged

Conversation

ClausKlein
Copy link
Contributor

@ClausKlein ClausKlein commented Sep 15, 2022

if to project A and B use different version of project_options and
project C use A and B with CMP.cmake (FetchContents), there is a common CMakeCache variable used!

src/Index.cmake Outdated Show resolved Hide resolved
src/Index.cmake Outdated Show resolved Hide resolved
@ClausKlein
Copy link
Contributor Author

I have problems to build the test on my native OSX with newest apple clang:

-- Build files have been written to: /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install
+ cmake --build ./cmake-build-test-x86_64-Debug/install
[4/9] Building CXX object CMakeFiles/main.dir/cmake_pch.hxx.pch
Checking /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/main.dir/cmake_pch.hxx.cxx ...
Checking /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/main.dir/cmake_pch.hxx.cxx: FMT_LOCALE=1...
[5/9] Building CXX object CMakeFiles/lib2.dir/cmake_pch.hxx.pch
Checking /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/lib2.dir/cmake_pch.hxx.cxx ...
Checking /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/lib2.dir/cmake_pch.hxx.cxx: FMT_LOCALE=1...
[6/9] Building CXX object CMakeFiles/main.dir/src/main/main.cpp.o
FAILED: CMakeFiles/main.dir/src/main/main.cpp.o 
/usr/local/Cellar/cmake/3.24.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;--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;--std=c++20" --source=/Users/clausklein/cmake/project_options/test/src/main/main.cpp -- /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -DFMT_LOCALE -isystem /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/vcpkg_installed/x64-osx/include -isystem /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/vcpkg_installed/x64-osx/include/eigen3 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fcolor-diagnostics -march=native --coverage -O0 -g -fsanitize=address,undefined -Wall -Wextra -Wextra-semi -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -std=c++20 -Winvalid-pch -Xclang -include-pch -Xclang /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/main.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/main.dir/cmake_pch.hxx -MD -MT CMakeFiles/main.dir/src/main/main.cpp.o -MF CMakeFiles/main.dir/src/main/main.cpp.o.d -o CMakeFiles/main.dir/src/main/main.cpp.o -c /Users/clausklein/cmake/project_options/test/src/main/main.cpp
error: PCH file built from a different branch ((clang-1400.0.29.102)) than the compiler () [clang-diagnostic-error]
1 error generated.
Error while processing /Users/clausklein/cmake/project_options/test/src/main/main.cpp.
Found compiler error(s).
[7/9] Building CXX object CMakeFiles/lib2.dir/src/mylib2/lib.cpp.o
FAILED: CMakeFiles/lib2.dir/src/mylib2/lib.cpp.o 
/usr/local/Cellar/cmake/3.24.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;--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;--std=c++20" --source=/Users/clausklein/cmake/project_options/test/src/mylib2/lib.cpp -- /Applications/Xcode.app/Contents/Developer/usr/bin/g++ -DFMT_LOCALE -I/Users/clausklein/cmake/project_options/test/include -isystem /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/vcpkg_installed/x64-osx/include -isystem /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/vcpkg_installed/x64-osx/include/eigen3 -isystem /Users/clausklein/cmake/project_options/test/libs/mythirdpartylib/include -isystem /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/libs/mythirdpartylib -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -fcolor-diagnostics -march=native --coverage -O0 -g -fsanitize=address,undefined -Wall -Wextra -Wextra-semi -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -std=c++20 -Winvalid-pch -Xclang -include-pch -Xclang /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/lib2.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /Users/clausklein/cmake/project_options/test/cmake-build-test-x86_64-Debug/install/CMakeFiles/lib2.dir/cmake_pch.hxx -MD -MT CMakeFiles/lib2.dir/src/mylib2/lib.cpp.o -MF CMakeFiles/lib2.dir/src/mylib2/lib.cpp.o.d -o CMakeFiles/lib2.dir/src/mylib2/lib.cpp.o -c /Users/clausklein/cmake/project_options/test/src/mylib2/lib.cpp
error: PCH file built from a different branch ((clang-1400.0.29.102)) than the compiler () [clang-diagnostic-error]
1 error generated.
Error while processing /Users/clausklein/cmake/project_options/test/src/mylib2/lib.cpp.
Found compiler error(s).
ninja: build stopped: subcommand failed.
bash-3.2$ #

@ClausKlein
Copy link
Contributor Author

this changes helps:

diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7739dca..b4f70da 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.16...3.21)
+cmake_minimum_required(VERSION 3.16...3.24)
 
 # set a default CXX standard used by the external tools like clang-tidy, cppcheck, etc.
 # You can later set fine-grained standards for each target using `target_compile_features`
@@ -49,16 +49,16 @@ project_options(
   ENABLE_CACHE
   ENABLE_CONAN
   # WARNINGS_AS_ERRORS
-  ENABLE_CPPCHECK
+  # ENABLE_CPPCHECK
   ENABLE_CLANG_TIDY
-  # ENABLE_INCLUDE_WHAT_YOU_USE
+  ENABLE_INCLUDE_WHAT_YOU_USE
   ENABLE_COVERAGE
-  ENABLE_PCH
-  PCH_HEADERS
-  ${PCH_HEADERS}
+  # ENABLE_PCH
+  # PCH_HEADERS
+  # ${PCH_HEADERS}
   ENABLE_DOXYGEN
-  ENABLE_INTERPROCEDURAL_OPTIMIZATION
-  ENABLE_NATIVE_OPTIMIZATION
+  # ENABLE_INTERPROCEDURAL_OPTIMIZATION
+  # ENABLE_NATIVE_OPTIMIZATION
   # ENABLE_USER_LINKER
   # ENABLE_BUILD_WITH_TIME_TRACE
   # ENABLE_UNITY

@aminya
Copy link
Owner

aminya commented Sep 16, 2022

I have problems to build the test on my native OSX with newest apple clang:

It seems that PCH files are outdated. Clean the build directory.

@aminya aminya merged commit 4238db0 into aminya:main Sep 16, 2022
@ClausKlein
Copy link
Contributor Author

It seems that PCH files are outdated. Clean the build directory.

I do this always

@aminya
Copy link
Owner

aminya commented Sep 16, 2022

Open a new issue. It should be reproducible in CI.

@ClausKlein ClausKlein deleted the feature/prevent-use-of-ProjectOptions_SRC_DIR branch September 16, 2022 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants