Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable choose maya version #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.1...3.15)

ADD_DEFINITIONS(-DVERSION="${VERSION}")


if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

cmake_policy(SET CMP0048 NEW)

project(meshCompare VERSION 1.0 DESCRIPTION "Next Mesh Compare Tool" LANGUAGES CXX)


set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../cgcmake/modules)


add_subdirectory(src)
44 changes: 22 additions & 22 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Chad Vernon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

The MIT License (MIT)
Copyright (c) 2015 Chad Vernon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
109 changes: 29 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,29 @@
# cgcmake
CMake modules for common applications related to computer graphics

# Sample Usage

## Maya Project

```
|-- CMakeLists.txt
|-- cgcmake
|-- modules
|-- FindMaya.cmake
|-- src
|-- CMakeLists.txt
|-- pluginMain.cpp
|-- sampleCmd.cpp
|-- sampleCmd.h
```

### Root CMakeLists.txt

```
cmake_minimum_required(VERSION 3.1...3.15)

if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

cmake_policy(SET CMP0048 NEW)

project(MayaProjectName VERSION 1.0 DESCRIPTION "My Maya Plug-in" LANGUAGES CXX)

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cgcmake/modules)

add_subdirectory(src)
```

### src/CMakeLists.txt

```
set(SOURCE_FILES
"pluginMain.cpp"
"sampleCmd.h"
"sampleCmd.cpp"
)

find_package(Maya REQUIRED)

add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})

target_link_libraries(${PROJECT_NAME} PRIVATE Maya::Maya)
target_include_directories(${PROJECT_NAME}
PRIVATE Maya::Maya
PUBLIC "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}"
)
MAYA_PLUGIN(${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME} ${MAYA_TARGET_TYPE} DESTINATION plug-ins/${MAYA_VERSION})
```

#### Windows

In a Command Prompt from the root of the project

Pre-Maya 2020
```
mkdir build.2019
cd build.2019
cmake -A x64 -T v140 -DMAYA_VERSION=2019 ../
cmake --build . --target install --config Release
```

Maya 2020
```
mkdir build.2020
cd build.2020
cmake -A x64 -T v141 -DMAYA_VERSION=2020 ../
cmake --build . --target install --config Release
```
# cgcmake
CMake modules for common applications related to computer graphics


Maya CMakeLists.txt
-------------------
cmake_minimum_required(VERSION 3.1)
project(sampleplugin)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/modules)

set(SOURCE_FILES "pluginMain.cpp"
"sampleCmd.cpp" "sampleCmd.h"
)

find_package(Maya REQUIRED)

add_library(sampleplugin SHARED ${SOURCE_FILES})
target_link_libraries(sampleplugin PRIVATE Maya::Maya)
target_include_directories(sampleplugin PRIVATE Maya::Maya)
MAYA_PLUGIN(sampleplugin)


From Command Line
-----------------
# CMake 3.x
cmake -G "Visual Studio 14 2015 Win64" -DMAYA_VERSION=2018 ../
cmake --build . --config Release

28 changes: 28 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off
pushd %~dp0
for /f "delims== tokens=1,2" %%G in (..\version.txt) do set %%G=%%H
echo version %version%
echo mayaVersion %mayaVersion%

if not exist bin mkdir bin
cd bin
del /s /q /f *.mll
cd ..

FOR %%G IN (%mayaVersion%) DO (call :subroutine "%%G")
popd
GOTO :eof


:subroutine
set builddir=build.%1
if not exist %builddir% goto BUILDENV
rmdir %builddir% /S /Q
:BUILDENV
mkdir %builddir%
cd %builddir%
cmake -DVERSION=%version% -A x64 -DCMAKE_TOOLCHAIN_FILE=../../../../cgcmake/toolchain/%1.cmake -DMAYA_VERSION=%1 ../
cmake --build . --target meshCompare --config Release
cd ..
xcopy .\build.%1\src\Release\meshCompare.mll .\bin\meshCompare_%1.mll* /Y
goto :eof
Loading