1
00:00:05,390 --> 00:00:10,190
In this video, we'll go over the steps necessary to create our own custom project template.

2
00:00:10,790 --> 00:00:15,470
The idea here is that we can create our own project templates, and when we create our projects, we

3
00:00:15,470 --> 00:00:17,630
can use this template as the starting point.

4
00:00:17,900 --> 00:00:21,590
That way we'll have a proper main CPP file.

5
00:00:21,620 --> 00:00:23,370
We'll have all our switches set.

6
00:00:23,390 --> 00:00:25,000
We'll have our environment set.

7
00:00:25,010 --> 00:00:26,160
All right, so let's get started.

8
00:00:26,180 --> 00:00:28,670
First thing you need to do is open up a workspace.

9
00:00:28,670 --> 00:00:32,119
I've got a workspace already open, already created, I should say.

10
00:00:32,119 --> 00:00:32,990
I'm going to open it now.

11
00:00:32,990 --> 00:00:34,460
I'm going to say open workspace.

12
00:00:34,460 --> 00:00:38,570
If you don't have a workspace at all, you could just say file new workspace.

13
00:00:38,660 --> 00:00:40,550
So I'll open the workspace that I've got.

14
00:00:40,550 --> 00:00:43,590
It's on my desktop and it's called CP workspace.

15
00:00:43,590 --> 00:00:44,630
So I'll open that.

16
00:00:46,250 --> 00:00:48,710
And the first thing you want to do is you want to add a project.

17
00:00:48,710 --> 00:00:53,810
So you want to right click on your workspace and say New, new project.

18
00:00:55,190 --> 00:00:59,180
Now here you've got the new project Wizard and you've got different examples.

19
00:00:59,180 --> 00:01:04,129
You can create gooey applications, console applications, you can have user templates and so forth.

20
00:01:04,129 --> 00:01:12,050
What we want to do is we want to use the simple executable plus plus template that comes with code light,

21
00:01:12,470 --> 00:01:14,030
and we want to tweak that our own way.

22
00:01:14,030 --> 00:01:18,320
And then what we want to do is we want to create our own template and here that we can choose and we

23
00:01:18,320 --> 00:01:22,310
could put it in console or we can put it here in user templates, we could put it wherever we'd like.

24
00:01:22,700 --> 00:01:22,910
Okay.

25
00:01:22,940 --> 00:01:25,070
But before we do that, we need to create a project.

26
00:01:25,070 --> 00:01:25,850
So let's do that.

27
00:01:25,850 --> 00:01:32,510
I'm going to select console and let's use the G plus plus simple executable console template press next.

28
00:01:34,040 --> 00:01:34,850
The project name.

29
00:01:34,850 --> 00:01:35,910
It doesn't really matter.

30
00:01:35,930 --> 00:01:42,290
I'll just say sample since we're going to save it as a template anyway and I'll select next.

31
00:01:43,100 --> 00:01:45,590
We want to make sure our compilers are set up correctly.

32
00:01:49,520 --> 00:01:53,660
Here I'm using min gw and the GDB debugger select finish.

33
00:01:54,870 --> 00:01:56,940
And that creates our project.

34
00:01:56,940 --> 00:02:01,770
You can see here's the source file and here's the CP file, which is really C code and not C++ code.

35
00:02:01,770 --> 00:02:03,120
But we'll fix all this in a minute.

36
00:02:03,210 --> 00:02:10,080
So first thing we want to do is we want to get rid of this and let's write a simple C++ program, same

37
00:02:10,080 --> 00:02:11,340
one we've been writing all along.

38
00:02:11,340 --> 00:02:18,180
So we'll say include IO stream, we'll include IO streams since we're going to probably use it in most

39
00:02:18,180 --> 00:02:22,350
of the projects that we write, then we have our main function.

40
00:02:24,490 --> 00:02:30,520
And again it's int main open closed friends and then an open curly which will be automatically closed

41
00:02:30,520 --> 00:02:30,940
by code.

42
00:02:30,940 --> 00:02:40,600
Like here we can indent in by just pressing tab and we could say STD two colons see out and then the

43
00:02:40,600 --> 00:02:47,770
insertion operator followed by the string hello world and you can type anything you like here for hello

44
00:02:47,770 --> 00:02:52,180
world and we'll do also an STD two colons and del.

45
00:02:52,420 --> 00:02:58,990
This prints a new line that way when we display hello world the cursor will go to the next line on the

46
00:02:58,990 --> 00:03:02,330
console and then finally we'll just return zero like we always do.

47
00:03:02,350 --> 00:03:03,040
That's it.

48
00:03:03,430 --> 00:03:06,820
I'm going to save this so that press control is here.

49
00:03:06,820 --> 00:03:08,350
So I've just done that and saved it.

50
00:03:09,250 --> 00:03:11,130
Now we'll set some compiler settings.

