Init
This commit is contained in:
18
cmake/README.md
Normal file
18
cmake/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
# Toolchain
|
||||
To use the same toolchain as the CI in vscode
|
||||
place the file 'cmake-kits.json' into your '.vscode' directory.
|
||||
Then select the 'Spacegame LLVM Kit' in the cmake-tools extension.
|
||||
Restarting vscode may be necessary.
|
||||
|
||||
# Debugging
|
||||
To enable debugging add this to your .vscode/settings.json
|
||||
```
|
||||
"cmake.debugConfig": {
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "/usr/bin/gdb"
|
||||
}
|
||||
```
|
||||
|
||||
# Usefull links
|
||||
- [LLVM Debian/Ubuntu packages](https://apt.llvm.org/)
|
||||
34
cmake/clang_mingw_toolchain.cmake
Normal file
34
cmake/clang_mingw_toolchain.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# This toolchain configuration file can be used cross-compile from linux to windows
|
||||
# Ref.: https://github.com/glfw/glfw/blob/master/CMake/x86_64-w64-mingw32-clang.cmake
|
||||
|
||||
MESSAGE("Cross-Compiling with toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
|
||||
# llvm-mingw-x86_64 is expected to be avilable under this directory
|
||||
set(MINGW_DIRECTORY /llvm-mingw-x86_64)
|
||||
|
||||
# Define the environment for cross-compiling with 64-bit MinGW-w64 Clang
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
SET(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_C_COMPILER ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-clang)
|
||||
set(CMAKE_CXX_COMPILER ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-clang++)
|
||||
set(CMAKE_RC_COMPILER ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-windres)
|
||||
set(CMAKE_RANLIB ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-ranlib)
|
||||
set(CMAKE_AR ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-ar)
|
||||
set(CMAKE_STRIP ${MINGW_DIRECTORY}/bin/x86_64-w64-mingw32-strip)
|
||||
|
||||
# Configure the behaviour of the find commands
|
||||
set(CMAKE_FIND_ROOT_PATH
|
||||
${MINGW_DIRECTORY}/x86_64-w64-mingw32
|
||||
${MINGW_DIRECTORY}
|
||||
/spacegame_deps)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
# Note: For windows we supply all libraries in use directly through mingw => Full static linking!
|
||||
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld -static")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld -static")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld -static")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)
|
||||
23
cmake/clang_toolchain.cmake
Normal file
23
cmake/clang_toolchain.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# This toolchain configuration file can be used for 'normal' linux native compilation
|
||||
|
||||
MESSAGE("Compiling with toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
|
||||
# Define the environment for compiling with 64-bit clang
|
||||
# Note: Ensure the proper links / aliases are set
|
||||
# ex. /usr/bin/clang -> /usr/bin/clang-18
|
||||
set(CMAKE_C_COMPILER /usr/bin/clang )
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/clang++ )
|
||||
set(CMAKE_RC_COMPILER /usr/bin/llvm-windres)
|
||||
set(CMAKE_RANLIB /usr/bin/llvm-ranlib )
|
||||
set(CMAKE_AR /usr/bin/llvm-ar )
|
||||
set(CMAKE_STRIP /usr/bin/llvm-strip )
|
||||
|
||||
# Note: We can static link with libc++, but not entirely since we depend on dynamic
|
||||
# libraries such as x11,glx,etc...
|
||||
# Note: Despite its name '-static-libstdc++' the option causes libc++ to be linked statically
|
||||
set(CMAKE_CXX_FLAGS_INIT "-stdlib=libc++" )
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld -static-libstdc++")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)
|
||||
10
cmake/cmake-kits.json
Normal file
10
cmake/cmake-kits.json
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"name": "Spacegame LLVM Kit",
|
||||
"toolchainFile": "cmake/clang_toolchain.cmake",
|
||||
"cmakeSettings":
|
||||
{
|
||||
"SPACEGAME_BUILD_SHADERS": "ON"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user