Closed svb688 closed 4 years ago
Hi @svb688, can you be more specific about the issue you encounter? I tried to reproduce it by:
CMakeLists.txt
fastforest
to the list of linked libraries in the target_link_libraries
part:
target_link_libraries(example PUBLIC
${Boost_LIBRARIES}
fastforest
# here you can add any library dependencies
)
fastforest.h
in the projects main.cpp
:
#include "fastforest.h"
MAIN()
to see if it gets correctly linked:
std::vector<std::string> features{"f0", "f1", "f2", "f3", "f4"};
const auto fastForest = fastforest::load_txt("model.txt", features);
Since this compiles flawlessly, I don't see at the moment how this is a fastforest issue. Maybe you have tried to include it as <fastforest.h>
, but it should be in double quotes? Or you forgot to link it? Maybe the minimal example I referenced above can help you to solve your problem.
OK Must be something on my end. I am having issues recreating your example as well.
src/main/main.cpp
#include "main.h"
#include "fastforest.h"
// REST OF main.cpp
CMakeLists.txt
include(FetchContent)
FetchContent_Declare(
XGBoost-FastForest
GIT_REPOSITORY https://github.com/guitargeek/XGBoost-FastForest
)
FetchContent_MakeAvailable(XGBoost-FastForest)
# then below in the dependencies section I have:
target_link_libraries(example PUBLIC
${Boost_LIBRARIES}
fastforest
# here you can add any library dependencies
)
Yet when I try to make
minimal_cmake_example/src/main/main.cpp:13:10: fatal error: fastforest.h: No such file or directory
13 | #include "fastforest.h"
If you're able to assist or send your implementation that would be great, Since you're able to make it work the issue seems to be on my end, so you're welcome to close the issue and I can report back later if I figure out what's going on.
also, what version of cmake are you using? I am using 3.14.5
I am using cmake version 3.17.3, so maybe it's a cmake version issue.
Have you tried setting the include directory explicitly for the target? Like below, in our minimal example.
Note that I changed the content name from XGBoost-FastForest
to simply fastforest
, because upper case and the dash caused trouble with the *_SOURCE_DIR
variable (maybe this is even the underlying issue for you).
include(FetchContent)
FetchContent_Declare(
fastforest
GIT_REPOSITORY https://github.com/guitargeek/XGBoost-FastForest
)
FetchContent_MakeAvailable(fastforest)
target_link_libraries(example PUBLIC
${Boost_LIBRARIES}
fastforest
# here you can add any library dependencies
)
message( ${fastforest_SOURCE_DIR} ) # this is just a print to see if the include dir is correct
target_include_directories(example PUBLIC ${fastforest_SOURCE_DIR}/include)
I got inspired a bit by this issue here: https://github.com/Skycoder42/QHotkey/issues/24
ah ha! it did end up being the dash. Thanks for your help. First time using FetchContent!
You are welcome! I didn't know about FetchContent before and was happy to learn about this nice CMake feature.
I'll close this issue, feel free to open a new thread if you have further issues.
I am trying to add this project to my existing project. As per cmake I have the following:
However, when I try to compile I am having issues with including the main header file
fastforest.h
.