Skip to content

Commit a36eeda

Browse files
jkwak-workcsyonghe
authored andcommitted
Updating CONTRIBUTION guide to use CMake (shader-slang#4017)
Releated to shader-slang#3703 Removing the build instruction with Premake and replacing it with an instruction with CMake. It is because we are going to move over to CMake anytime soon. Bumping the required CMake version to 3.25.0. When CMakePresets.json has "version:6", it requires CMake version to be 3.25 or above. See the URL below for more information, https://cmake.org/cmake/help/latest/release/3.25.html CMakeLists.txt copies the prebuilt binary files from external/slang-binaries/bin/windows-x64 CMakeLists.txt was copying "slang-llvm.dll" to build/Release/lib directory when it should have been build/Release/bin. It made slang-test to ignore all FILECHECK tests. This is fixed. Co-authored-by: Yong He <yonghe@outlook.com>
1 parent c805beb commit a36eeda

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ option(SLANG_EMBED_STDLIB "Build slang with an embedded version of the stdlib")
9393
option(SLANG_ENABLE_FULL_IR_VALIDATION "Enable full IR validation (SLOW!)")
9494
option(SLANG_ENABLE_ASAN "Enable ASAN (address sanitizer)")
9595

96+
option(SLANG_ENABLE_PREBUILT_BINARIES "Enable using prebuilt binaries" ON)
9697
option(SLANG_ENABLE_GFX "Enable gfx targets" ON)
9798
option(SLANG_ENABLE_SLANGD "Enable language server target" ON)
9899
option(SLANG_ENABLE_SLANGC "Enable standalone compiler target" ON)
@@ -390,7 +391,7 @@ if(SLANG_SLANG_LLVM_FLAVOR STREQUAL "FETCH_BINARY")
390391
endif()
391392

392393
set(slang_llvm_dest_object
393-
${CMAKE_BINARY_DIR}/$<CONFIG>/${library_subdir}/${slang_llvm_filename}
394+
${CMAKE_BINARY_DIR}/$<CONFIG>/${runtime_subdir}/${slang_llvm_filename}
394395
)
395396
add_custom_command(
396397
OUTPUT ${slang_llvm_dest_object}
@@ -453,6 +454,18 @@ elseif(SLANG_SLANG_LLVM_FLAVOR STREQUAL "USE_SYSTEM_LLVM")
453454
# pulling in libLLVM.so)
454455
endif()
455456

457+
if(SLANG_ENABLE_PREBUILT_BINARIES)
458+
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
459+
add_custom_target(
460+
copy-prebuilt-binaries ALL
461+
COMMAND ${CMAKE_COMMAND} -E copy_directory
462+
${CMAKE_SOURCE_DIR}/external/slang-binaries/bin/windows-x64
463+
${CMAKE_BINARY_DIR}/$<CONFIG>/${runtime_subdir}
464+
VERBATIM
465+
)
466+
endif()
467+
endif()
468+
456469
if(SLANG_ENABLE_GFX)
457470
#
458471
# `platform` contains all the platform abstractions for a GUI application.

CMakePresets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": 6,
33
"cmakeMinimumRequired": {
44
"major": 3,
5-
"minor": 20,
5+
"minor": 25,
66
"patch": 0
77
},
88
"configurePresets": [

CONTRIBUTION.md

+21-14
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,35 @@ Please follow the instructions of how to [Building Slang from Source](docs/build
7373
For a quick reference, follow the instructions below.
7474

7575
#### Windows
76-
Find where the premake executable is. The location may change when we upgrade Premake.
77-
```
78-
C:\git\slang> where /r external\slang-binaries\premake premake*.exe
79-
```
76+
Download and install CMake from [CMake.org/download](https://cmake.org/download)
8077

81-
Run the premake with the following command line options after replacing "PREMAKE" with the result from the previous command.
78+
Run CMake with the following command to generate a Visual Studio 2022 Solution:
8279
```
83-
# For VisualStudio 2019
84-
C:\git\slang> PREMAKE vs2019 --deps=true --arch=x64
85-
# For VisualStudio 2017
86-
C:\git\slang> PREMAKE vs2017 --deps=true --arch=x64
80+
# For VisualStudio 2022
81+
C:\git\slang> cmake.exe --preset vs2022
8782
```
8883

8984
Open slang.sln with VisualStudio IDE and build it for "x64".
9085

86+
Or you can build with a following command:
87+
```
88+
C:\git\slang> cmake.exe --build --preset release
89+
```
90+
9191
#### Linux
92-
Find where the premake is and run it with gmake2 option.
92+
Install CMake and Ninja.
93+
```
94+
$ sudo apt-get install cmake ninja-build
95+
```
96+
97+
Run CMake with a following command to generate Makefile:
98+
```
99+
$ cmake --preset default
100+
```
101+
102+
Build with a following command:
93103
```
94-
$ PREMAKE="$(find external/slang-binaries/premake -type f -iname 'premake5' | grep bin/linux-64)"
95-
$ chmod u+x "$PREMAKE"
96-
$ "$PREMAKE" gmake2 --deps=true --arch=x64
97-
$ make config=release_x64
104+
$ cmake --build --preset release
98105
```
99106

100107
### Making Changes

0 commit comments

Comments
 (0)