Skip to content

Commit 09c1c2b

Browse files
committed
[CMAKE] Enable multithreaded compilation for VC6 builds
Created a custom cmake toolchain file for using the vc6 compiler with the ninja generator Switching from nmake to multithreaded ninja reduces compile times by an order of magnitude Does not seem to work with program database (pdb) file generation enabled
1 parent 61cbc6f commit 09c1c2b

File tree

3 files changed

+184
-54
lines changed

3 files changed

+184
-54
lines changed

CMakePresets.json

Lines changed: 82 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
{
22
"version": 6,
3-
"cmakeMinimumRequired": {
3+
"cmakeMinimumRequired":
4+
{
45
"major": 3,
56
"minor": 25,
67
"patch": 0
78
},
8-
"configurePresets": [
9+
"configurePresets":
10+
[
911
{
1012
"name": "vc6",
1113
"displayName": "Windows 32bit VC6 Release",
12-
"generator": "NMake Makefiles",
14+
"generator": "Ninja",
1315
"hidden": false,
1416
"binaryDir": "${sourceDir}/build/${presetName}",
15-
"cacheVariables": {
17+
"toolchainFile": "${sourceDir}/cmake/vc6toolchain.cmake",
18+
"cacheVariables":
19+
{
20+
"CMAKE_VERBOSE_MAKEFILE": "TRUE",
1621
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1722
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
18-
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:ProgramDatabase>",
23+
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
1924
"CMAKE_BUILD_TYPE": "Release",
2025
"RTS_FLAGS": "/W3"
2126
},
22-
"vendor": {
23-
"jetbrains.com/clion": {
27+
"vendor":
28+
{
29+
"jetbrains.com/clion":
30+
{
2431
"toolchain": "Visual Studio 6"
2532
}
2633
}
@@ -30,15 +37,17 @@
3037
"displayName": "Windows 32bit VC6 Profile",
3138
"hidden": false,
3239
"inherits": "vc6",
33-
"cacheVariables": {
40+
"cacheVariables":
41+
{
3442
"RTS_BUILD_OPTION_PROFILE": "ON"
3543
}
3644
},
3745
{
3846
"name": "vc6-internal",
3947
"displayName": "Windows 32bit VC6 Internal",
4048
"inherits": "vc6",
41-
"cacheVariables": {
49+
"cacheVariables":
50+
{
4251
"RTS_BUILD_OPTION_INTERNAL": "ON"
4352
}
4453
},
@@ -47,7 +56,8 @@
4756
"displayName": "Windows 32bit VC6 Debug",
4857
"hidden": false,
4958
"inherits": "vc6",
50-
"cacheVariables": {
59+
"cacheVariables":
60+
{
5161
"CMAKE_BUILD_TYPE": "Debug",
5262
"RTS_BUILD_OPTION_DEBUG": "ON"
5363
}
@@ -58,7 +68,8 @@
5868
"generator": "Ninja Multi-Config",
5969
"hidden": true,
6070
"binaryDir": "${sourceDir}/build/${presetName}",
61-
"cacheVariables": {
71+
"cacheVariables":
72+
{
6273
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
6374
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
6475
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
@@ -70,7 +81,8 @@
7081
"generator": "Ninja Multi-Config",
7182
"hidden": true,
7283
"binaryDir": "${sourceDir}/build/${presetName}",
73-
"cacheVariables": {
84+
"cacheVariables":
85+
{
7486
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
7587
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
7688
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
@@ -82,15 +94,19 @@
8294
"inherits": "default",
8395
"hidden": false,
8496
"displayName": "Windows 32bit Release",
85-
"architecture": {
97+
"architecture":
98+
{
8699
"value": "Win32",
87100
"strategy": "external"
88101
},
89-
"cacheVariables": {
102+
"cacheVariables":
103+
{
90104
"RTS_FLAGS": "/W3"
91105
},
92-
"vendor": {
93-
"jetbrains.com/clion": {
106+
"vendor":
107+
{
108+
"jetbrains.com/clion":
109+
{
94110
"toolchain": "Visual Studio"
95111
}
96112
}
@@ -99,23 +115,26 @@
99115
"name": "win32-profile",
100116
"inherits": "win32",
101117
"displayName": "Windows 32bit Profile",
102-
"cacheVariables": {
118+
"cacheVariables":
119+
{
103120
"RTS_BUILD_OPTION_PROFILE": "ON"
104121
}
105122
},
106123
{
107124
"name": "win32-internal",
108125
"inherits": "win32",
109126
"displayName": "Windows 32bit Internal",
110-
"cacheVariables": {
127+
"cacheVariables":
128+
{
111129
"RTS_BUILD_OPTION_INTERNAL": "ON"
112130
}
113131
},
114132
{
115133
"name": "win32-debug",
116134
"inherits": "win32",
117135
"displayName": "Windows 32bit Debug",
118-
"cacheVariables": {
136+
"cacheVariables":
137+
{
119138
"RTS_BUILD_OPTION_DEBUG": "ON"
120139
}
121140
},
@@ -124,15 +143,19 @@
124143
"inherits": "default-vcpkg",
125144
"hidden": false,
126145
"displayName": "Windows 32bit VCPKG Release",
127-
"architecture": {
146+
"architecture":
147+
{
128148
"value": "Win32",
129149
"strategy": "external"
130150
},
131-
"cacheVariables": {
151+
"cacheVariables":
152+
{
132153
"RTS_FLAGS": "/W3"
133154
},
134-
"vendor": {
135-
"jetbrains.com/clion": {
155+
"vendor":
156+
{
157+
"jetbrains.com/clion":
158+
{
136159
"toolchain": "Visual Studio"
137160
}
138161
}
@@ -141,23 +164,26 @@
141164
"name": "win32-vcpkg-profile",
142165
"inherits": "win32-vcpkg",
143166
"displayName": "Windows 32bit VCPKG Profile",
144-
"cacheVariables": {
167+
"cacheVariables":
168+
{
145169
"RTS_BUILD_OPTION_PROFILE": "ON"
146170
}
147171
},
148172
{
149173
"name": "win32-vcpkg-internal",
150174
"inherits": "win32-vcpkg",
151175
"displayName": "Windows 32bit VCPKG Internal",
152-
"cacheVariables": {
176+
"cacheVariables":
177+
{
153178
"RTS_BUILD_OPTION_INTERNAL": "ON"
154179
}
155180
},
156181
{
157182
"name": "win32-vcpkg-debug",
158183
"inherits": "win32-vcpkg",
159184
"displayName": "Windows 32bit VCPKG Debug",
160-
"cacheVariables": {
185+
"cacheVariables":
186+
{
161187
"RTS_BUILD_OPTION_DEBUG": "ON"
162188
}
163189
},
@@ -168,7 +194,8 @@
168194
"displayName": "Unix 32bit VCPKG Release"
169195
}
170196
],
171-
"buildPresets": [
197+
"buildPresets":
198+
[
172199
{
173200
"name": "vc6",
174201
"configurePreset": "vc6",
@@ -257,10 +284,12 @@
257284
"configuration": "Release"
258285
}
259286
],
260-
"workflowPresets": [
287+
"workflowPresets":
288+
[
261289
{
262290
"name": "vc6",
263-
"steps": [
291+
"steps":
292+
[
264293
{
265294
"type": "configure",
266295
"name": "vc6"
@@ -273,7 +302,8 @@
273302
},
274303
{
275304
"name": "vc6-debug",
276-
"steps": [
305+
"steps":
306+
[
277307
{
278308
"type": "configure",
279309
"name": "vc6-debug"
@@ -286,7 +316,8 @@
286316
},
287317
{
288318
"name": "vc6-internal",
289-
"steps": [
319+
"steps":
320+
[
290321
{
291322
"type": "configure",
292323
"name": "vc6-internal"
@@ -299,7 +330,8 @@
299330
},
300331
{
301332
"name": "vc6-profile",
302-
"steps": [
333+
"steps":
334+
[
303335
{
304336
"type": "configure",
305337
"name": "vc6-profile"
@@ -312,7 +344,8 @@
312344
},
313345
{
314346
"name": "win32",
315-
"steps": [
347+
"steps":
348+
[
316349
{
317350
"type": "configure",
318351
"name": "win32"
@@ -325,7 +358,8 @@
325358
},
326359
{
327360
"name": "win32-internal",
328-
"steps": [
361+
"steps":
362+
[
329363
{
330364
"type": "configure",
331365
"name": "win32-internal"
@@ -338,7 +372,8 @@
338372
},
339373
{
340374
"name": "win32-profile",
341-
"steps": [
375+
"steps":
376+
[
342377
{
343378
"type": "configure",
344379
"name": "win32-profile"
@@ -351,7 +386,8 @@
351386
},
352387
{
353388
"name": "win32-debug",
354-
"steps": [
389+
"steps":
390+
[
355391
{
356392
"type": "configure",
357393
"name": "win32-debug"
@@ -364,7 +400,8 @@
364400
},
365401
{
366402
"name": "win32-vcpkg",
367-
"steps": [
403+
"steps":
404+
[
368405
{
369406
"type": "configure",
370407
"name": "win32-vcpkg"
@@ -377,7 +414,8 @@
377414
},
378415
{
379416
"name": "win32-vcpkg-internal",
380-
"steps": [
417+
"steps":
418+
[
381419
{
382420
"type": "configure",
383421
"name": "win32-vcpkg-internal"
@@ -390,7 +428,8 @@
390428
},
391429
{
392430
"name": "win32-vcpkg-profile",
393-
"steps": [
431+
"steps":
432+
[
394433
{
395434
"type": "configure",
396435
"name": "win32-vcpkg-profile"
@@ -403,7 +442,8 @@
403442
},
404443
{
405444
"name": "win32-vcpkg-debug",
406-
"steps": [
445+
"steps":
446+
[
407447
{
408448
"type": "configure",
409449
"name": "win32-vcpkg-debug"
@@ -416,7 +456,8 @@
416456
},
417457
{
418458
"name": "unix",
419-
"steps": [
459+
"steps":
460+
[
420461
{
421462
"type": "configure",
422463
"name": "unix"

cmake/compilers.cmake

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ else()
1515
set(IS_VS6_BUILD FALSE)
1616
endif()
1717

18-
# Make release builds have debug information too.
19-
if(MSVC)
20-
# Create PDB for Release as long as debug info was generated during compile.
21-
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
22-
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
23-
else()
24-
# We go a bit wild here and assume any other compiler we are going to use supports -g for debug info.
25-
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
26-
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
27-
endif()
18+
if (NOT IS_VS6_BUILD)
19+
# Make release builds have debug information too.
20+
if(MSVC)
21+
# Create PDB for Release as long as debug info was generated during compile.
22+
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
23+
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
24+
else()
25+
# We go a bit wild here and assume any other compiler we are going to use supports -g for debug info.
26+
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -g")
27+
string(APPEND CMAKE_C_FLAGS_RELEASE " -g")
28+
endif()
2829

29-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
30-
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures only ISO features are used
30+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
31+
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures only ISO features are used
3132

32-
if (NOT IS_VS6_BUILD)
3333
if (MSVC)
3434
# Multithreaded build.
3535
add_compile_options(/MP)

0 commit comments

Comments
 (0)