Skip to content

Commit 7a11043

Browse files
committed
-Dev: full support for Linux
1 parent 779ecdf commit 7a11043

File tree

3 files changed

+76
-14
lines changed

3 files changed

+76
-14
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1616
message("Using GCC")
1717
endif()
1818

19-
20-
# Set the platform (e.g., x64)
21-
# set(CMAKE_GENERATOR_PLATFORM x64) # or Win32, as needed
22-
2319
# Use C++17
2420
set(CMAKE_CXX_STANDARD 17)
2521
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -33,6 +29,10 @@ find_package(Vulkan REQUIRED)
3329
if(NOT Vulkan_FOUND)
3430
message(FATAL_ERROR "Vulkan SDK not found. Please install Vulkan SDK and ensure it's in your CMake search path.")
3531
endif()
32+
# if(UNIX)
33+
# set(SHADERC_INCLUDE_DIRS $ENV{VULKAN_SDK}/include)
34+
# set(SHADERC_LIBRARIES $ENV{VULKAN_SDK}/lib/libshaderc_combined.a)
35+
# endif()
3636

3737
# Get the root path for Vulkan from the Vulkan_LIBRARY variable
3838
get_filename_component(VULKAN_SDK_ROOT ${Vulkan_LIBRARY} DIRECTORY)

CMakePresets.json

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"name": "ninja-debug",
1313
"displayName": "Ninja (Debug)",
1414
"generator": "Ninja",
15-
"binaryDir": "${sourceDir}/build/ninja-debug",
15+
"binaryDir": "${sourceDir}/build/${presetName}",
1616
"cacheVariables": {
1717
"CMAKE_CXX_COMPILER": "clang++",
1818
"CMAKE_C_COMPILER": "clang",
@@ -27,7 +27,7 @@
2727
"name": "ninja-release",
2828
"displayName": "Ninja (Release)",
2929
"generator": "Ninja",
30-
"binaryDir": "${sourceDir}/build/ninja-release",
30+
"binaryDir": "${sourceDir}/build/${presetName}",
3131
"cacheVariables": {
3232
"CMAKE_CXX_COMPILER": "clang++",
3333
"CMAKE_C_COMPILER": "clang",
@@ -42,7 +42,7 @@
4242
"displayName": "Visual Studio 2022 (x64) (Debug)",
4343
"generator": "Visual Studio 17 2022",
4444
"architecture": "x64",
45-
"binaryDir": "${sourceDir}/build/vs2022-x64-debug",
45+
"binaryDir": "${sourceDir}/build/${presetName}",
4646
"cacheVariables": {
4747
"CMAKE_BUILD_TYPE": "Debug"
4848
}
@@ -52,11 +52,38 @@
5252
"displayName": "Visual Studio 2022 (x64) (Release)",
5353
"generator": "Visual Studio 17 2022",
5454
"architecture": "x64",
55-
"binaryDir": "${sourceDir}/build/vs2022-x64-release",
55+
"binaryDir": "${sourceDir}/build/${presetName}",
5656
"cacheVariables": {
5757
"CMAKE_BUILD_TYPE": "Release"
5858
}
59+
},
60+
{
61+
"name": "GCC-x86_64-debug",
62+
"displayName": "GCC (x86-64) (Debug)",
63+
"binaryDir": "${sourceDir}/build/${presetName}",
64+
"cacheVariables": {
65+
"CMAKE_C_COMPILER": "gcc",
66+
"CMAKE_CXX_COMPILER": "g++",
67+
"CMAKE_CXX_STANDARD": "17",
68+
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
69+
"CMAKE_CXX_EXTENSIONS": "OFF",
70+
"CMAKE_BUILD_TYPE": "Debug"
71+
}
72+
},
73+
{
74+
"name": "GCC-x86_64-release",
75+
"displayName": "GCC (x86-64) (Release)",
76+
"binaryDir": "${sourceDir}/build/${presetName}",
77+
"cacheVariables": {
78+
"CMAKE_C_COMPILER": "gcc",
79+
"CMAKE_CXX_COMPILER": "g++",
80+
"CMAKE_CXX_STANDARD": "17",
81+
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
82+
"CMAKE_CXX_EXTENSIONS": "OFF",
83+
"CMAKE_BUILD_TYPE": "Release"
84+
}
5985
}
86+
6087
],
6188

