Home > database >  CMake not finding include file I specified
CMake not finding include file I specified

Time:08-14

I am trying to use CMake to debug a JUCE distortion project I'm working on but I can't get the CMakeLists.txt file find the header file JuceHeader.h so it can build and debug the project.

So here's what the file structure looks like:

distort (CMakeLists located here)
|
|_______Source
|       |
|       |________PluginEditor.cpp and .h, PluginProcessor.cpp and .h
|
|_______JuceLibraryCode
        |
        |________JuceHeader.h (and more)

and the txt file in its entirety:

cmake_minimum_required(VERSION 3.0.0)
project(Distort VERSION 0.1.0)

include(CTest)
enable_testing()

set(HEADER_FILES /home/wolf/vst/distort/JuceLibraryCode)
set(SOURCES Source/PluginProcessor.cpp Source/PluginEditor.cpp ${HEADER_FILES}/JuceHeader.h)

add_executable(Distort ${SOURCES})
target_include_directories(Distort PRIVATE home/wolf/vst/distort/JuceLibraryCode/)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

And it gives an error saying that it cannot find JuceHeader.h

And finally, the error output:

[build] /home/wolf/vst/distort/Source/PluginProcessor.h:11:10: fatal error: 'JuceHeader.h' file not found
[build] #include <JuceHeader.h>
[build]          ^~~~~~~~~~~~~~
[build] In file included from /home/wolf/vst/distort/Source/PluginEditor.cpp:9:
[build] /home/wolf/vst/distort/Source/PluginProcessor.h:11:10: fatal error: 'JuceHeader.h' file not found
[build] #include <JuceHeader.h>

Any help would be greatly appreciated! :)

CodePudding user response:

I suppose home/wolf/vst/distort/JuceLibraryCode/ should be an absolute path, but relative one was given. But the absolute path is not a solution.

target_include_directories(Distort PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/JuceLibraryCode)

Or just like bellow

target_include_directories(Distort PRIVATE JuceLibraryCode)

CodePudding user response:

With a relatively new version of cmake, the following should work:

file(GLOB headers ${CMAKE_SOURCE_DIR}/JuceLibraryCode)
...
target_include_directories(Distort PRIVATE ${headers})
  • Related