Announcement

Collapse
No announcement yet.

[Moved from GitHub] CMake improvements and fixes for Linux, Windows and Mac - Discussion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Moved from GitHub] CMake improvements and fixes for Linux, Windows and Mac - Discussion

    Moved from GitHub to not clog up the pull request. See CMake improvements and fixes for Linux, Windows and Mac for the original discussion.
    ----

    Last post by me:

    Alright, let's take a step back and have a look at this.

    Dropping everything, this is a step-by-step guide on how to get this working properly with CLion, Linux and Mac. Go over each step and make sure you've done them all.
    1. Patch UBT with this pull request
    2. Delete your current CMakeLists.txt.
    3. Set the compiler to Clang by going into Settings -> Build -> Toolchains -> CMake and setting two variables:
      CLion compiler configuration
    4. When you've changed compilers, open CLion and invalidate the caches by going to File -> Invalidate Caches / Restart.
    5. Build UBT. Go to the root folder of the engine, and run the following command:
      Code:
      ./GenerateProjectFiles.sh -project="<path>/<to>/<your>/<project>/<project>.uproject" -game -engine
      Make sure this is an absolute path, and that it doesn't go through any symlinks - CLion seems to have trouble with those. Omit "-engine" if you don't plan on building any engine targets, or if you're generating for a game project.
    6. Open the generated CMakeLists.txt in CLion.
    7. CLion will now begin to load the project. This initial loading may take a very long time, depending on the size and scope of the project. Before it's done, nothing will work. You can see the progress of this in the bottom bar. Grab a drink and sit back.
      Your paths will vary depending on your system, but those are valid for most Linux systems.
    8. In order to speed up loading times, you can comment out all engine-related build targets if you've no plans on building them (you can also omit the -engine switch from the previous command). You can also comment out any of your game targets that you don't plan on building.
      CLion targets
    9. After the loading has fully finished, you should be good to go. If not, we can start troubleshooting.




    ----
    Last edited by Jargon; 07-02-2016, 07:05 AM.
    Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
    Stalk me on the IRC: jarl or jargon
    Need a launcher for your games? Check out Launchpad

    #2
    Thanks for updating this process! I'm really hoping to get CLion working on windows - being able to use the same IDE regardless of platform is HUGE. I also find VS a strange and clunky beast.

    Unfortunately running
    ./GenerateProjectFiles.bat -project="<path/to/my/project>.uproject" -game -engine
    Runs successfully(?), but does not produce a CMakeLists.txt on windows. It outputs this:
    Setting up Unreal Engine 4 project files...
    Discovering modules, targets and source code for project...
    Binding IntelliSense data... 100%
    Writing project files... 100%
    I have GitBash installed, so I can technically run ./GenerateProjectFiles.sh, but that's obviously the wrong approach on windows - it gives me a lot of errors, like I don't have xcode, and I haven't run Setup.sh, and Setup.sh can't find mono... etc.

    Comment


      #3
      Oh success! I just needed to add the -cmakefile flag. Now I have the CMakeLists.txt. I'm trying to get CLion happy with my cmake + clang + cygwin next.

      Comment


        #4
        Originally posted by AssumptionSoup View Post
        Thanks for updating this process! I'm really hoping to get CLion working on windows - being able to use the same IDE regardless of platform is HUGE. I also find VS a strange and clunky beast.

        Unfortunately running

        Runs successfully(?), but does not produce a CMakeLists.txt on windows. It outputs this:


        I have GitBash installed, so I can technically run ./GenerateProjectFiles.sh, but that's obviously the wrong approach on windows - it gives me a lot of errors, like I don't have xcode, and I haven't run Setup.sh, and Setup.sh can't find mono... etc.
        That's a little peculiar. Could you run the effective UBT command produced by GenerateProjectFiles in debug mode and see if you can suss anything out? I don't have any Windows computers or VMs on hand, unfortunately.
        Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
        Stalk me on the IRC: jarl or jargon
        Need a launcher for your games? Check out Launchpad

        Comment


          #5
          Originally posted by AssumptionSoup View Post
          Thanks for updating this process! I'm really hoping to get CLion working on windows - being able to use the same IDE regardless of platform is HUGE. I also find VS a strange and clunky beast.

          Unfortunately running

          Runs successfully(?), but does not produce a CMakeLists.txt on windows. It outputs this:


          I have GitBash installed, so I can technically run ./GenerateProjectFiles.sh, but that's obviously the wrong approach on windows - it gives me a lot of errors, like I don't have xcode, and I haven't run Setup.sh, and Setup.sh can't find mono... etc.
          Ah, actually - it would seem whoever worked with the generated before me may have completely disabled generating CMake files on Windows by making IsWindowsFiltered return false... I'll look into it. Debug anyway if you can, it would help a lot to see where it drops out.
          Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
          Stalk me on the IRC: jarl or jargon
          Need a launcher for your games? Check out Launchpad

          Comment


            #6
            I've had a look and pushed some more changes that should fix CMake generation on Windows. Testing now.
            Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
            Stalk me on the IRC: jarl or jargon
            Need a launcher for your games? Check out Launchpad

            Comment


              #7
              Thank you very much for this, looking forward to see Clion + UE4 work on windows.
              Marketplace: Quality Game Settings

              Comment


                #8
                Just for future reference, on Mac you still need to modify the command files to have the -cmakefile

                #!/bin/sh
                # Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
                #
                # Simple wrapper around GenerateProjectFiles.sh using the
                # .command extension enables it to be run from the OSX Finder.

                sh "`dirname "$0"`"/GenerateProjectFiles.sh -cmakefile
                --
                Reapazor

                Comment


                  #9
                  Hey,

                  Thanks for the pull!

                  I'm having troubles when trying to build the patched UBT. It throws me the following error in several lines:

                  error CS1056: Unexpected character `$'

                  Is this a mono/C# version problem? I'm using the release Unreal4 branch, is that the problem?

                  Thank you and best regards,

                  Saso

                  Comment


                    #10
                    Are we supposed to be able to connect the debugger with this? I could have sworn I've managed to do it in the past, but can't seem to get the debugger to attach now. As of right now, I'm just able to get the code to build, but not run from CLion.

                    Comment


                      #11
                      Originally posted by zerophase View Post
                      Are we supposed to be able to connect the debugger with this? I could have sworn I've managed to do it in the past, but can't seem to get the debugger to attach now. As of right now, I'm just able to get the code to build, but not run from CLion.
                      I've successfully debugged both the engine and my own game code using this patchset and CLion on Linux. Are you running a target without debug symbols, or doing something else out of the ordinary?
                      Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
                      Stalk me on the IRC: jarl or jargon
                      Need a launcher for your games? Check out Launchpad

                      Comment


                        #12
                        Originally posted by Jargon View Post
                        I've successfully debugged both the engine and my own game code using this patchset and CLion on Linux. Are you running a target without debug symbols, or doing something else out of the ordinary?
                        I'm on 4.12, and I just pulled in your CMakefileGenerator.cs changes. Right now, I'm testing if I can debug the game through CodeLite. I have a feeling the package maintainer removed some key files, trying to slim the Unreal install down.

                        This is what he's copying over. Can you see anything missing that should definitely be in there?

                        package() {
                        install -Dm644 UE4Editor.desktop "$pkgdir/usr/share/applications/UE4Editor.desktop"

                        cd $srcdir/UnrealEngine

                        # license
                        install -Dm644 LICENSE.pdf "$pkgdir/usr/share/licenses/UnrealEngine/LICENSE.pdf"

                        # engine
                        install -d "$pkgdir/opt/$pkgname/Engine"
                        # these folders needs to be writable, otherwise there is a segmentation fault when starting the editor
                        cp -r Engine/Binaries "$pkgdir/opt/$pkgname/Engine/Binaries"
                        cp -r Engine/Build "$pkgdir/opt/$pkgname/Engine/Build"
                        cp -r Engine/Config "$pkgdir/opt/$pkgname/Engine/Config"
                        cp -r Engine/Content "$pkgdir/opt/$pkgname/Engine/Content"
                        install -d "$pkgdir/opt/$pkgname/Engine/DerivedDataCache" # editor needs this
                        cp -r Engine/Documentation "$pkgdir/opt/$pkgname/Engine/Documentation"
                        cp -r Engine/Extras "$pkgdir/opt/$pkgname/Engine/Extras"
                        install -d "$pkgdir/opt/$pkgname/Engine/Intermediate" # editor needs this, but not the files from the build
                        cp -r Engine/Intermediate "$pkgdir/opt/$pkgname/Engine/Intermediate"
                        cp -r Engine/Plugins "$pkgdir/opt/$pkgname/Engine/Plugins"
                        cp -r Engine/Programs "$pkgdir/opt/$pkgname/Engine/Programs"
                        cp -r Engine/Saved "$pkgdir/opt/$pkgname/Engine/Saved"
                        cp -r Engine/Shaders "$pkgdir/opt/$pkgname/Engine/Shaders"
                        cp -r Engine/Source "$pkgdir/opt/$pkgname/Engine/Source" # the source cannot be redistributed, but seems to be needed to compile c++ projects
                        chmod -R a+rwX "$pkgdir/opt/$pkgname/Engine"

                        # content
                        cp -r FeaturePacks "$pkgdir/opt/$pkgname/FeaturePacks"
                        cp -r Samples "$pkgdir/opt/$pkgname/Samples"
                        cp -r Templates "$pkgdir/opt/$pkgname/Templates"

                        # build scripts, used by some plugins
                        install -Dm755 GenerateProjectFiles.sh "$pkgdir/opt/$pkgname/GenerateProjectFiles.sh"
                        install -Dm755 Setup.sh "$pkgdir/opt/$pkgname/Setup.sh"

                        # icon for .desktop file
                        install -Dm644 Engine/Source/Programs/UnrealVS/Resources/Preview.png "$pkgdir/usr/share/pixmaps/UE4Editor.png"
                        }
                        This is what I was using for the install previously, while running 4.11
                        package() {
                        install -Dm644 UE4Editor.desktop "$pkgdir/usr/share/applications/UE4Editor.desktop"

                        cd $srcdir/UnrealEngine

                        install -Dm644 LICENSE.pdf "$pkgdir/usr/share/licenses/UnrealEngine/LICENSE.pdf"

                        install -d "$pkgdir/opt/$pkgname"

                        # copy the entire build dir, ~22 GiB
                        # @todo only copy what is needed
                        cp -r * "$pkgdir/opt/$pkgname/"

                        # make the whole thing world writable, otherwise there is a segmentation fault when starting the editor
                        # @todo find out what specifically needs to writable
                        chmod -R a+w "$pkgdir/opt/$pkgname/"

                        install -Dm644 Engine/Content/Editor/Slate/About/UE4Icon.png "$pkgdir/usr/share/pixmaps/UE4Editor.png"
                        }
                        Last edited by zerophase; 09-03-2016, 05:13 PM.

                        Comment


                          #13
                          Originally posted by zerophase View Post
                          I'm on 4.12, and I just pulled in your CMakefileGenerator.cs changes. Right now, I'm testing if I can debug the game through CodeLite. I have a feeling the package maintainer removed some key files, trying to slim the Unreal install down.

                          This is what he's copying over. Can you see anything missing that should definitely be in there?



                          This is what I was using for the install previously, while running 4.11
                          Is this Arch? I can't see anything obviously wrong, but I could easily be missing something. Could you try booting up an Ubuntu VM or something and seeing if the problems persist?
                          Talk to me on qTox: E8FF4A2B55C2C3A8BC7B60F729E8884BF95CEB4FE8906AE76F5941B08E73066AF562A26C280B
                          Stalk me on the IRC: jarl or jargon
                          Need a launcher for your games? Check out Launchpad

                          Comment


                            #14
                            Originally posted by Jargon View Post
                            Is this Arch? I can't see anything obviously wrong, but I could easily be missing something. Could you try booting up an Ubuntu VM or something and seeing if the problems persist?
                            This is Arch. So, debugging is definitely working in CodeLite. Going to wait for CLion to load, and check the targets.

                            These are the settings I have for Run/Debug:
                            Click image for larger version

Name:	VSBQLDC.png
Views:	1
Size:	12.4 KB
ID:	1114512
                            Last edited by zerophase; 09-03-2016, 06:05 PM. Reason: Adds image of settings.

                            Comment


                              #15
                              Originally posted by Jargon View Post
                              Is this Arch? I can't see anything obviously wrong, but I could easily be missing something. Could you try booting up an Ubuntu VM or something and seeing if the problems persist?
                              Alright, so I tried getting a vm up and running. Got Unreal compiled and everything set up, only to find out Opengl 4 isn't supported yet by virtualbox. I'm just going to reinstall copying everything over to see if everything works correctly.

                              Comment

                              Working...
                              X