Update: Fixed I've corrected the CMakeLists.txt
file below: I had left out a slash. So the solution was adding ${CMAKE_CURRENT_LIST_DIR}
to the path for target_include_directories
.
I'm trying to use libharu as a subproject. I've set it up as a git submodule in my project in the libharu directory and made edits to the CMakeLists.txt
file (changing CMAKE_*_DIR
references to PROJECT_*_DIR
so it will behave as a subproject as per an unresolved issue raised on the library).
In my main CMakeLists.txt
file I have (edited per suggestions in comments and answers)
add_subdirectory(libharu)
add_executable ( gftopdf)
target_link_libraries(gftopdf libharu)
target_sources(gftopdf PRIVATE
main.cpp
Bitmap.cpp
GFReader.cpp
PDFWriter.cpp
)
target_include_directories(gftopdf PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libharu/include)
(I've also tried without the include
on the target_include_directories
) but when I try to do
#include "hpdf.h"
I get an error 'hpdf.h' file not found
. I'm assuming this is something really basic, but I'm new to CMake.
I did see that I have this warning which is probably relevant:
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
hpdf
(CLion is inconsistent about showing me the CMake run output when I make changes so I hadn't noticed this before.) Adding
set(CMAKE_MACOSX_RPATH 0)
(or 1
) removes the warning but does not resolve the issue, so I suspect it's unrelated.