6289
"buildPresets": [
@@ -77,6 +104,16 @@
77104
"name": "vs2022-x64-debug",
78105
"configurePreset": "vs2022-x64-debug",
79106
"configuration": "Debug"
107+
},
108+
{
109+
"name": "GCC-x86_64-debug",
110+
"configurePreset": "GCC-x86_64-debug",
111+
"configuration": "Debug"
112+
},
113+
{
114+
"name": "GCC-x86_64-release",
115+
"configurePreset": "GCC-x86_64-release",
116+
"configuration": "Release"
80117
}
81118
]
82119
}

README.md

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ This project is a work in progress. It has a long way until becoming a decent li
7171

7272
The prequisites for using this code are:
7373

74-
- Windows 10, 11 (Although it should be easy enough to set it up for Linux).
75-
- Vulkan SDK 1.3.* installed. (With VMA and Shaderc libraries)
74+
- Windows (10, 11) or Ubuntu (22, 23).
75+
- Vulkan SDK 1.3.* installed. **(With VMA and Shaderc libraries)**
7676
- CMake installed.
77-
- Ninja (Optional but recommended to speed-up compilation time)
77+
- Ninja 🥷 (Optional but recommended to speed-up compilation time)
7878

7979
1. Clone the repo:
8080
```bash
@@ -92,16 +92,16 @@ The prequisites for using this code are:
9292

9393
The project is configured in such a way that, during the build process, CMake takes care of automatically locating and linking all dependencies on the system, with exception of the Vulkan SDK, due to its more complex installation. This has been done to facilitate an easy and lightweight distribution of the source code, sparing the user the effort of manual configuration. Although the project has been implemented in VS Code, a practical file structure has been configured for CMake in case it is opened in Visual Studio or any other IDE.
9494

95-
Once the project is opened in the IDE of choice, compile it in the desired mode, and it would be ready to run. The CMake configuration is set for a 64-bit architecture, but it can be changed. CMake also takes care of automatically configuring the paths for resource files.
95+
Once the project is opened in the IDE of choice, compile it in the desired mode, and it would be ready to run (compile configurations json added for VS Code). CMake also takes care of automatically configuring the paths for resource files.
9696

9797
The project compiles dependencies, the 3D library, and the example applications directory, which statically links against the 3D library. The library is a STATIC lib, do not try to link dynamically against it.
9898

99-
3. Building of the demos and tests directory is optional, and can be turned off in CMake:
99+
3. Building of the demos and tests directory is **optional**, and can be turned off in CMake:
100100
```bash
101101
cmake -DBUILD_EXAMPLES=OFF /path/to/source
102102
cmake -DBUILD_TESTS=OFF /path/to/source
103103
```
104-
4. Alternatively, you can click on any of the setup folder .bat files to compile and configure the project using you preferred backend. If using VS Code, you can change presents in the CMake Tools' bar.
104+
4. **Alternatively**, you can click on any of the setup folder **.bat files** to compile and configure the project using you preferred backend. If using VS Code, you can change presents in the CMake Tools' bar.
105105

106106
## Project Integration 🗄️
107107

@@ -326,3 +326,28 @@ With a little extra effort, you can create much richer and interactive applicati
326326
As you can see, the library is easy to use: with a window, a camera, a scene filled with some meshes and of course a renderer, you have everything you need to start working.
327327

328328

329+
## FOR LINUX USERS ONLY
330+
331+
In order for GLFW to compile you will need to install these dependencies:
332+
333+
```bash
334+
sudo apt-get install libxkbcommon-x11-dev
335+
sudo apt-get install libxinerama-dev
336+
sudo apt-get install libxcursor-dev
337+
sudo apt-get install libxi-dev
338+
```
339+
340+
This uses x11 backend, if you want to use Wayland install Wayland depedencies.
341+
342+
After that, follow these steps:
343+
344+
1. Download https://vulkan.lunarg.com/sdk/home (better this way than apt because it brings VMA and shaderc)
345+
2. Extract and install
346+
```bash
347+
chmod +x vulkansdk-linux-x.x.x.x-setup.run
348+
./vulkansdk-linux-x.x.x.x-setup.run
349+
```
350+
3. Setup enviroment variables
351+
```bash
352+
source ~/VulkanSDK/x.x.x.x.x/setup-env.sh
353+
```

0 commit comments

Comments
 (0)