making a custom template

Hello again! I've been wanting to make a customized project template so that I can start with a project easily that has a bunch of stuff that I reuse from game to a my system for scene switching, a main menu with some default buttons, etc. I'm not sure I've approached it in the best way, but I've had some success by creating my own init.bat file that calls a customized .r script which uses a different alternative template folder in which I've added my ini files, some .h and .cpp files for my classes, and default sounds and images for menu buttons, etc. It works well and makes starting up a new project a lot quicker for me since I like to use these things over and over. The only thing I can't figure out is that even though my .h files are included in the src folder and everything compiles just fine, I notice that in Visual Studio, only the .cpp files are part of the project. This doesn't really cause any problems since the .h files are there in the folder, but it would be nice if they are a part of the project. It is easy enough to use "Add Existing" to pull them in so I see them in my src folder but if I can get them in automatically it would be ideal. I admit I don't totally understand how the visual studio project is being created in the init.r and setup.r files, but I didn't see anything obvious that was filtering out my .h files.

Any suggestion for how I can get those .h files to show as part of the project?



  • Hi,

    It's actually a nice timing as I've been working on init lately to add support for extensions and I was wondering how to support customized templates as well. Right now there's only two extensions added (Scroll and Dear ImGui), but I plan adding more. You can test it on this branch if you're curious:

    That being said, in order to display the .h files you simply need to add an includedirs directive inside the premake4.lua file that points to the base folder containing your headers as we use premake4 to generate all the solutions.
    You should already see other includedirs directive pointing at orx's header in that file.

  • Nice, thanks as always for the help. I may check out the extensions you are working on at some point, sounds useful. I'll try the includedirs directive and see if I can get my solutions looking more complete.

    thanks again!

  • I took a quick stab at adding the includedirs line, but I'm not sure that it changed anything. It is probable that I haven't explained what I'm expecting very well. Here is what I've added. I tried it also without the "./". My kudotemplate folder is at the same level as the .lua file (and same as the main template folder). Have I understood the correct place to add this?

    So the resulting project doesn't show my .h files in the /src folder. I have both my .h and .cpp files all together in the /src folder of the project, but the project only shows the .cpp files. The .h files are indeed copied into that folder, so the project compiles just fine, but I'd like to see them in the project automatically without having to manually add them in with each new project. It isn't too much hassle, but would be nice to know what controls whether they appear in the project or not. Thanks for any suggestion you can offer.

  • Ah right, I forgot to mention the files directive to have them displayed in the solution explorer.
    The includedirs is only used to add include paths.
    In your case, you'll want to add kudotemplate/**.h to the list in files and re-run premake4.

  • I was doing a few things wrong...first, I edited the wrong lua file...I found the correct one in my build folder in the custom template folder. Then, I noticed the default action in that file was set for VS 2019. I'm still using 2017, so I changed the default action to 2017 and it works for me now! Thanks!

  • My pleasure, glad you got it working.

Sign In or Register to comment.