1. Forum moved (you can use login and pass from old forum)
  2. Many discussions moved to the bugtracker

Unified build system (cmake)

Discussion in 'Coding' started by kkmic, Aug 12, 2014.

  1. kkmic

    kkmic Undefined

    Joined:
    Jul 17, 2014
    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    I believe that it's time to implement a unified build system using cmake (just like OXC does).

    Advantages:
    [list type=decimal]
    [*]One ring to ru... err, one build system that generates the necessary build/project files for all major platforms/IDEs out there
    [*]Only one build system to care for (true, there is stuff that must be processed differently for different platforms, but it's all centralized in one place)
    [*]You basically need to generate the project once, if the build system (CMakeLists) is adjusted later, it will automatically update the project on build
    [*]We can get rid of the Visual Studio specific files from the repository (they are different for each developer out there)
    [*]Separate the source from the compiled output (make a standard "build" directory that should be ignored by Git and generate the project there (resources need to be copied there, but fortunately, this can be automated too)
    [*]The proverbial "more"...
    [/list]
    Disadvantages:
    [list type=decimal]
    [*]pmprog will have to install and learn to use cmake :p
    [/list]
    Unfortunately, I am not a C++ guy, so my experience with cmake is mainly limited to something along the lines of
    Code:
    mkdir build && cd build && cmake .. && make
    .


    Volunteers? I nominate JonnyH :p
     
  2. pmprog

    pmprog Well-Known Member Official Developer Administrator

    Joined:
    Jul 8, 2014
    Messages:
    175
    Likes Received:
    12
    Best Answers:
    0
    What are you talking about? Visual Studio files do not differ between developers.
    Oh, and also...

    If somebody wants to add cmake stuff, fine, but you're not removing the Visual Studio project files.

    Again, what? The Visual Studio project puts the compiled exe in bin\Debug or bin\Release; not in with the source code.
     
  3. kkmic

    kkmic Undefined

    Joined:
    Jul 17, 2014
    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    I think it's a leftover, I'll ask SupSuper when I'll get the chance, to be sure.

    Relax mate, nobody said anything about removing your VS files :) You can keep them even if they are not versioned in the repository.

    Of course it does, because the solution file it is configured to do just that. But it works only for VS developers. On other platforms, you have to configure your build system from scratch. So far.

    And there are two options:
    [list type=decimal]
    [*]Create a build system for each of the other major platforms out there (MacOS and Linux at least) and maintain them separately.
    [*]Use cmake to generate a platform-specific build system on-demand for each platform supported from a single platform-independent file.
    [/list]

    Don't worry, cmake does not bite :) It is not the friendliest system out there either, but it has it's merits. It even has a pretty nice GUI and a wizard-like interface for Windows systems.


    Anyway, as usual, this is me tossing ideas around. Everybody, feel free to disagree. Feedback is always welcome.
     
  4. pmprog

    pmprog Well-Known Member Official Developer Administrator

    Joined:
    Jul 8, 2014
    Messages:
    175
    Likes Received:
    12
    Best Answers:
    0
    https://github.com/SupSuper/OpenXcom/commit/bfe6a553ff030eb82bf3b897bc903ff579781baf
    Search for src/OpenXcom.2010.vcxproj - that's the project file, rather than the solution file. it was updated 6 days ago.
     
  5. kkmic

    kkmic Undefined

    Joined:
    Jul 17, 2014
    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    Yep, it was updated along with the CMakeLists.txt and the makefile.am files - two new files were added to the project, and this change had to be reflected in the build system supported by OXC.

    Warboy updated the VS solution and the two "extra" (from his point of view) solutions. The issue I'm pointing here is that you can either update all the build systems that OpenApoc will support, or update just one that generates the others.

    I'm thinking that maybe you don't know what cmake is and what it will do for you: when you'll run it, it will generate a solution tailored to a certain (your choice) build system. In your case (Visual Studio), you chose a VS project file and cmake will generate a... Visual Studio solution file :)

    And it will keep it up to date automagically.

    Why use cmake to generate a VS .sln instead of simply using the one already available?
    [list type=decimal]
    [*]Project file generation is a one-time only step
    [*]VS solution files are not always identical for every developer, plus that you sometimes want to experiment with things. Yes, you can revert your experiments before doing a commit, but I believe that it's better to have a project file outside the versioned solution for experiments.
    [/list]

    And if you are looking to build a cross-platform app, you will need a cross-platform solution. Maybe not cmake, and maybe not now (though I believe it is not too early to start implementing it), but you will definitely need one.

    Check this StackOverflow answer for a little bit more technical explanation on why to use cmake.
     
  6. pmprog

    pmprog Well-Known Member Official Developer Administrator

    Joined:
    Jul 8, 2014
    Messages:
    175
    Likes Received:
    12
    Best Answers:
    0
    Okay, there's a problem with what you're suggesting - it doesn't fit my workflow.

    When I add a new file (or set of files) to my project, I'll already have visual studio open. I'm not going to shut it down, edit the CMakeLists.txt, recreate my project file and reopen it.

    But this conversation is moot anyway, because we already have a CMakeLists.txt
     
  7. kkmic

    kkmic Undefined

    Joined:
    Jul 17, 2014
    Messages:
    59
    Likes Received:
    2
    Best Answers:
    0
    Yeah, you pointed out the only "major" drawback of using cmake.

    IIRC, you don't need to shut down VS, you just need to attempt to build the project from inside VS, and cmake will regenerate the VS project, and VS will detect this and will show the correct files in the tree.

    Anyways, is a bit odd, I'll give you that.

    I'm sure JonnyH will be happy/able to maintain the CMakeLists.txt file (yes, I know it is there, I've been using it :) ), so that means it's only a matter of keeping the cmake file list up to date when the adding/removing the files from the project.


    I think I got a bit carried away with my ideas and maybe I had been a little bit out of line, sorry about that.


    What I really wanted to say is that you need to take care to keep the CMkeLists.txt up to date (just the project files list).

    Again, my apologies if I had had been a bit ... weird in my posts.
     
  8. pmprog

    pmprog Well-Known Member Official Developer Administrator

    Joined:
    Jul 8, 2014
    Messages:
    175
    Likes Received:
    12
    Best Answers:
    0
    I'm sure somebody else will. I've added the recent forms files into it to, might just forget sometimes.

    Don't worry, we will. If somebody forgets to update it, I'm sure somebody will add the file that was forgotten and do a pull request

    No worries
     

Share This Page