-1

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! :)

zwolfgang
  • 43
  • 5
  • [Edit] your question with verbose build output. – Stephen Newell Aug 13 '22 at 17:53
  • You missed the important information about where CMakeLists.txt is located. – 273K Aug 13 '22 at 17:55
  • 2
    I suppose `home/wolf/vst/distort/JuceLibraryCode/` should be an absolute path, but relative one was given. – 273K Aug 13 '22 at 17:57
  • You already set the variable `HEADER_FILES` with the path. Why don't you use that variable in the `target_include_directories` instead of retyping the full path, with a chance of typos (like you actually have)? – Some programmer dude Aug 13 '22 at 18:24

2 Answers2

1

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)
273K
  • 29,503
  • 10
  • 41
  • 64
-1

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

file(GLOB headers ${CMAKE_SOURCE_DIR}/JuceLibraryCode)
...
target_include_directories(Distort PRIVATE ${headers})
Arnab De
  • 402
  • 4
  • 12
  • [We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.](https://cmake.org/cmake/help/v3.0/command/file.html) – 273K Aug 13 '22 at 18:41
  • [Why is cmake file GLOB evil?](https://stackoverflow.com/questions/32411963/why-is-cmake-file-glob-evil) – 273K Aug 13 '22 at 18:42