mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Support mingw gcc and llvm-ming(clang) build.
This commit is contained in:
13
README.md
13
README.md
@@ -37,7 +37,9 @@ TinyUSDZ is currently in alpha stage. Not usable.
|
||||
* C++11 compiler
|
||||
* [x] gcc 4.8.5(CentOS 7 default) or later
|
||||
* [x] Visual Studio 2017 or later(2015 may OK)
|
||||
* [x] Can be compiled with standalone MSVC compilers(Build Tools for Visual Studio 2017)
|
||||
* [x] clang 3.8 or later
|
||||
* [x] llvm-ming(clang) supported
|
||||
|
||||
## USDZ file format
|
||||
|
||||
@@ -67,6 +69,17 @@ $ cmake ..
|
||||
$ make
|
||||
```
|
||||
|
||||
#### LLVM-MinGW build
|
||||
|
||||
MinGW native and cross-compiling example using llvm-mingw(clang) is provided.
|
||||
See `scripts/bootstrap-cmake-mingw-win.sh` and `scripts/bootstrap-cmake-llvm-mingw-cross.sh` for details.
|
||||
|
||||
One of benefit to use llvm-mingw is address sanitizer support on Windows app.
|
||||
|
||||
To run app(`.exe`, you'll need `libunwind.dll` and `libc++.dll` on your working directory or search path)
|
||||
|
||||
For Windows native build, we assume `ninja.exe` is installed on your system(You can use it from Meson package)
|
||||
|
||||
#### CMake build options
|
||||
|
||||
* `TINYUSDZ_BUILD_TESTS` : Build tests
|
||||
|
||||
24
cmake/llvm-mingw-cross.cmake
Normal file
24
cmake/llvm-mingw-cross.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
IF (DEFINED ENV{LLVM_MINGW_DIR})
|
||||
SET(LLVM_MINGW_ROOT "$ENV{LLVM_MINGW_DIR}")
|
||||
ELSE ()
|
||||
SET(LLVM_MINGW_ROOT "/mnt/data/local/llvm-mingw-20200325-ubuntu-18.04")
|
||||
ENDIF()
|
||||
|
||||
|
||||
SET(CMAKE_C_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-clang)
|
||||
SET(CMAKE_CXX_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-clang++)
|
||||
SET(CMAKE_RC_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-windres)
|
||||
|
||||
#SET(CMAKE_C_LINK_EXECUTABLE x86_64-w64-mingw32-gcc)
|
||||
#SET(CMAKE_CXX_LINK_EXECUTABLE x86_64-w64-mingw32-g++)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH ${LLVM_MINGW_ROOT}/x86_64-w64-mingw32)
|
||||
|
||||
# We may need some advanced thread APIs to compile, so enable 0x601(Win7) if required.
|
||||
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x601")
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
20
cmake/llvm-mingw-win64.cmake
Normal file
20
cmake/llvm-mingw-win64.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
IF (DEFINED ENV{LLVM_MINGW_DIR})
|
||||
SET(LLVM_MINGW_ROOT "$ENV{LLVM_MINGW_DIR}")
|
||||
ELSE ()
|
||||
SET(LLVM_MINGW_ROOT "C:/ProgramData/llvm-mingw")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_C_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-clang.exe)
|
||||
SET(CMAKE_CXX_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-clang++.exe)
|
||||
SET(CMAKE_RC_COMPILER ${LLVM_MINGW_ROOT}/bin/x86_64-w64-mingw32-windres.exe)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH ${LLVM_MINGW_ROOT}/x86_64-w64-mingw32)
|
||||
|
||||
# We may need some advanced thread APIs to compile tinyusz. use 0x601(Win7) if required
|
||||
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x601")
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
20
cmake/mingw64-cross.cmake
Normal file
20
cmake/mingw64-cross.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
IF (DEFINED ENV{MINGW_GCC_DIR})
|
||||
SET(MINGW_GCC_ROOT "$ENV{MINGW_GCC_DIR}")
|
||||
ELSE ()
|
||||
# Assume mingw cross compiler is installed in your system
|
||||
SET(MINGW_GCC_ROOT "/usr")
|
||||
ENDIF()
|
||||
|
||||
# win32 may fail to compile with C++11 threads.
|
||||
|
||||
SET(CMAKE_C_COMPILER ${MINGW_GCC_ROOT}/bin/x86_64-w64-mingw32-gcc-posix)
|
||||
SET(CMAKE_CXX_COMPILER ${MINGW_GCC_ROOT}/bin/x86_64-w64-mingw32-g++-posix)
|
||||
SET(CMAKE_RC_COMPILER ${MINGW_GCC_ROOT}/bin/x86_64-w64-mingw32-windres)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH ${MINGW_GCC_ROOT}/x86_64-w64-mingw32)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
19
scripts/bootstrap-cmake-llvm-mingw-cross.sh
Executable file
19
scripts/bootstrap-cmake-llvm-mingw-cross.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
# llvm-mingw cross compile
|
||||
# Assume Ninja is installed on your system
|
||||
curdir=`pwd`
|
||||
|
||||
# Set path to llvm-mingw in env var.
|
||||
export LLVM_MINGW_DIR=/mnt/data/local/llvm-mingw-20200325-ubuntu-18.04/
|
||||
|
||||
builddir=${curdir}/build-llvm-mingw
|
||||
|
||||
rm -rf ${builddir}
|
||||
mkdir ${builddir}
|
||||
|
||||
cd ${builddir} && cmake \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${curdir}/cmake/llvm-mingw-cross.cmake \
|
||||
-G "Ninja" \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=1 \
|
||||
..
|
||||
|
||||
cd ${curdir}
|
||||
8
scripts/bootstrap-cmake-mingw-win.sh → scripts/bootstrap-cmake-llvm-mingw-win.sh
Normal file → Executable file
8
scripts/bootstrap-cmake-mingw-win.sh → scripts/bootstrap-cmake-llvm-mingw-win.sh
Normal file → Executable file
@@ -2,15 +2,17 @@
|
||||
# Assume Ninja is installed on your system
|
||||
curdir=`pwd`
|
||||
|
||||
builddir=${curdir}/build
|
||||
# Set path to llvm-mingw in env var.
|
||||
set LLVM_MINGW_DIR=/d/local/llvm-mingw-20200325-ubuntu-18.04/
|
||||
|
||||
builddir=${curdir}/build-llvm-mingw
|
||||
|
||||
rm -rf ${builddir}
|
||||
mkdir ${builddir}
|
||||
|
||||
# Change the path to llvm-mingw to fit into your system.
|
||||
cd ${builddir} && cmake \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${curdir}/cmake/llvm-mingw-win64.cmake \
|
||||
-G "Ninja" \
|
||||
-DCMAKE_CXX_COMPILER=/d/local/llvm-mingw/bin/x86_64-w64-mingw32-g++.exe \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=1 \
|
||||
..
|
||||
|
||||
17
scripts/bootstrap-cmake-mingw-gcc-cross.sh
Executable file
17
scripts/bootstrap-cmake-mingw-gcc-cross.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
# mingw gcc cross compile
|
||||
curdir=`pwd`
|
||||
|
||||
# Set path to mingw in env var(if required).
|
||||
export MINGW_GCC_DIR=/usr
|
||||
|
||||
builddir=${curdir}/build-mingw
|
||||
|
||||
rm -rf ${builddir}
|
||||
mkdir ${builddir}
|
||||
|
||||
cd ${builddir} && cmake \
|
||||
-DCMAKE_TOOLCHAIN_FILE=${curdir}/cmake/mingw64-cross.cmake \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=1 \
|
||||
..
|
||||
|
||||
cd ${curdir}
|
||||
Reference in New Issue
Block a user