Skip to content

Commit 6ddaa39

Browse files
authored
build: adjust build rules for Windows (#35)
Because we do not use `cl` from MSVC or `clang-cl`, we lose some of the necessary target macros. This manually constructs the macro definitions to allow building the C/C++ code on Windows. This is required in addition to #34 to build the gfm branch.
1 parent 7fc530e commit 6ddaa39

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Package.swift

+20-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33

44
import PackageDescription
55

6+
#if os(Windows)
7+
#if arch(i386) || arch(x86_64)
8+
let cSettings: [CSetting] = [
9+
.define("_X86_", .when(platforms: [.windows])),
10+
]
11+
#elseif arch(arm) || arch(arm64)
12+
let cSettings: [CSetting] = [
13+
.define("_ARM_", .when(platforms: [.windows])),
14+
]
15+
#else
16+
#error("unsupported architecture")
17+
#endif
18+
#else
19+
let cSettings: [CSetting] = []
20+
#endif
21+
622
let package = Package(
723
name: "cmark-gfm",
824
products: [
@@ -30,7 +46,8 @@ let package = Package(
3046
"cmark-gfm_version.h.in",
3147
"case_fold_switch.inc",
3248
"entities.inc",
33-
]
49+
],
50+
cSettings: cSettings
3451
),
3552
.target(name: "cmark-gfm-extensions",
3653
dependencies: [
@@ -40,7 +57,8 @@ let package = Package(
4057
exclude: [
4158
"CMakeLists.txt",
4259
"ext_scanners.re",
43-
]
60+
],
61+
cSettings: cSettings
4462
),
4563
.target(name: "cmark-gfm-bin",
4664
dependencies: [

0 commit comments

Comments
 (0)