Skip to content

Commit 6c573b5

Browse files
authored
Added module support (#217)
* Compiles with msvc * Compiles with clang * MSVC compiles as regular headers * Try a matrix build for modules * Added module support for matrices
1 parent 33d11f6 commit 6c573b5

Some content is hidden

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

46 files changed

+5034
-696
lines changed

.github/workflows/clang.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Clang 13/14/15
1+
name: Clang 13-16
22

33
on:
44
workflow_run:
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
version: [13, 14, 15]
16+
version: [13, 14, 15, 16]
1717
built_type: [Debug, Release]
1818

1919
steps:
@@ -40,8 +40,8 @@ jobs:
4040
COMMAND cmake
4141
-S .
4242
-B build
43-
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
4443
-G Ninja
44+
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
4545
-D CMAKE_MAKE_PROGRAM=/usr/bin/ninja
4646
RESULT_VARIABLE result
4747
)
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Clang 17-18
2+
3+
on:
4+
workflow_run:
5+
workflows: [Generate single-include header]
6+
types:
7+
- completed
8+
9+
jobs:
10+
clang:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
version: [17, 18]
17+
modules: [false, true]
18+
built_type: [Debug, Release]
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
submodules: true # recursive
24+
25+
- name: Install Ninja
26+
run: /usr/bin/ninja --version || sudo apt-get install ninja-build
27+
28+
- name: Install compiler
29+
run: |
30+
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
31+
sudo apt-get install clang-${{ matrix.version }} clang++-${{ matrix.version }} llvm-${{ matrix.version }}-dev libstdc++6 libstdc++-13-dev
32+
33+
- name: Configure
34+
shell: cmake -P {0}
35+
run: |
36+
set(ENV{CC} "/usr/bin/clang-${{ matrix.version }}")
37+
set(ENV{CXX} "/usr/bin/clang++-${{ matrix.version }}")
38+
39+
execute_process(
40+
COMMAND cmake
41+
-S .
42+
-B build
43+
-G Ninja
44+
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
45+
-D ECS_COMPILE_AS_MODULE=${{ matrix.modules }}
46+
-D CMAKE_MAKE_PROGRAM=/usr/bin/ninja
47+
RESULT_VARIABLE result
48+
)
49+
if (NOT result EQUAL 0)
50+
message(FATAL_ERROR "Bad exit status")
51+
endif()
52+
53+
54+
- name: Build
55+
shell: cmake -P {0}
56+
run: |
57+
set(ENV{NINJA_STATUS} "[%f/%t %e sec] ")
58+
59+
execute_process(
60+
COMMAND cmake --build build
61+
RESULT_VARIABLE result
62+
)
63+
if (NOT result EQUAL 0)
64+
message(FATAL_ERROR "CMake build failed")
65+
endif()
66+
67+
68+
- name: Run tests
69+
shell: cmake -P {0}
70+
run: |
71+
include(ProcessorCount)
72+
ProcessorCount(N)
73+
74+
execute_process(
75+
COMMAND ctest --output-on-failure -j ${N}
76+
WORKING_DIRECTORY build
77+
RESULT_VARIABLE result
78+
)
79+
if (NOT result EQUAL 0)
80+
message(FATAL_ERROR "Running tests failed!")
81+
endif()

.github/workflows/gcc.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: GCC 11/12/13
22

3-
on:
4-
workflow_run:
5-
workflows: [Generate single-include header]
6-
types:
7-
- completed
3+
#on:
4+
# workflow_run:
5+
# workflows: [Generate single-include header]
6+
# types:
7+
# - completed
88

99
jobs:
1010
gcc:

.github/workflows/msvc.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ jobs:
1212
runs-on: windows-2022
1313

1414
strategy:
15-
fail-fast: false
15+
fail-fast: true
1616
matrix:
1717
version: [14.3] # 2019(14.2), 2022(14.3)
18+
modules: [false, true]
1819
built_type: [Debug, Release]
1920

20-
2121
steps:
2222
- uses: actions/checkout@v3
2323
with:
@@ -45,8 +45,9 @@ jobs:
4545
COMMAND cmake
4646
-S .
4747
-B build
48-
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
4948
-G Ninja
49+
-D CMAKE_BUILD_TYPE=${{ matrix.build_type }}
50+
-D ECS_COMPILE_AS_MODULE=${{ matrix.modules }}
5051
RESULT_VARIABLE result
5152
)
5253
if (NOT result EQUAL 0)

CMakeLists.txt

+24-15
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,34 @@
22

33
project (ecs CXX)
44

