Skip to content

Commit afc0fe8

Browse files
committed
CMake: include common headers dir in include dirs
This adds the src/common directory to the include directories, so compilers will search there for headers in addition to the target source directories.
1 parent 80ed275 commit afc0fe8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+106
-81
lines changed

CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,4 @@ add_executable(pi src/TheRestOfYourLife/pi.cc ${CO
8080
add_executable(sphere_importance src/TheRestOfYourLife/sphere_importance.cc ${COMMON_ALL})
8181
add_executable(sphere_plot src/TheRestOfYourLife/sphere_plot.cc ${COMMON_ALL})
8282

83-
target_include_directories(inOneWeekend PRIVATE src)
84-
target_include_directories(theNextWeek PRIVATE src)
85-
target_include_directories(theRestOfYourLife PRIVATE src)
86-
target_include_directories(cos_cubed PRIVATE src)
87-
target_include_directories(cos_density PRIVATE src)
88-
target_include_directories(integrate_x_sq PRIVATE src)
89-
target_include_directories(pi PRIVATE src)
90-
target_include_directories(sphere_importance PRIVATE src)
91-
target_include_directories(sphere_plot PRIVATE src)
83+
include_directories(src/common)

books/RayTracingInOneWeekend.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@
319319
Now we can change our main to use this:
320320

321321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
322-
#include "common/vec3.h"
322+
#include "vec3.h"
323323

324324
#include <iostream>
325325

@@ -370,7 +370,7 @@
370370
#ifndef RAY_H
371371
#define RAY_H
372372

373-
#include "common/vec3.h"
373+
#include "vec3.h"
374374

375375
class ray {
376376
public:
@@ -742,8 +742,8 @@
742742
#ifndef SPHERE_H
743743
#define SPHERE_H
744744

745-
#include "common/vec3.h"
746745
#include "hittable.h"
746+
#include "vec3.h"
747747

748748
class sphere: public hittable {
749749
public:
@@ -1064,19 +1064,20 @@
10641064

10651065
// Common Headers
10661066

1067-
#include "common/ray.h"
1068-
#include "common/vec3.h"
1067+
#include "ray.h"
1068+
#include "vec3.h"
10691069

10701070
#endif
10711071
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1072-
[Listing [rtweekend-initial]: <kbd>[common/rtweekend.h]</kbd> The rtweekend.h common header]
1072+
[Listing [rtweekend-initial]: <kbd>[rtweekend.h]</kbd> The rtweekend.h common header]
10731073
</div>
10741074

10751075
<div class='together'>
10761076
And the new main:
10771077

10781078
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1079-
#include "common/rtweekend.h"
1079+
#include "rtweekend.h"
1080+
10801081
#include "hittable_list.h"
10811082
#include "sphere.h"
10821083

@@ -1164,7 +1165,7 @@
11641165
<div class='together'>
11651166
A simple approach to this is to use the `rand()` function that can be found in `<cstdlib>`. This
11661167
function returns a random integer in the range 0 and `RAND_MAX`. Hence we can get a real random
1167-
number as desired with the following code snippet, added to `common/rtweekend.h`:
1168+
number as desired with the following code snippet, added to `rtweekend.h`:
11681169

11691170
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
11701171
#include <cstdlib>
@@ -1219,7 +1220,7 @@
12191220
#ifndef CAMERA_H
12201221
#define CAMERA_H
12211222

1222-
#include "common/rtweekend.h"
1223+
#include "rtweekend.h"
12231224

12241225
class camera {
12251226
public:
@@ -1712,7 +1713,7 @@
17121713
#ifndef HITTABLE_H
17131714
#define HITTABLE_H
17141715

1715-
#include "common/rtweekend.h"
1716+
#include "rtweekend.h"
17161717
#include "ray.h"
17171718

17181719
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight

books/RayTracingTheNextWeek.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@
541541
passing in the interval $t_{min}$, $t_{max}$ we get:
542542

543543
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
544-
#include "common/rtweekend.h"
544+
#include "rtweekend.h"
545545

546546
class aabb {
547547
public:
@@ -876,7 +876,7 @@
876876
being able to make any color a texture is great.
877877

878878
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
879-
#include "common/rtweekend.h"
879+
#include "rtweekend.h"
880880

881881
class texture {
882882
public:
@@ -1135,7 +1135,7 @@
11351135
colors:
11361136

11371137
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1138-
#include "common/perlin.h"
1138+
#include "perlin.h"
11391139

11401140
class noise_texture : public texture {
11411141
public:
@@ -1599,7 +1599,7 @@
15991599
RGBs that each range 0..255 for black to fully-on.
16001600

16011601
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1602-
#include "common/texture.h"
1602+
#include "texture.h"
16031603

16041604
class image_texture : public texture {
16051605
public:
@@ -1640,10 +1640,10 @@
16401640

16411641
<div class='together'>
16421642
The representation of a packed array in that order is pretty standard. Thankfully, the `stb_image`
1643-
package makes that super simple -- just include the header `common/rtw_stb_image.h` in `main.h`:
1643+
package makes that super simple -- just include the header `rtw_stb_image.h` in `main.h`:
16441644

16451645
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1646-
#include "common/rtw_stb_image.h"
1646+
#include "rtw_stb_image.h"
16471647
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16481648
[Listing [incl-stb-img]: Including the STB image package]
16491649
</div>

books/RayTracingTheRestOfYourLife.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
centered at the origin:
6767

6868
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
69-
#include "common/rtweekend.h"
69+
#include "rtweekend.h"
7070

7171
#include <iostream>
7272
#include <iomanip>
@@ -96,7 +96,7 @@
9696
If we change the program to run forever and just print out a running estimate:
9797
9898
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
99-
#include "common/rtweekend.h"
99+
#include "rtweekend.h"
100100

101101
#include <iostream>
102102
#include <iomanip>
@@ -139,7 +139,7 @@
139139
because we need to know the grid. Let’s take a hundred million and try it both ways:
140140
141141
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
142-
#include "common/rtweekend.h"
142+
#include "rtweekend.h"
143143

144144
#include <iostream>
145145
#include <iomanip>
@@ -213,7 +213,7 @@
213213
This suggests a MC approach:
214214

215215
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
216-
#include "common/rtweekend.h"
216+
#include "rtweekend.h"
217217

218218
#include <iostream>
219219
#include <iomanip>
@@ -1074,7 +1074,7 @@
10741074
Let’s also start generating them as random vectors:
10751075

10761076
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1077-
#include "common/rtweekend.h"
1077+
#include "rtweekend.h"
10781078

10791079
#include <iostream>
10801080
#include <math.h>
@@ -2310,7 +2310,7 @@
23102310
<< static_cast<int>(256 * clamp(b, 0.0, 0.999)) << '\n';
23112311
}
23122312
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2313-
[Listing [write-color-nan]: <kbd>[common/vec3.h]</kbd> NaN-tolerant write_color function]
2313+
[Listing [write-color-nan]: <kbd>[vec3.h]</kbd> NaN-tolerant write_color function]
23142314
</div>
23152315

23162316
<div class='together'>

src/InOneWeekend/hittable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "common/rtweekend.h"
14+
#include "rtweekend.h"
1515

1616

1717
class material;

src/InOneWeekend/hittable_list.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "common/rtweekend.h"
14+
#include "rtweekend.h"
15+
1516
#include "hittable.h"
17+
1618
#include <memory>
1719
#include <vector>
1820

src/InOneWeekend/main.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1010
//==============================================================================================
1111

12-
#include "common/rtweekend.h"
13-
#include "common/camera.h"
12+
#include "rtweekend.h"
13+
14+
#include "camera.h"
1415
#include "hittable_list.h"
1516
#include "material.h"
1617
#include "sphere.h"
18+
1719
#include <iostream>
1820

1921

src/InOneWeekend/material.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "common/rtweekend.h"
14+
#include "rtweekend.h"
1515

1616

1717
struct hit_record;

src/InOneWeekend/sphere.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "common/rtweekend.h"
14+
#include "rtweekend.h"
15+
1516
#include "hittable.h"
1617

1718

src/TheNextWeek/aarect.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// along with this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
1212
//==============================================================================================
1313

14-
#include "common/rtweekend.h"
14+
#include "rtweekend.h"
15+
1516
#include "hittable.h"
1617

1718

0 commit comments

Comments
 (0)