MSVC#
Lowlevel MSVC Tests
Executable#
1// MSVC specialized Toolchain
2Toolchain_msvc msvc;
3
4// MSVC specialized targets
5// Creates `Simple.exe`
6ExecutableTarget_msvc exetarget("Simple", msvc, "");
7exetarget.GlobSources("src");
8exetarget.AddIncludeDir("include", true);
9exetarget.Build();
10
11// Build
12tf::Executor executor;
13executor.run(exetarget.GetTaskflow());
14executor.wait_for_all();
StaticLib#
1// MSVC specialized Toolchain
2Toolchain_msvc msvc;
3
4// MSVC specialized targets
5// Creates `librandom.lib`
6StaticTarget_msvc statictarget("librandom", msvc, "");
7statictarget.AddSource("src/random.cpp");
8statictarget.AddIncludeDir("include", true);
9statictarget.Build();
10
11// MSVC specialized targets
12// Creates `Simple.exe`
13ExecutableTarget_msvc exetarget("Simple", msvc, "");
14exetarget.AddSource("src/main.cpp");
15exetarget.AddIncludeDir("include", true);
16exetarget.AddLibDep(statictarget);
17exetarget.Build();
18
19// Build
20tf::Executor executor;
21tf::Taskflow taskflow;
22
23// Setup your dependencies explicitly
24// Here statictarget needs to be built before exetarget
25auto statictargetTask = taskflow.composed_of(statictarget.GetTaskflow());
26auto exetargetTask = taskflow.composed_of(exetarget.GetTaskflow());
27exetargetTask.succeed(statictargetTask);
28
29executor.run(taskflow);
30executor.wait_for_all();
DynamicLib#
1// MSVC specialized Toolchain
2Toolchain_msvc msvc;
3
4// MSVC specialized targets
5// Creates `librandom.lib` and `librandom.lib.dll`
6DynamicTarget_msvc dynamictarget("librandom", msvc, "");
7dynamictarget.AddSource("src/random.cpp");
8dynamictarget.AddIncludeDir("include", true);
9dynamictarget.Build();
10
11// MSVC specialized target
12// Creates `Simple.exe` which uses the above dynamic library
13ExecutableTarget_msvc exetarget("Simple", msvc, "");
14exetarget.AddSource("src/main.cpp");
15exetarget.AddIncludeDir("include", true);
16exetarget.AddLibDep(dynamictarget);
17exetarget.Build();
18
19// Build
20tf::Executor executor;
21tf::Taskflow taskflow;
22
23// Setup your dependencies explicitly
24// Here dynamictarget needs to be built before exetarget
25auto dynamictargetTask = taskflow.composed_of(dynamictarget.GetTaskflow());
26auto exetargetTask = taskflow.composed_of(exetarget.GetTaskflow());
27exetargetTask.succeed(dynamictargetTask);
28
29executor.run(taskflow);
30executor.wait_for_all();
31
32// Now that both your targets are built, copy the dynamictarget DLL to the exetarget location
33// This is required for your exetarget to run properly
34if (exetarget.IsBuilt()) {
35 fs::copy(dynamictarget.GetDllPath(),
36 exetarget.GetTargetPath().parent_path() /
37 dynamictarget.GetDllPath().filename());
38}
Note
Our ExecutableTarget_msvc
depends on DynamicTarget_msvc
and requires the librandom.lib.dll
file to be present in the same folder location as the executable when running.
PrecompileHeader#
TODO