51
00:03:11,170 --> 00:03:14,290
We'll do this the one time, then we'll save it as a project template.

52
00:03:14,470 --> 00:03:21,160
So let's go to the sample project, the actual project name, and we'll right click go down to settings.

53
00:03:22,750 --> 00:03:27,190
Global settings and we want to make sure we've got those two compiler options set.

54
00:03:27,190 --> 00:03:29,620
So we're going to right click on those three little dots here on the button.

55
00:03:29,620 --> 00:03:34,990
You want to select that button and click, and we want to make sure that we've got our all warnings

56
00:03:34,990 --> 00:03:38,890
enabled on and our C++ 14 standard on.

57
00:03:39,850 --> 00:03:40,240
Press.

58
00:03:40,240 --> 00:03:40,810
Okay.

59
00:03:42,410 --> 00:03:50,060
Then you want to come to us as code completion and select that and select enable C++ 14 Standard Apply.

60
00:03:51,660 --> 00:03:52,560
And that's it.

61
00:03:52,770 --> 00:03:59,850
Now, what we can do is we can come to the project again, right click and say Save as template.

62
00:04:00,480 --> 00:04:01,620
So I'll select that.

63
00:04:02,610 --> 00:04:04,640
And what's the project name?

64
00:04:04,650 --> 00:04:05,940
This could be anything we want.

65
00:04:05,970 --> 00:04:13,770
We could just say frank template or template for course or any name you like rather than that.

66
00:04:13,770 --> 00:04:18,810
I'm just going to say Frank, let's see G plus.

67
00:04:18,810 --> 00:04:19,470
Plus.

68
00:04:20,760 --> 00:04:21,750
Console.

69
00:04:25,170 --> 00:04:25,680
Template.

70
00:04:25,680 --> 00:04:31,500
I think it's pretty picky about spaces, so I'm just going to use those dashes and it is a console application.

71
00:04:32,130 --> 00:04:34,980
If you leave it as console, it'll be in the console group.

72
00:04:35,100 --> 00:04:38,130
I'm actually going to change that to user template.

73
00:04:39,460 --> 00:04:41,410
And then you can give any description you want.

74
00:04:43,380 --> 00:04:45,390
I'll just say Frank's console template.

75
00:04:48,210 --> 00:04:48,780
That's it.

76
00:04:48,810 --> 00:04:49,290
I'll select.

77
00:04:49,290 --> 00:04:49,800
Okay.

78
00:04:50,400 --> 00:04:52,530
And now we've got a new template that's stored.

79
00:04:52,530 --> 00:04:58,320
So if I go back to my workspace and I want to create a new project now, we close all this up, I'm

80
00:04:58,320 --> 00:05:01,260
going to right click and say New project.

81
00:05:02,160 --> 00:05:07,080
And now you can go down to your templates and go down to your user templates right here.

82
00:05:07,650 --> 00:05:10,560
And you should see that one we just created right here.

83
00:05:11,160 --> 00:05:12,720
So we can just select that.

84
00:05:13,140 --> 00:05:22,350
Next, I'll just say project one, select next, keep the defaults for the compilers and finish.

85
00:05:23,220 --> 00:05:29,970
At this point you can double click here to make that project, the active project and we'll look at

86
00:05:29,970 --> 00:05:30,870
the main CP.

87
00:05:30,900 --> 00:05:33,570
You can see it's the main CP that we just typed.

88
00:05:34,320 --> 00:05:39,720
Also, if you right click on the project and you go down to the settings, you can see a code completion

89
00:05:39,720 --> 00:05:44,790
is C++ 14 and the global settings have the appropriate compiler flags that we need.

90
00:05:45,730 --> 00:05:46,540
That's it.

91
00:05:46,600 --> 00:05:48,010
We'll test this real quick.

92
00:05:49,250 --> 00:05:51,860
That's run, build and execute.

93
00:05:52,880 --> 00:05:54,050
And Hello World.

94
00:05:54,320 --> 00:05:54,770
That's it.

95
00:05:54,770 --> 00:05:56,590
So now you've got a project, you're all set up.

96
00:05:56,600 --> 00:05:58,560
You can create as many of these as you like.

97
00:05:58,580 --> 00:06:00,440
Tweak the settings as far as you like.

98
00:06:00,830 --> 00:06:04,280
It's really up to you to decide what you want to do with the project templates.

99
00:06:04,280 --> 00:06:06,650
But for this course include IO stream.

100
00:06:06,650 --> 00:06:07,810
Give yourself a main.

101
00:06:07,820 --> 00:06:11,450
You may or may not want this line right here since you know you're probably going to get rid of it anyway

102
00:06:11,450 --> 00:06:12,800
when we start writing other code.

103
00:06:12,800 --> 00:06:16,040
But at a minimum do something like that.

104
00:06:16,490 --> 00:06:19,220
When you create a new project, you'll be ready to start coding.

