Skip to content

Commit 4b6aa70

Browse files
authored
Merge pull request #1 from Submitty/cmake_example
Added cmake compilation example
2 parents 26dd45b + 2f9ce9e commit 4b6aa70

File tree

7 files changed

+92
-0
lines changed

7 files changed

+92
-0
lines changed
50.4 KB
Loading
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"max_submission_size" : 1000000,
3+
"testcases" : [
4+
5+
// *************** COMPILATION *****************
6+
{
7+
"type" : "Compilation",
8+
"title" : "Compilation",
9+
//Note the multistep compilation which first
10+
//calls cmake and then make.
11+
"command" : ["cmake .", "make"],
12+
"executable_name" : "a.out",
13+
"points" : 4
14+
},
15+
16+
// *************** TEST CASES *****************
17+
{
18+
"title" : "Run cube program hw4",
19+
"command" : "./a.out",
20+
"points" : 6,
21+
"validation" :
22+
[
23+
{
24+
"method" : "myersDiffbyLinebyChar",
25+
"actual_file" : "STDOUT.txt",
26+
"description" : "Program Output",
27+
"expected_file" : "output.txt"
28+
}
29+
]
30+
}
31+
]
32+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Hello world. This was compiled using cmake.
2+
Hello! I am a simple object which was created using a .h and .cpp.
3+
These were included in the cmakelists.txt file. My name is Jan
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmake_minimum_required (VERSION 2.8)
2+
project (cmakeTest)
3+
4+
#name this project's executable.
5+
set(my_executable a.out)
6+
7+
# toggle for building a 32 bit version (for Dr. Memory)
8+
set(BUILD_32 "")
9+
#set(BUILD_32 " -m32 ")
10+
11+
# all the .cpp and .h files that make up this project
12+
add_executable(${my_executable}
13+
main.cpp
14+
SimpleObject.cpp
15+
SimpleObject.h
16+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "SimpleObject.h"
2+
#include <iostream>
3+
#include <string>
4+
5+
SimpleObject::SimpleObject(std::string name)
6+
{
7+
myName = name;
8+
}
9+
10+
std::string SimpleObject::getMyName()
11+
{
12+
return myName;
13+
}
14+
15+
void SimpleObject::sayHello()
16+
{
17+
std::cout << "Hello! I am a simple object which was created using a .h and .cpp." << std::endl << "These were included in the cmakelists.txt file. My name is " << getMyName() << std::endl;
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// in myclass.h
2+
#include <string>
3+
class SimpleObject
4+
{
5+
public:
6+
SimpleObject(std::string name);
7+
std::string getMyName();
8+
void sayHello();
9+
private:
10+
std::string myName;
11+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//The following is a very simple program for use with the cmake compilation example.
2+
//It simply prints one line, creates an instance of the SimpleObject Class, and then
3+
//invokes the sayHello method of that class.
4+
#include <iostream>
5+
#include "SimpleObject.h"
6+
int main()
7+
{
8+
std::cout << "Hello world. This was compiled using cmake." << std::endl;
9+
SimpleObject simple("Jan");
10+
simple.sayHello();
11+
return 0;
12+
}

0 commit comments

Comments
 (0)