+ Add build script for windows

This commit is contained in:
indigo 2023-09-24 21:17:31 +08:00
parent 502777b45c
commit 570517b89f
4 changed files with 107 additions and 4 deletions

View File

@ -1,6 +1,6 @@
project(CgMeshInfo) project(CgMeshInfo)
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
add_subdirectory(src) add_subdirectory(src)

View File

@ -42,4 +42,12 @@ cmds.meshInfo(vtxHash=True, uvHash=True, ptHash=True, noIntermediate
# Mesh info file exported : C:/Temp/mesh_info.json # # Mesh info file exported : C:/Temp/mesh_info.json #
``` ```
## How to build in windows
### Requirement
* Visual Studio 2012 or Build Tool C++ 2012 or higher
open command shell (**CMD**), change dir into repository directory, then run the follow command
```shell
make.bat 2020
```

93
make.bat Normal file
View File

@ -0,0 +1,93 @@
@echo off
::
:: Usage :
:: make.bat [maya_version]
::
:: Example :
:: Build plugin for maya version 2020
:: > make.bat 2020
::
:: -------------------------------------
setlocal EnableDelayedExpansion
set maya_ver=%1
set maya_install_base=C:\aw
if "%1" == "" (
echo "Maya version is not specify. exit."
goto end
)
if "%2" NEQ "" (
set maya_install_base=%2
)
cd %~dp0
set current=%cd%
set is_build_tool=0
if not defined VisualStudioVersion (
echo "VisualStudioVersion is not set, setup %maya_ver% compiler..."
if %maya_ver% LSS 2020 (
set compiler_ver=9.0
if %maya_ver% LEQ 2014 set compiler_ver=10.0
if %maya_ver% GEQ 2015 set compiler_ver=11.0
if %maya_ver% GEQ 2018 set compiler_ver=14.0
set compiler_bat="%ProgramFiles(x86)%\Microsoft Visual Studio !compiler_ver!\VC\vcvarsall.bat" x86_amd64
)
if %maya_ver% GEQ 2020 (
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio 2017\WDExpress\VC\Auxiliary\Build\vcvarsall.bat" (
set compiler_bat="%ProgramFiles(x86)%\Microsoft Visual Studio 2017\WDExpress\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
set compiler_ver=15.0
)
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" (
set compiler_bat="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat"
)
)
set VisualStudioVersion=!compiler_ver!
if not exist !compiler_bat! (
echo "Can\'t find !compiler_bat!"
goto end
)
echo !compiler_bat!
call !compiler_bat!
)
if not defined VisualStudioVersion (
echo "VisualStudioVersion is not set correct."
goto end
)
IF %VisualStudioVersion% == 11.0 set vc_config=Visual Studio 11 2012 Win64
IF %VisualStudioVersion% == 12.0 set vc_config=Visual Studio 12 2013 Win64
IF %VisualStudioVersion% == 14.0 set vc_config=Visual Studio 14 2015 Win64
IF %VisualStudioVersion% == 15.0 set vc_config=Visual Studio 15 2017 Win64
set install_dir=%current%\install
if exist build ^
rmdir build /S/Q
if not exist build ^
mkdir build
cd build
cmake -G "%vc_config%"^
-DCMAKE_INSTALL_PREFIX=%install_dir%^
-DMAYA_INSTALL_BASE_PATH="%maya_install_base%"^
-DMAYA_VERSION=%maya_ver%^
..
:build
cmake --build . --target install --config Release -- /maxcpucount:8
:end
cd %current%
endlocal

View File

@ -5,18 +5,20 @@ set(SRC_FILES
"sha1.hpp" "sha1.hpp"
"json.hpp") "json.hpp")
# find_package(Maya REQUIRED) find_package(Maya REQUIRED)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
include_directories( include_directories(
"C:/aw/Maya2020/include" ${MAYA_INCLUDE_DIR}
) )
link_directories( link_directories(
"C:/aw/Maya2020/lib" ${MAYA_LIBRARY_DIR}
) )
link_libraries(Foundation OpenMaya OpenMayaAnim OpenMayaUI OpenMayaFX OpenMayaRender) link_libraries(Foundation OpenMaya OpenMayaAnim OpenMayaUI OpenMayaFX OpenMayaRender)
add_library(${PROJECT_NAME} SHARED ${SRC_FILES}) add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".mll") # Suffix set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".mll") # Suffix
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "plug-ins/${MAYA_VERSION}")