File tree Expand file tree Collapse file tree 4 files changed +53
-8
lines changed Expand file tree Collapse file tree 4 files changed +53
-8
lines changed Original file line number Diff line number Diff line change 1
1
add_subdirectory (LibTemplateCMake)
2
2
add_subdirectory (LibHeaderOnlyTemplateCMake)
3
3
add_subdirectory (ExeExample)
4
+ add_subdirectory (ExeExampleHeaderOnly)
Original file line number Diff line number Diff line change 1
- #include " LibTemplateCMake/LibTemplateCMake.h"
1
+ #include < LibTemplateCMake/LibTemplateCMake.h>
2
2
3
3
#include < cstdlib>
4
4
#include < cmath>
5
5
#include < iostream>
6
6
7
7
int main ()
8
8
{
9
- std::cout << " Example executable" << std::endl;
9
+ std::cout << " Executable example using the library!" << std::endl;
10
+
10
11
LibTemplateCMake::summationClass sumClass;
11
12
LibTemplateCMake::differenceClass diffClass;
12
13
13
14
double tol = 1e-10 ;
14
15
double op1 = 15.0 ;
15
16
double op2 = 10.0 ;
16
17
17
- if ( fabs (sumClass.doSomething (op1,op2)- (op1+ op2)) > tol )
18
+ if ( fabs (sumClass.doSomething (op1, op2) - (op1 + op2)) > tol )
18
19
{
19
20
std::cerr << " [ERR] sumClass.doSomething(" << op1 << " ," << op2
20
- << " ) is equal to " << sumClass.doSomething (op1,op2)
21
- << " instead of the expected " << op1+ op2 << std::endl;
21
+ << " ) is equal to " << sumClass.doSomething (op1, op2)
22
+ << " instead of the expected " << op1 + op2 << std::endl;
22
23
return EXIT_FAILURE;
23
24
}
24
25
25
- if ( fabs (diffClass.doSomething (op1,op2)- (op1- op2)) > tol )
26
+ if ( fabs (diffClass.doSomething (op1, op2) - (op1 - op2)) > tol )
26
27
{
27
28
std::cerr << " [ERR] sumClass.doSomething(" << op1 << " ," << op2
28
- << " ) is equal to " << diffClass.doSomething (op1,op2)
29
- << " instead of the expected " << op1- op2 << std::endl;
29
+ << " ) is equal to " << diffClass.doSomething (op1, op2)
30
+ << " instead of the expected " << op1 - op2 << std::endl;
30
31
return EXIT_FAILURE;
31
32
}
32
33
Original file line number Diff line number Diff line change
1
+ set (EXE_TARGET_NAME ExeExampleHeaderOnly)
2
+
3
+ set (${EXE_TARGET_NAME} _SRC
4
+ main.cpp
5
+ )
6
+
7
+ add_executable (${EXE_TARGET_NAME} ${${EXE_TARGET_NAME} _SRC})
8
+
9
+ target_link_libraries (${EXE_TARGET_NAME} LibTemplateCMake::LibTemplateCMakeHeaderOnly)
10
+
11
+ install (TARGETS ${EXE_TARGET_NAME} DESTINATION bin)
Original file line number Diff line number Diff line change
1
+ #include < LibHeaderOnlyTemplateCMake/LibHeaderOnlyTemplateCMake.h>
2
+
3
+ #include < cstdlib>
4
+ #include < cmath>
5
+ #include < iostream>
6
+
7
+ int main ()
8
+ {
9
+ std::cout << " Executable example using the header-only library!" << std::endl;
10
+
11
+ double tol = 1e-10 ;
12
+ double op1 = 15.0 ;
13
+ double op2 = 10.0 ;
14
+
15
+ if ( fabs (LibTemplateCMake::sum (op1, op2) - (op1 + op2)) > tol )
16
+ {
17
+ std::cerr << " [ERR] sumClass.doSomething(" << op1 << " ," << op2
18
+ << " ) is equal to " << LibTemplateCMake::sum (op1, op2)
19
+ << " instead of the expected " << op1 + op2 << std::endl;
20
+ return EXIT_FAILURE;
21
+ }
22
+
23
+ if ( fabs (LibTemplateCMake::sub (op1, op2) - (op1 - op2)) > tol )
24
+ {
25
+ std::cerr << " [ERR] sumClass.doSomething(" << op1 << " ," << op2
26
+ << " ) is equal to " << LibTemplateCMake::sub (op1, op2)
27
+ << " instead of the expected " << op1 - op2 << std::endl;
28
+ return EXIT_FAILURE;
29
+ }
30
+
31
+ return EXIT_SUCCESS;
32
+ }
You can’t perform that action at this time.
0 commit comments