Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FetchContent #380

Open
TheMariday opened this issue Jan 29, 2024 · 5 comments
Open

FetchContent #380

TheMariday opened this issue Jan 29, 2024 · 5 comments

Comments

@TheMariday
Copy link

Hi hi! Long time sphinx-fan, first time bug-raiser

Just wanted to report something I found whilst trying to include this library in my latest project using fetch content.

This could very well be a me issue, however in programs/CMakeLists.txt, I needed to add the following around the check dependency:

  if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
    add_dependencies(check ${PROGRAM})
  endif()

I have managed to get pocketsphinx standalone to work with the following CMake, however I do have to provide the -hmm, -lm and -dict args as I assume I've broken the default configs including this in the project without installing it?

Thank you and I hope at least this can help others!

My CMakeLists.txt:

FetchContent_Declare(
  pocketsphinx
  GIT_REPOSITORY https://github.com/themariday/pocketsphinx.git
)

FetchContent_MakeAvailable(pocketsphinx)

include_directories(${pocketsphinx_SOURCE_DIR}/src)
include_directories(${pocketsphinx_SOURCE_DIR}/include)
include_directories(${pocketsphinx_SOURCE_DIR}/src/util)

include_directories(${pocketsphinx_BINARY_DIR})
include_directories(${pocketsphinx_BINARY_DIR}/include)
@dhdaines
Copy link
Contributor

Ah, thanks! I'm still a bit bewildered by CMake, that should be the right fix for the check target, I assume the problem was it was trying to build all the tests when it shouldn't?

For the rest... I'm not familiar with FetchContent, probably the issue is that the default directory isn't getting set properly. Can you point me to a full minimal example of what you're trying to do?

@TheMariday
Copy link
Author

TheMariday commented Jan 30, 2024

Firstly yes, I think that was the issue. All other check dependencies seem to be wrapped in that CMAKE_PROJECT_NAME checking codeblock. See my fork used above here d618334

Secondly, I got up early this morning to put together an example cmake but could I get include_directories to include directories? Could I bugger. Worked last night.

I'll try and get an example to you in the next day or so.

@dhdaines
Copy link
Contributor

Let me know if you find the time to put together an example - I think the fix you propose is correct, though it would be good to test it.

@TheMariday
Copy link
Author

TheMariday commented Jun 4, 2024

Here's an example of building a pocketsphinx example program using fetchcontent:
https://github.com/TheMariday/pocketsphinx_fetch_content_example

P.S. I've modified simple.c at line 58 to cast the returned malloc address from void to short pointer otherwise -fpermissive complains

this points to a fork of pocketsphinx here:
https://github.com/themariday/pocketsphinx.git

I've made 2 changes that both do the same thing:

I've added a project name check around doxygen, program and examples in the main CMakeLists so that these aren't built using fetch content.

If you do want to build these using fetch content, it will still fail due to 'check' missing a project name check in programs/CMakeLists.txt which I have also added.

Hope this is what you were looking for and as always thank you!

@dhdaines
Copy link
Contributor

dhdaines commented Jul 6, 2024

Oh! Thank you! I turned off GitHub notifications so it took me a while to see this. Will look at it ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants