summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2024-04-24 18:35:46 -0700
committerGitHub <noreply@github.com>2024-04-24 18:35:46 -0700
commit52dcb5bd44aa15f07826062c53fae344d55959e9 (patch)
tree9303a69b335289bf9143330bf06d5ea69969854d
parent941961e5dad5afa51095450b8d57380c322900c0 (diff)
Updating CONTRIBUTION guide to use CMake (#4017)
Releated to #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>
-rw-r--r--CMakeLists.txt15
-rw-r--r--CMakePresets.json2
-rw-r--r--CONTRIBUTION.md35
3 files changed, 36 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49d2ab2f4..6793a9f6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -87,6 +87,7 @@ option(SLANG_EMBED_STDLIB "Build slang with an embedded version of the stdlib")
option(SLANG_ENABLE_FULL_IR_VALIDATION "Enable full IR validation (SLOW!)")
option(SLANG_ENABLE_ASAN "Enable ASAN (address sanitizer)")
+option(SLANG_ENABLE_PREBUILT_BINARIES "Enable using prebuilt binaries" ON)
option(SLANG_ENABLE_GFX "Enable gfx targets" ON)
option(SLANG_ENABLE_SLANGD "Enable language server target" ON)
option(SLANG_ENABLE_SLANGC "Enable standalone compiler target" ON)
@@ -385,7 +386,7 @@ if(SLANG_SLANG_LLVM_FLAVOR STREQUAL "FETCH_BINARY")
endif()
set(slang_llvm_dest_object
- ${CMAKE_BINARY_DIR}/$<CONFIG>/${library_subdir}/${slang_llvm_filename}
+ ${CMAKE_BINARY_DIR}/$<CONFIG>/${runtime_subdir}/${slang_llvm_filename}
)
add_custom_command(
OUTPUT ${slang_llvm_dest_object}
@@ -445,6 +446,18 @@ elseif(SLANG_SLANG_LLVM_FLAVOR STREQUAL "USE_SYSTEM_LLVM")
# pulling in libLLVM.so)
endif()
+if(SLANG_ENABLE_PREBUILT_BINARIES)
+ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ add_custom_target(
+ copy-prebuilt-binaries ALL
+ COMMAND ${CMAKE_COMMAND} -E copy_directory
+ ${CMAKE_SOURCE_DIR}/external/slang-binaries/bin/windows-x64
+ ${CMAKE_BINARY_DIR}/$<CONFIG>/${runtime_subdir}
+ VERBATIM
+ )
+ endif()
+endif()
+
if(SLANG_ENABLE_GFX)
#
# `platform` contains all the platform abstractions for a GUI application.
diff --git a/CMakePresets.json b/CMakePresets.json
index c23fbada1..de1959c28 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -2,7 +2,7 @@
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
- "minor": 20,
+ "minor": 25,
"patch": 0
},
"configurePresets": [
diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md
index 594e32a9f..fb5f9e5e2 100644
--- a/CONTRIBUTION.md
+++ b/CONTRIBUTION.md
@@ -73,28 +73,35 @@ Please follow the instructions of how to [Building Slang from Source](docs/build
For a quick reference, follow the instructions below.
#### Windows
-Find where the premake executable is. The location may change when we upgrade Premake.
-```
-C:\git\slang> where /r external\slang-binaries\premake premake*.exe
-```
+Download and install CMake from [CMake.org/download](https://cmake.org/download)
-Run the premake with the following command line options after replacing "PREMAKE" with the result from the previous command.
+Run CMake with the following command to generate a Visual Studio 2022 Solution:
```
-# For VisualStudio 2019
-C:\git\slang> PREMAKE vs2019 --deps=true --arch=x64
-# For VisualStudio 2017
-C:\git\slang> PREMAKE vs2017 --deps=true --arch=x64
+# For VisualStudio 2022
+C:\git\slang> cmake.exe --preset vs2022
```
Open slang.sln with VisualStudio IDE and build it for "x64".
+Or you can build with a following command:
+```
+C:\git\slang> cmake.exe --build --preset release
+```
+
#### Linux
-Find where the premake is and run it with gmake2 option.
+Install CMake and Ninja.
+```
+$ sudo apt-get install cmake ninja-build
+```
+
+Run CMake with a following command to generate Makefile:
+```
+$ cmake --preset default
+```
+
+Build with a following command:
```
-$ PREMAKE="$(find external/slang-binaries/premake -type f -iname 'premake5' | grep bin/linux-64)"
-$ chmod u+x "$PREMAKE"
-$ "$PREMAKE" gmake2 --deps=true --arch=x64
-$ make config=release_x64
+$ cmake --build --preset release
```
### Making Changes