5-
#add_custom_command(OUTPUT ecs_sh.h
6-
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ecs/
7-
# COMMAND powershell.exe -File make_single_header.ps1
8-
# COMMENT "Generating single-include header"
9-
#)
10-
11-
# creates a library 'ecs' which is an interface (header files only)
12-
add_library(ecs INTERFACE)
13-
14-
install(
15-
DIRECTORY include/ecs
16-
DESTINATION include
17-
)
5+
set(CMAKE_CXX_STANDARD 23)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
187

198
# Set up some options
209
set(ECS_STANDALONE_PROJECT OFF)
10+
set(ECS_COMPILE_AS_MODULE ON CACHE BOOL "Compile 'ecs' to a module")
2111
set(ECS_ENABLE_CONTRACTS ON CACHE BOOL "Use contracts internally to verify state")
2212
set(ECS_ENABLE_CONTRACTS_AUDIT OFF CACHE BOOL "Enable expensive contracts. Should only be used for debugging")
2313

14+
if (ECS_COMPILE_AS_MODULE)
15+
# Module stuff (experimental)
16+
include(cxx_modules_rules.cmake)
17+
18+
add_library(ecs)
19+
target_compile_definitions(ecs PUBLIC ECS_USE_MODULES)
20+
target_sources(ecs PUBLIC FILE_SET CXX_MODULES FILES "include/ecs/ecs.ixx")
21+
else()
22+
# creates a library 'ecs' which is an interface (header files only)
23+
add_library(ecs INTERFACE)
24+
25+
install(
26+
DIRECTORY include/ecs
27+
DESTINATION include
28+
)
29+
30+
target_compile_definitions(ecs INTERFACE ECS_EXPORT=)
31+
endif()
32+
2433
if (ECS_ENABLE_CONTRACTS)
2534
target_compile_definitions(ecs INTERFACE ECS_ENABLE_CONTRACTS)
2635

@@ -36,7 +45,7 @@ endif ()
3645

3746
if (MSVC)
3847
target_compile_options(ecs INTERFACE
39-
/std:c++latest
48+
#/std:c++latest
4049

4150
# enable lots of warnings
4251
/W4
@@ -86,7 +95,7 @@ if (MSVC)
8695
else()
8796
# lots of warnings
8897
target_compile_options(ecs INTERFACE
89-
-std=c++2a
98+
#-std=c++2a
9099
-Wall
91100
-Wextra
92101
-Wpedantic

CMakePresets.json

+3-19
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"configurePresets": [
44
{
55
"name": "gcc-11-debug",
6-
"displayName": "GCC 11 - Debug",
76
"description": "Target the Windows Subsystem for Linux or a remote Linux system.",
87
"generator": "Ninja",
98
"binaryDir": "${sourceDir}/out/build/${presetName}",
9+
"toolset": "11",
1010
"cacheVariables": {
1111
"CMAKE_BUILD_TYPE": "Debug",
1212
"CMAKE_C_COMPILER": "gcc-11",
@@ -26,25 +26,9 @@
2626
},
2727
{
2828
"name": "gcc-11-release",
29-
"displayName": "GCC 11 - Release",
30-
"description": "Target the Windows Subsystem for Linux or a remote Linux system.",
31-
"generator": "Ninja",
32-
"binaryDir": "${sourceDir}/out/build/${presetName}",
29+
"inherits": "gcc-11-debug",
3330
"cacheVariables": {
3431
"CMAKE_BUILD_TYPE": "Release",
35-
"CMAKE_C_COMPILER": "gcc-11",
36-
"CMAKE_CXX_COMPILER": "g++-11"
37-
},
38-
"vendor": {
39-
"microsoft.com/VisualStudioSettings/CMake/1.0": {
40-
"hostOS": [
41-
"Linux"
42-
],
43-
"intelliSenseMode": "linux-gcc-x64"
44-
},
45-
"microsoft.com/VisualStudioRemoteSettings/CMake/1.0": {
46-
"sourceDir": "$env{HOME}/.vs/$ms{projectDirName}"
47-
}
4832
}
4933
},
5034
{
@@ -278,7 +262,7 @@
278262
"displayName": "Debug 2019 (v14.2)",
279263
"description": "Target Windows with the Visual Studio development environment.",
280264
"generator": "Visual Studio 17 2022",
281-
"toolset": "v142",
265+
"toolset": "14.2",
282266
"binaryDir": "${sourceDir}/out/build/${presetName}",
283267
"architecture": {
284268
"value": "x64",

0 commit comments

Comments
 (0)