Radfordhound / HedgeLib

A C++ library and collection of tools that aims to make modding games in the Sonic the Hedgehog franchise easier.
MIT License
88 stars 24 forks source link

Trouble with CMake #83

Closed Ashrindy closed 10 months ago

Ashrindy commented 10 months ago

Hey! I'm a bit new to CMake so this might be a simple and stupid solution, but I'm getting this error which I have no idea on how to solve. Screenshot_239 Would appreciate any sort of solution!

Knuxfan24 commented 10 months ago

This looks like the same (or a similar) problem in https://github.com/Radfordhound/HedgeLib/issues/81, has anything in that thread helped?

Ashrindy commented 10 months ago

@Knuxfan24 Absolutely not :/. I've tried everything in that thread, but nothing seemed to help.

Radfordhound commented 10 months ago

Hey, sorry you're having issues! Thanks for attaching a screenshot; that's very helpful!

It looks like the Get-Dependencies script is running CMake, and CMake is failing, because it can't find a "generator" to use (a thing to build the C++ code with, basically).

Do you have Visual Studio installed, along with the C++ build tools? Those are required to build C++ code on Windows (they're big downloads, so sorry in advance for this if you don't already have them. Microsoft moment).

Ashrindy commented 10 months ago

@Radfordhound Thanks for your worry! I've the C++ build tools downloaded, which is why I'm scratching my head on why it doesn't work.

Radfordhound commented 10 months ago

@Ashrindy Huh, I'm not sure why CMake is defaulting to the Unix Makefiles generator then, that's very weird! Is this being run in a Unix-like environment, like MinGW or something?

Regardless, assuming you've got Visual Studio 2022, try adding -G "Visual Studio 17 2022" to line 53 of Get-Dependencies.ps1, like so:

& cmake -Wno-deprecated -G "Visual Studio 17 2022" -A $Architecture ../src/$SourcePath $Arguments $InstalledPrefixArgument

(Or, if you're using Visual Studio 2019, then use -G "Visual Studio 16 2019" instead.)

Then, try running the Get-Dependencies script again, to see if that lets you build (or at least gives you a different error).

Ashrindy commented 10 months ago

@Radfordhound I'm not quite sure on the environment. Though after adding that argument in, it spits out a different error Screenshot_240. Even though I have VS 2022 downloaded and am constantly using, it says it doesn't exist.

Radfordhound commented 10 months ago

@Ashrindy Interesting! Normal CMake for Windows builds are always supposed to have the Visual Studio generators built-in... so maybe a special version of CMake is installed on your machine that ended up higher in your PATH somehow? I assume you downloaded your CMake from cmake.org, yeah?

Do you happen to have devkitpro/msys2 installed? That comes with its own version of CMake which might be screwing with things.

What does it say if you run the following command in a Command Prompt window:

(NOTE: It has to be command prompt, as for some reason, this command seems to just output nothing in PowerShell)

where cmake.exe

For me, it listed two paths:

E:\Program Files\CMake\bin\cmake.exe
e:\devkitPro\msys2\usr\bin\cmake.exe

As you can see, I have devkitpro installed, but it's lower in my PATH, so when I run "cmake", it uses that first cmake.exe, which is the correct one, and it has the Visual Studio generators.

If I instead run the second one that it lists for me from devkitpro, I also do not have any Visual Studio generators listed.

Ashrindy commented 10 months ago

@Radfordhound You were right! I have msys2 downloaded, and it was above my normal cmake.exe. Though it only worked when I removed -G "Visual Studio 17 2022", which is kinda weird, but atleast it solved my problem! Thanks for your help and patience! Very appreciated!

Radfordhound commented 10 months ago

@Ashrindy Ay! 🎉 No problem, happy I could help!