Code insight not finding include files for custom target
I'm using cmake with clion to develop a heterogeneous application (running on CPU and FPGA accelerator) as single project. Both the host-side (CPU) and device-side (FPGA) code must be built with compilers provided by the FPGA vendor. In lieu of defining custom toolchains (I would need two), I created cmake custom targets that depend on the output of custom commands that invoke the special compilers. Here's an excerpt from the CMakeLists.txt for host application directory:
include_directories(${CMAKE_PROJECT_DIR}/include /usr/local/include)
add_custom_command( OUTPUT myapp.exe
DEPENDS myapp.cpp
COMMAND bash -c "${BUILD_APP_SCRIPT} myapp.cpp ${HOST_OBJECTS}" )
add_custom_target( myapp ALL
DEPENDS myapp.exe HostObjects
SOURCES myapp.cpp )
${HOST_OBJECTS} are all the .o files compiled for another custom target ("HostObjects") using a similar custom command for those source compiles.
${BUILD_APP_SCRIPT} is a bash script that sources an environment and invokes the vendor compiler with the arguments provided.
The project compiles OK, but CLion is not resolving the include path and not finding the headers in either my project includes or the system includes as specified in include_directories() above.
How can CLion resolve include paths for custom targets based on custom commands? Should this be handled differently?
请先登录再写评论。
Hello!
Do you have any common targets (add_executable or add_library) in your CMakeLists.txt? Are your source files added to them?
I am not using add_library() nor add_executable() because I am not relying on the active toolchain (default GCC) to build anything. I'm only using custom targets as shown above with the depends specified explicitely.
Please provide a non-custom target (a fake
add_executable/add_librarywith proper include directories) for CLion's code insight to work properly. It should be something like this: