Trying to port game to FreeBSD, need some assistance with CMake/ffmpeg

Hello all,

I'm very new to FreeBSD and would appreciate a little assistance on what I'm doing wrong here. I work on a game (https://github.com/itgmania/itgmania) which is very stable and well tested under Linux - I'm very familiar with getting it built on different Linux distributions. I'm trying to get it running on FreeBSD.

I have not found out why cmake is failing to find ffmpeg, which is in its expected location inside the build directory, when this kind of error has never been seen on Linux hosts.

Normally when building the game, ffmpeg (among others) is pulled in as a git submodule and used in building, but it's failing to find ffmpeg.

Other submodules are being pulled in and recognized but I'm not sure what is going on here.

Building supposed to be pretty simple; you can clone the project with git, enter the directory, run the following:
  • git submodule update --init --recursive
  • cmake -B build
  • and then cmake --build build and all should be working as expected.
Specifically, I'm using cmake -DCMAKE_C_COMPILER=/usr/local/bin/gcc -DCMAKE_CXX_COMPILER=/usr/local/bin/g++ -B build to ensure gcc is being used.

The problem is it's apparently failing to find ffmpeg, even if I point it to the directory manually:

Code:
CMake Error at src/CMakeLists.txt:462 (add_dependencies):
  The dependency target "ffmpeg" of target "ITGmania" does not exist.

I tried with:
  • the ffmpeg pulled in by git, located at ./extern/ffmpeg (what it should be using)
  • ffmpeg-6.1.1_6,1 from pkg
  • pointing cmake to the ffmpeg sources at /usr/ports/multimedia/ffmpeg

The relevant CMake code is as follows...

Code:
  add_dependencies("${SM_EXE_NAME}" "ffmpeg")
  list(APPEND SM_INCLUDE_DIRS "${SM_FFMPEG_INCLUDE}")
else()
  if(MSVC)
    list(APPEND SM_INCLUDE_DIRS "${SM_EXTERN_DIR}/ffmpeg-w32/include")
  else()
    add_dependencies("${SM_EXE_NAME}" "ffmpeg") <------- the line cmake fails at 
    list(APPEND SM_INCLUDE_DIRS "${SM_FFMPEG_INCLUDE}")

I ensured the variable for the FFMPEG_INCLUDE directory was valid and correct

Are there any peculiarities about CMake on FreeBSD i may be missing here? So far I haven't been able to deduce why cmake is failing to recognize ffmpeg. I'm at a loss for why this may be.
 
I'm just guessing here, but the problem might lie in StepmaniaCore.cmake. It doesn't seem to look for dependencies on FreeBSD. Instead of elseif(LINUX) on line 257, maybe replace it with something like elseif(LINUX OR BSD) or just elseif(BSD) and see what happens.
 
Hmm. Possibly pointing the SM_FFMPEG_INCLUDE variable to /usr/local/include after installing the ffmpeg package?

Likewise with SM_EXE_NAME to be /usr/local/bin/ffmpeg.

The extern dependencies design is pretty poor engineering though. Upstream developers incorrectly assume that platforms other than Wintel and Linux don't need patches to build. This port might be more of a marathon rather than a sprint!
 
Nice to see that porting effort. CMake probably doesn't know about the "ffmpeg" target because it is defined in
CMake/SetupFfmpeg.cmake, and that file is only included for MacOS and Linux - fix as outlined by huggablemonad. I know of other ports that build an internal version of ffmpeg, web browsers in particular, maybe additional patches are needed to build ffmpeg correctly.

The canonical way would be to use multimedia/ffmpeg provided by packages, but for that you'd have to replace the CMake add_dependencies() and ffmpeg target with a method to find the ffmpeg package like find_package().

BTW, can anyone explain why this post showed up for a short time yesterday, and then disappeared until today?
 
I'm just guessing here, but the problem might lie in StepmaniaCore.cmake. It doesn't seem to look for dependencies on FreeBSD. Instead of elseif(LINUX) on line 257, maybe replace it with something like elseif(LINUX OR BSD) or just elseif(BSD) and see what happens.
Thanks so much for this. Because that file had a check if the system was BSD, I thought it was set to go, but changing all instances of LINUX to LINUX OR BSD allowed me to finish building it.

This port might be more of a marathon rather than a sprint!
We are overhauling an awful lot of 10-20 year old code, it's definitely a commitment. :)

The canonical way would be to use multimedia/ffmpeg provided by packages, but for that you'd have to replace the CMake add_dependencies() and ffmpeg target with a method to find the ffmpeg package like find_package().

BTW, can anyone explain why this post showed up for a short time yesterday, and then disappeared until today?
Thank you for noting this!

It disappeared because I edited the original post and I don't have 10 posts here yet, so all my edits have to be approved by moderators for now.
 
Back
Top