-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: convert the plugin building process to cmake (#76)
* Move the previous plugin source under "Src" folder * Add script to find and execute Visual Studio 2019 developer command prompt * Add documents to build using cmake * Move g_filenameToPtrMap to Loader and add a new global define PLUGIN_DLL_EXPORT to define dllexport in the code * Add AddPlugin module to copy libraries directly to the Runtime folder * Pass BUILD_OSX_BUNDLE as an argument to AddPlugin * move dllmain.cpp under Win folder * Move TGALoader.cpp under Win folder * Copy the libraries to different folders based on the platform * Update Mac Bundle and dylib * Update Windows DLL * Load CommonLib.dylib on startup on Mac gitignore * ignore cmake build files * don't ignore dylib Yamato: * remove prepack
- Loading branch information
Showing
91 changed files
with
415 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" /version [16.0^,17^) /property installationPath`) do ( | ||
set VSDIR=%%i | ||
echo %%i | ||
) | ||
call "%VSDIR%\Common7\Tools\VsDevCmd.bat" | ||
cd %~dp0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Expects BUILD_TESTS variable to be defined | ||
|
||
option(ENABLE_DEPLOY "Copy built binaries to plugins directory." ON) | ||
|
||
|
||
function(add_plugin name) | ||
cmake_parse_arguments(arg "BUILD_OSX_BUNDLE" "PLUGINS_DIR" "SOURCES" ${ARGN}) | ||
file(TO_NATIVE_PATH ${arg_PLUGINS_DIR} native_plugins_dir) | ||
|
||
if(NOT BUILD_TESTS AND APPLE AND ${arg_BUILD_OSX_BUNDLE}) | ||
add_library(${name} MODULE ${arg_SOURCES}) | ||
set_target_properties(${name} PROPERTIES BUNDLE ON) | ||
else() | ||
add_library(${name} SHARED ${arg_SOURCES}) | ||
set_target_properties(${name} PROPERTIES PREFIX "") | ||
endif() | ||
|
||
if(ENABLE_DEPLOY) | ||
|
||
if(WIN32) | ||
|
||
# Win: Visual Studio Settings | ||
add_custom_command(TARGET ${name} POST_BUILD | ||
COMMAND del ${native_plugins_dir}\$(TargetFileName) | ||
COMMAND copy $(TargetPath) ${native_plugins_dir} | ||
|
||
) | ||
else() | ||
|
||
if(${arg_BUILD_OSX_BUNDLE}) | ||
SET(target_filename \${TARGET_BUILD_DIR}/${name}.bundle) | ||
else() | ||
SET(target_filename $<TARGET_FILE:${name}>) | ||
endif() | ||
|
||
# Linux or Mac | ||
add_custom_command(TARGET ${name} POST_BUILD | ||
COMMAND rm -rf ${arg_PLUGINS_DIR}/${target_filename} | ||
COMMAND cp -r ${target_filename} ${native_plugins_dir} | ||
) | ||
endif() | ||
|
||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.13) | ||
|
||
# Mac deployment target | ||
if(APPLE) | ||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version") | ||
endif() | ||
|
||
PROJECT(StreamingImageSequencePlugin) | ||
|
||
|
||
#cmake variables | ||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/Build/cmake_modules) | ||
|
||
# Custom scripts | ||
include(AddPlugin) | ||
|
||
set(src_root ${CMAKE_CURRENT_SOURCE_DIR}/Src) | ||
|
||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
if(APPLE) | ||
set(PLATFORM "OSX") | ||
find_library(CORE_GRAPHICS_LIBRARY CoreGraphics) | ||
mark_as_advanced(CORE_GRAPHICS_LIBRARY) | ||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
set(PLATFORM "Linux") | ||
set(LINUX ON) | ||
|
||
elseif(WIN32) | ||
set(PLATFORM "Win64") | ||
|
||
add_definitions(-DPLUGIN_DLL_EXPORT) | ||
|
||
# To handle DLL loading error related to the requirement of having VCRUNTIME140_1.DLL | ||
# https://developercommunity.visualstudio.com/content/problem/852548/vcruntime140-1dll-is-missing.html | ||
add_definitions(-d2FH4-) | ||
add_link_options(-d2:-FH4-) | ||
endif() | ||
|
||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") | ||
|
||
# Force Unicode character set | ||
add_definitions(-DUNICODE -D_UNICODE) | ||
|
||
|
||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
option(BUILD_TESTS "Tests" OFF) | ||
|
||
# ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
|
||
#Specify available modules | ||
add_subdirectory(${src_root}/External/stb) | ||
add_subdirectory(${src_root}/CommonLib) | ||
add_subdirectory(${src_root}/Loader) | ||
|
||
if(WIN32) | ||
add_subdirectory(${src_root}/DrawOverWindow) | ||
endif() | ||
|
||
# Tests | ||
if(BUILD_TESTS) | ||
add_subdirectory(${src_root}/PluginTest) | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Building Plugins | ||
|
||
1. [Windows](#building-on-windows) | ||
1. [Mac OSX](#building-on-mac-osx) | ||
|
||
|
||
## Building on Windows | ||
|
||
### Prerequisites (Win) | ||
|
||
1. Install [cmake](https://cmake.org/) version 3.13 or later. | ||
Make sure to choose one of the "Add CMake to the System PATH ..." options as shown below. | ||
 | ||
|
||
1. Install Visual Studio 2019. | ||
1. Install git. For example: [SourceTree](https://www.sourcetreeapp.com/) | ||
|
||
|
||
### Build Steps (Win) | ||
|
||
|
||
Start "Developer Command Prompt for VS 2019" and execute the following: | ||
|
||
``` | ||
$ git clone https://github.com/unity3d-jp/StreamingImageSequence.git | ||
$ cd StreamingImageSequence\Plugins~\Build | ||
$ cmake -G "Visual Studio 16 2019" -A x64 .. | ||
$ msbuild StreamingImageSequencePlugin.sln /t:Build /p:Configuration=Release /p:Platform=x64 /m /nologo | ||
``` | ||
|
||
> For a regular "Command Prompt", there is a script: *VsDevCmd_2019.bat* | ||
> under the *Build* folder, which if executed, will turn the prompt into a | ||
> "Developer Command Prompt for VS 2019". | ||
|
||
## Building on Mac OSX | ||
|
||
### Prerequisites (Mac) | ||
|
||
1. Install [cmake](https://cmake.org/) version 3.5 or later, if not already installed. | ||
1. Install [XCode](https://developer.apple.com/xcode/). | ||
1. Install XCode Command Line tools. | ||
``` | ||
xcode-select --install | ||
``` | ||
1. Install git. For example: [SourceTree](https://www.sourcetreeapp.com/) | ||
### Build Steps (Mac) | ||
Open a terminal and execute the following | ||
``` | ||
$ git clone https://github.com/unity3d-jp/StreamingImageSequence.git | ||
$ cd StreamingImageSequence/Plugins~/Build | ||
$ cmake -GXcode .. | ||
$ xcodebuild -scheme ALL_BUILD -configuration Release build | ||
``` | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.13) | ||
|
||
project(CommonLib) | ||
|
||
file(GLOB sources *.cpp *.h) | ||
set(CommonLib_dir "${CMAKE_CURRENT_SOURCE_DIR}") | ||
if(WIN32) | ||
file(GLOB win_sources Win/*.h Win/*.cpp) | ||
list(APPEND sources ${win_sources}) | ||
endif() | ||
set(src_root "${CMAKE_CURRENT_SOURCE_DIR}/..") | ||
set(plugins_dir "${src_root}/../../Runtime/Plugins/${PLATFORM}") | ||
|
||
# setup as a library | ||
add_plugin(CommonLib SOURCES ${sources} PLUGINS_DIR ${plugins_dir}) | ||
|
||
#Include, pch | ||
target_precompile_headers(CommonLib PRIVATE "${CommonLib_dir}/stdafx.h") | ||
target_include_directories(CommonLib PRIVATE | ||
${CommonLib_dir} | ||
${src_root} | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.13) | ||
|
||
project(DrawOverWindow) | ||
|
||
file(GLOB sources *.cpp *.h) | ||
set(DrawOverWindow_dir "${CMAKE_CURRENT_SOURCE_DIR}") | ||
if(WIN32) | ||
file(GLOB win_sources Win/*.h Win/*.cpp) | ||
list(APPEND sources ${win_sources}) | ||
endif() | ||
set(plugins_dir "${src_root}/../../Runtime/Plugins/${PLATFORM}") | ||
|
||
# setup as a library | ||
add_plugin(DrawOverWindow SOURCES ${sources} PLUGINS_DIR ${plugins_dir}) | ||
|
||
#Include, pch | ||
target_precompile_headers(DrawOverWindow PRIVATE "${DrawOverWindow_dir}/stdafx.h") | ||
target_include_directories(DrawOverWindow PRIVATE | ||
${DrawOverWindow_dir} | ||
${src_root} | ||
) | ||
|
||
# Library dependencies | ||
target_link_libraries( DrawOverWindow | ||
CommonLib | ||
) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.13) | ||
|
||
project(stb) | ||
|
||
file(GLOB sources *.cpp *.h) | ||
set(stb_dir "${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
# setup as a library | ||
add_library(stb STATIC ${sources} ) | ||
|
||
#Include, pch | ||
target_include_directories(stb PRIVATE | ||
${stb_dir} | ||
) | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 3.13) | ||
|
||
project(Loader) | ||
|
||
file(GLOB sources *.cpp *.h ../) | ||
set(Loader_dir "${CMAKE_CURRENT_SOURCE_DIR}") | ||
if(APPLE) | ||
file(GLOB mac_sources Mac/*.h Mac/*.cpp Mac/*.mm) | ||
list(APPEND sources ${mac_sources}) | ||
|
||
elseif(WIN32) | ||
file(GLOB win_sources Win/*.h Win/*.cpp) | ||
list(APPEND sources ${win_sources}) | ||
endif() | ||
set(src_root "${CMAKE_CURRENT_SOURCE_DIR}/..") | ||
set(plugins_dir "${src_root}/../../Runtime/Plugins/${PLATFORM}") | ||
|
||
# setup as a library | ||
add_plugin(Loader SOURCES ${sources} PLUGINS_DIR ${plugins_dir} BUILD_OSX_BUNDLE ) | ||
|
||
#Include, pch | ||
target_precompile_headers(Loader PRIVATE "${Loader_dir}/stdafx.h") | ||
target_include_directories(Loader PRIVATE | ||
${Loader_dir} | ||
${src_root} | ||
) | ||
|
||
# Library dependencies | ||
target_link_libraries( Loader | ||
CommonLib | ||
stb | ||
${CORE_GRAPHICS_LIBRARY} | ||
) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Oops, something went wrong.