There are two projects in my C++ solution. So, resultant of one project is the dependency for other project.
I have placed "ProjectA/src/Include" in ProjectB as ProjectA is a dependency for ProjectB. In "ProjectB/Src/stdafx.h" I have included that header file from "ProjectA/src/Include".
I have included the "ProjectA/src/Include" in CMAke file as well and my CMake file of ProjectB look like
include_directories(${PROJECT_SOURCE_DIR}/Dependencies/ProjectA/include)
target_link_directories(ProjectB PRIVATE ${PROJECT_SOURCE_DIR}/Dependencies/ProjectA/lib)
target_link_libraries(ProjectB PRIVATE ProjectA)
I get the issue from this line
target_precompile_headers(ProjectB PRIVATE
"$<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h>"
)
Issue: "Defs.h" is from "ProjectA/src/Include" and included in "ProjectB/Src/stdafx.h"
In file included from /home/vsts/work/1/s/ProjectB/out/build/Linux-GCC-Debug/Debug/Source/CMakeFiles/ProjectB.dir/cmake_pch.hxx:5, from <command-line>:/home/vsts/work/1/s/ProjectB/Source/stdafx.h:18:10: fatal error: Defs.h: No such file or directory
18 | #include "Defs.h" | ^~~~~~~~~~~ compilation terminated. gmake[2]: *** [Source/CMakeFiles/ProjectB.dir/build.make:77: Source/CMakeFiles/ProjectB.dir/cmake_pch.hxx.gch] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:98: Source/CMakeFiles/ProjectB.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2 ##[error]The process '/usr/local/bin/cmake' failed with exit code 2 ##[error]CMake failed with error: The process '/usr/local/bin/cmake' failed with exit code 2
Building in azure devops in Linux envireonment: Ubuntu: 22.04 Cmake: 3.26 The C compiler identification is GNU 11.3.0 The CXX compiler identification is GNU 11.3.0 Ninja for build
- I tried adding /Yc and /Yu compiler options for stdafx.cpp and stdafx.h
Aucun commentaire:
Enregistrer un commentaire