Giter VIP home page Giter VIP logo

Comments (6)

guitargeek avatar guitargeek commented on August 22, 2024

Hi @svb688, can you be more specific about the issue you encounter? I tried to reproduce it by:

  1. taking a minimal cmake example (https://github.com/krux02/minimal_cmake_example)
  2. adding your snippet to the CMakeLists.txt
  3. adding 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
    )
    
  4. include fastforest.h in the projects main.cpp:
    #include "fastforest.h"
  5. Calling some fastforest functionality in 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.

from xgboost-fastforest.

svb688 avatar svb688 commented on August 22, 2024

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.

from xgboost-fastforest.

svb688 avatar svb688 commented on August 22, 2024

also, what version of cmake are you using? I am using 3.14.5

from xgboost-fastforest.

guitargeek avatar guitargeek commented on August 22, 2024

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:
Skycoder42/QHotkey#24

from xgboost-fastforest.

svb688 avatar svb688 commented on August 22, 2024

ah ha! it did end up being the dash. Thanks for your help. First time using FetchContent!

from xgboost-fastforest.

guitargeek avatar guitargeek commented on August 22, 2024

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.

from xgboost-fastforest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.