Initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Apply clang-format utility (if found) to all sources.
|
||||
#------------------------------------------------------
|
||||
|
||||
find_program(CLANG_FORMAT "clang-format")
|
||||
|
||||
if(CLANG_FORMAT)
|
||||
message("clang-format found, adding target to the build process.")
|
||||
file(GLOB_RECURSE
|
||||
all_source_files
|
||||
"include/*.h"
|
||||
"src/*.cc" "src/*.h"
|
||||
"test/*.cc" "test/*.h"
|
||||
"samples/*.cc" "samples/*.h"
|
||||
"howtos/*.cc")
|
||||
|
||||
add_custom_target(
|
||||
BUILD_CLANG_FORMAT
|
||||
COMMAND ${CLANG_FORMAT} -i -style=google ${all_source_files}
|
||||
VERBATIM)
|
||||
else()
|
||||
message("Optional program clang-format not found.")
|
||||
endif()
|
||||
@@ -0,0 +1,160 @@
|
||||
# Set compilers settings for all platforms/compilers.
|
||||
#---------------------------------------------------
|
||||
|
||||
#-----------------
|
||||
# Includes modules
|
||||
include(CheckIncludeFiles)
|
||||
|
||||
#------------------------------
|
||||
# Enables IDE folders y default
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
#------------------------
|
||||
# Available build options
|
||||
|
||||
#------------------------
|
||||
# Lists all the cxx flags
|
||||
set(cxx_all_flags
|
||||
CMAKE_CXX_FLAGS
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_RELEASE)
|
||||
|
||||
#--------------------------------------
|
||||
# Cross compiler compilation flags
|
||||
|
||||
# Requires C++11
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Simd math force ref
|
||||
if(ozz_build_simd_ref)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS OZZ_BUILD_SIMD_REF)
|
||||
endif()
|
||||
|
||||
#--------------------------------------
|
||||
# Modify default MSVC compilation flags
|
||||
if(MSVC)
|
||||
|
||||
#---------------------------
|
||||
# For the common build flags
|
||||
|
||||
# Disables crt secure warnings
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
|
||||
|
||||
# Adds support for multiple processes builds
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "/MP")
|
||||
|
||||
# Set the warning level to W4
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "/W4")
|
||||
|
||||
# Set warning as error
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "/WX")
|
||||
|
||||
# Select whether to use the DLL version or the static library version of the Visual C++ runtime library.
|
||||
foreach(flag ${cxx_all_flags})
|
||||
if (ozz_build_msvc_rt_dll)
|
||||
string(REGEX REPLACE "/MT" "/MD" ${flag} "${${flag}}")
|
||||
else()
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#--------------------------------------
|
||||
# else consider the compiler as GCC compatible
|
||||
# Modify default GCC compilation flags
|
||||
else()
|
||||
|
||||
# Set the warning level to Wall
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wall")
|
||||
|
||||
# Enable extra level of warning
|
||||
#set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wextra")
|
||||
|
||||
# Set warning as error
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Werror")
|
||||
|
||||
# Disables warning: ignored-attributes reports issue when using _m128 as template argument
|
||||
check_cxx_compiler_flag("-Wignored-attributes" W_IGNORED_ATTRIBUTES)
|
||||
if(W_IGNORED_ATTRIBUTES)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wno-ignored-attributes")
|
||||
endif()
|
||||
|
||||
# Enables warning: sign comparison warnings
|
||||
check_cxx_compiler_flag("-Wsign-compare" W_SIGN_COMPARE)
|
||||
if(W_SIGN_COMPARE)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-Wsign-compare")
|
||||
endif()
|
||||
|
||||
# Check some more options availability for the targeted compiler
|
||||
check_cxx_compiler_flag("-Wnull-dereference" W_NULL_DEREFERENCE)
|
||||
check_cxx_compiler_flag("-Wpragma-pack" W_PRAGMA_PACK)
|
||||
|
||||
# Enables debug glibcxx if NDebug isn't defined, not supported by APPLE
|
||||
if(NOT APPLE)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>")
|
||||
endif()
|
||||
|
||||
#----------------------
|
||||
# Sets emscripten output
|
||||
if(EMSCRIPTEN)
|
||||
SET(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
add_link_options(-s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0)
|
||||
|
||||
#if(NOT ozz_build_simd_ref)
|
||||
# set_property(DIRECTORY APPEND PROPERTY COMPILE_OPTIONS "-msse2")
|
||||
#endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
#---------------------
|
||||
# Prints all the flags
|
||||
message(STATUS "---------------------------------------------------------")
|
||||
message(STATUS "Default build type is: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "The following compilation flags will be used:")
|
||||
foreach(flag ${cxx_all_flags})
|
||||
message(${flag} " ${${flag}}")
|
||||
endforeach()
|
||||
|
||||
message(STATUS "---------------------------------------------------------")
|
||||
|
||||
get_directory_property(DirectoryCompileOptions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_OPTIONS)
|
||||
message(STATUS "Directory Compile Options:")
|
||||
foreach(opt ${DirectoryCompileOptions})
|
||||
message(STATUS ${opt})
|
||||
endforeach()
|
||||
|
||||
message(STATUS "---------------------------------------------------------")
|
||||
|
||||
get_directory_property(DirectoryCompileDefinitions DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
||||
message(STATUS "Directory Compile Definitions:")
|
||||
foreach(def ${DirectoryCompileDefinitions})
|
||||
message(STATUS ${def})
|
||||
endforeach()
|
||||
|
||||
message(STATUS "---------------------------------------------------------")
|
||||
|
||||
#----------------------------------------------
|
||||
# Modifies output directory for all executables
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ".")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ".")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ".")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ".")
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ".")
|
||||
|
||||
#-------------------------------
|
||||
# Set a postfix for output files
|
||||
if(ozz_build_postfix)
|
||||
set(CMAKE_DEBUG_POSTFIX "_d")
|
||||
set(CMAKE_RELEASE_POSTFIX "_r")
|
||||
set(CMAKE_MINSIZEREL_POSTFIX "_rs")
|
||||
set(CMAKE_RELWITHDEBINFO_POSTFIX "_rd")
|
||||
endif()
|
||||
@@ -0,0 +1,27 @@
|
||||
# Fuses all target .cc sources in a single file.
|
||||
#-----------------------------------------------
|
||||
|
||||
function(fuse_target _target_name)
|
||||
|
||||
set(output_file_name "${_target_name}.cc")
|
||||
set(output_file "${PROJECT_BINARY_DIR}/src_fused/${output_file_name}")
|
||||
|
||||
# Get all target sources.
|
||||
get_property(target_source_files TARGET ${_target_name} PROPERTY SOURCES)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${output_file}
|
||||
DEPENDS ${target_source_files}
|
||||
${PROJECT_SOURCE_DIR}/build-utils/cmake/fuse_target_script.cmake
|
||||
COMMAND ${CMAKE_COMMAND} -Dozz_fuse_output_file="${output_file}" -Dozz_target_source_files="${target_source_files}" -Dozz_fuse_target_dir="${CMAKE_CURRENT_LIST_DIR}" -Dozz_fuse_src_dir="${PROJECT_SOURCE_DIR}" -P "${PROJECT_SOURCE_DIR}/build-utils/cmake/fuse_target_script.cmake")
|
||||
|
||||
add_custom_target(BUILD_FUSE_${_target_name} ALL DEPENDS ${output_file})
|
||||
set_target_properties(BUILD_FUSE_${_target_name} PROPERTIES FOLDER "ozz/fuse")
|
||||
|
||||
if (NOT TARGET BUILD_FUSE_ALL)
|
||||
add_custom_target(BUILD_FUSE_ALL ALL)
|
||||
endif()
|
||||
|
||||
add_dependencies(BUILD_FUSE_ALL BUILD_FUSE_${_target_name})
|
||||
|
||||
endfunction()
|
||||
@@ -0,0 +1,37 @@
|
||||
# For each library, fuses all sources to a single .cc file.
|
||||
#----------------------------------------------------------
|
||||
|
||||
# Start with new content
|
||||
string(CONCAT output_content "" "// This file is autogenerated. Do not modify it.\n\n")
|
||||
|
||||
# Patches arguments so that cmake interprate it as a list.
|
||||
string (REPLACE " " ";" ozz_target_source_files "${ozz_target_source_files}")
|
||||
|
||||
# Concat all sources to the output.
|
||||
foreach(src_file ${ozz_target_source_files})
|
||||
get_filename_component(src_file_ext ${src_file} EXT)
|
||||
|
||||
# Handle source files.
|
||||
if(src_file_ext STREQUAL ".cc")
|
||||
file(READ "${ozz_fuse_target_dir}/${src_file}" src_file_content)
|
||||
|
||||
string(CONCAT output_content "${output_content}" "// Including ${src_file} file.\n\n")
|
||||
string(CONCAT output_content "${output_content}" "${src_file_content}\n")
|
||||
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Handle private include files (they are not prefixed by "ozz/").
|
||||
string(REGEX MATCHALL "#include \"[\^\"ozz\"]([^\"]+)\"" internal_include_lines ${output_content})
|
||||
|
||||
foreach(internal_include_line ${internal_include_lines})
|
||||
|
||||
STRING(REGEX REPLACE "#include \"([^\"]+)\"" "\\1" internal_include_file "${internal_include_line}" )
|
||||
|
||||
file(READ "${ozz_fuse_src_dir}/src/${internal_include_file}" internal_src_file_content)
|
||||
|
||||
string(REPLACE "${internal_include_line}" "\n// Includes internal include file ${internal_include_file}\n\n${internal_src_file_content}" output_content "${output_content}")
|
||||
|
||||
endforeach()
|
||||
|
||||
file(WRITE "${ozz_fuse_output_file}" "${output_content}")
|
||||
@@ -0,0 +1,274 @@
|
||||
# This module will try to located FBX SDK folder, based on the standard
|
||||
# directory structure proposed by Autodesk.
|
||||
# On every platform, the module will look for libraries that matches the
|
||||
# currently selected cmake generator.
|
||||
# A version can be specified to the find_package function.
|
||||
#
|
||||
# Once done, it will define
|
||||
# FBX_FOUND - System has Fbx SDK installed
|
||||
# FBX_INCLUDE_DIRS - The Fbx SDK include directories
|
||||
# FBX_LIBRARIES - The libraries needed to use Fbx SDK
|
||||
# FBX_LIBRARIES_DEBUG - The libraries needed to use debug Fbx SDK
|
||||
#
|
||||
# It accepts the following variables as input:
|
||||
#
|
||||
# FBX_MSVC_RT_DLL - Optional. Select whether to use the DLL version or the
|
||||
# static library version of the Visual C++ runtime library.
|
||||
# Default is ON (aka, DLL version: /MD).
|
||||
#
|
||||
# Known issues:
|
||||
# - On ALL platforms: If there are multiple FBX SDK version installed, the
|
||||
# current implementation will select the first one it finds.
|
||||
# - On MACOS: If there are multiple FBX SDK compiler supported (clang or gcc),
|
||||
# the current implementation will select the first one it finds.
|
||||
|
||||
#----------------------------------------------------------------------------#
|
||||
# #
|
||||
# ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation #
|
||||
# and distributed under the MIT License (MIT). #
|
||||
# #
|
||||
# Copyright (c) 2019 Guillaume Blanc #
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
###############################################################################
|
||||
# Generic library search function definition
|
||||
###############################################################################
|
||||
function(FindFbxLibrariesGeneric _FBX_ROOT_DIR _OUT_FBX_LIBRARIES _OUT_FBX_LIBRARIES_DEBUG)
|
||||
# Directory structure depends on the platform:
|
||||
# - Windows: \lib\<compiler_version>\<processor_type>\<build_mode>
|
||||
# - Mac OSX: \lib\<compiler_version>\ub\<processor_type>\<build_mode>
|
||||
# - Linux: \lib\<compiler_version>\<build_mode>
|
||||
|
||||
# Figures out matching compiler/os directory.
|
||||
|
||||
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.10)
|
||||
set(FBX_CP_PATH "vs2017")
|
||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19)
|
||||
set(FBX_CP_PATH "vs2015")
|
||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18)
|
||||
set(FBX_CP_PATH "vs2013")
|
||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
|
||||
set(FBX_CP_PATH "vs2012")
|
||||
elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 16)
|
||||
set(FBX_CP_PATH "vs2010")
|
||||
else()
|
||||
message ("Unsupported MSVC compiler version ${CMAKE_CXX_COMPILER_VERSION}.")
|
||||
return()
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
set(FBX_CP_PATH "*")
|
||||
else()
|
||||
set(FBX_CP_PATH "*")
|
||||
endif()
|
||||
|
||||
# Detects current processor type.
|
||||
if(NOT APPLE) # No <processor_type> on APPLE platform
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(FBX_PROCESSOR_PATH "x64")
|
||||
else()
|
||||
set(FBX_PROCESSOR_PATH "x86")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set libraries names to search, sorted by preference.
|
||||
set(FBX_SEARCH_LIB_NAMES fbxsdk-static.a libfbxsdk.a fbxsdk.a)
|
||||
|
||||
# Select whether to use the DLL version or the static library version of the Visual C++ runtime library.
|
||||
# Default is "md", aka use the multithread DLL version of the run-time library.
|
||||
if (NOT DEFINED FBX_MSVC_RT_DLL OR FBX_MSVC_RT_DLL)
|
||||
set(FBX_SEARCH_LIB_NAMES ${FBX_SEARCH_LIB_NAMES} libfbxsdk-md.lib)
|
||||
else()
|
||||
set(FBX_SEARCH_LIB_NAMES ${FBX_SEARCH_LIB_NAMES} libfbxsdk-mt.lib)
|
||||
endif()
|
||||
|
||||
# Set search path.
|
||||
set(FBX_SEARCH_LIB_PATH "${_FBX_ROOT_DIR}/lib/${FBX_CP_PATH}/${FBX_PROCESSOR_PATH}")
|
||||
|
||||
find_library(FBX_LIB
|
||||
${FBX_SEARCH_LIB_NAMES}
|
||||
HINTS "${FBX_SEARCH_LIB_PATH}/release/")
|
||||
|
||||
if(FBX_LIB)
|
||||
# Searches debug version also
|
||||
find_library(FBX_LIB_DEBUG
|
||||
${FBX_SEARCH_LIB_NAMES}
|
||||
HINTS "${FBX_SEARCH_LIB_PATH}/debug/")
|
||||
|
||||
if(UNIX)
|
||||
if(APPLE) # APPLE requires to link with Carbon framework
|
||||
find_library(CARBON_FRAMEWORK Carbon)
|
||||
list(APPEND FBX_LIB ${CARBON_FRAMEWORK})
|
||||
list(APPEND FBX_LIB_DEBUG ${CARBON_FRAMEWORK})
|
||||
else()
|
||||
find_package(Threads)
|
||||
list(APPEND FBX_LIB ${CMAKE_THREAD_LIBS_INIT} dl)
|
||||
list(APPEND FBX_LIB_DEBUG ${CMAKE_THREAD_LIBS_INIT} dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
FindFbxVersion(${FBX_ROOT_DIR} PATH_VERSION)
|
||||
|
||||
# 2019 SDK needs to link against bundled libxml and zlib
|
||||
if(PATH_VERSION GREATER_EQUAL "2019.1")
|
||||
if("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC")
|
||||
set(ADDITIONAL_LIB_SEARCH_PATH_RELEASE "${FBX_SEARCH_LIB_PATH}/release/")
|
||||
set(ADDITIONAL_LIB_SEARCH_PATH_DEBUG "${FBX_SEARCH_LIB_PATH}/debug/")
|
||||
if (NOT DEFINED FBX_MSVC_RT_DLL OR FBX_MSVC_RT_DLL)
|
||||
set(XML_SEARCH_LIB_NAMES libxml2-md.lib)
|
||||
set(Z_SEARCH_LIB_NAMES zlib-md.lib)
|
||||
else()
|
||||
set(XML_SEARCH_LIB_NAMES libxml2-mt.lib)
|
||||
set(Z_SEARCH_LIB_NAMES zlib-mt.lib)
|
||||
endif()
|
||||
else()
|
||||
set(ADDITIONAL_LIB_SEARCH_PATH_RELEASE "")
|
||||
set(ADDITIONAL_LIB_SEARCH_PATH_DEBUG "")
|
||||
set(XML_SEARCH_LIB_NAMES "xml2")
|
||||
set(Z_SEARCH_LIB_NAMES "z")
|
||||
endif()
|
||||
|
||||
find_library(XML_LIB
|
||||
${XML_SEARCH_LIB_NAMES}
|
||||
HINTS ${ADDITIONAL_LIB_SEARCH_PATH_RELEASE})
|
||||
find_library(Z_LIB
|
||||
${Z_SEARCH_LIB_NAMES}
|
||||
HINTS ${ADDITIONAL_LIB_SEARCH_PATH_RELEASE})
|
||||
|
||||
# Searches debug version also
|
||||
find_library(XML_LIB_DEBUG
|
||||
${XML_SEARCH_LIB_NAMES}
|
||||
HINTS ${ADDITIONAL_LIB_SEARCH_PATH_DEBUG})
|
||||
find_library(Z_LIB_DEBUG
|
||||
${Z_SEARCH_LIB_NAMES}
|
||||
HINTS ${ADDITIONAL_LIB_SEARCH_PATH_DEBUG})
|
||||
|
||||
# for whatever reason on apple it will need iconv as well?!
|
||||
if(APPLE)
|
||||
find_library(ICONV_LIB
|
||||
iconv)
|
||||
|
||||
# no special debug search here as mac only anyway
|
||||
|
||||
if(NOT ICONV_LIB)
|
||||
message(WARNING "FBX found but required iconv was not found!")
|
||||
endif()
|
||||
list(APPEND FBX_LIB ${ICONV_LIB})
|
||||
list(APPEND FBX_LIB_DEBUG ${ICONV_LIB})
|
||||
endif()
|
||||
|
||||
if(NOT XML_LIB)
|
||||
message(WARNING "FBX found but required libxml2 was not found!")
|
||||
endif()
|
||||
if(NOT Z_LIB)
|
||||
message(WARNING "FBX found but required zlib was not found!")
|
||||
endif()
|
||||
|
||||
list(APPEND FBX_LIB ${XML_LIB} ${Z_LIB})
|
||||
list(APPEND FBX_LIB_DEBUG ${XML_LIB_DEBUG} ${Z_LIB_DEBUG})
|
||||
endif()
|
||||
set(${_OUT_FBX_LIBRARIES} ${FBX_LIB} PARENT_SCOPE)
|
||||
set(${_OUT_FBX_LIBRARIES_DEBUG} ${FBX_LIB_DEBUG} PARENT_SCOPE)
|
||||
else()
|
||||
message ("A Fbx SDK was found, but doesn't match your compiler settings.")
|
||||
endif()
|
||||
# Deduce fbx sdk version
|
||||
endfunction()
|
||||
|
||||
###############################################################################
|
||||
# Deduce Fbx sdk version
|
||||
###############################################################################
|
||||
function(FindFbxVersion _FBX_ROOT_DIR _OUT_FBX_VERSION)
|
||||
# Opens fbxsdk_version.h in _FBX_ROOT_DIR and finds version defines.
|
||||
|
||||
set(fbx_version_filename "${_FBX_ROOT_DIR}include/fbxsdk/fbxsdk_version.h")
|
||||
|
||||
if(NOT EXISTS ${fbx_version_filename})
|
||||
message(SEND_ERROR "Unable to find fbxsdk_version.h")
|
||||
endif()
|
||||
|
||||
file(READ ${fbx_version_filename} fbx_version_file_content)
|
||||
|
||||
# Find version major
|
||||
if(fbx_version_file_content MATCHES "FBXSDK_VERSION_MAJOR[\t ]+([0-9]+)")
|
||||
set(fbx_version_file_major "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
# Find version minor
|
||||
if(fbx_version_file_content MATCHES "FBXSDK_VERSION_MINOR[\t ]+([0-9]+)")
|
||||
set(fbx_version_file_minor "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
# Find version patch
|
||||
if(fbx_version_file_content MATCHES "FBXSDK_VERSION_POINT[\t ]+([0-9]+)")
|
||||
set(fbx_version_file_patch "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
if (DEFINED fbx_version_file_major AND
|
||||
DEFINED fbx_version_file_minor AND
|
||||
DEFINED fbx_version_file_patch)
|
||||
set(${_OUT_FBX_VERSION} ${fbx_version_file_major}.${fbx_version_file_minor}.${fbx_version_file_patch} PARENT_SCOPE)
|
||||
else()
|
||||
message(SEND_ERROR "Unable to deduce Fbx version for root dir ${_FBX_ROOT_DIR}")
|
||||
set(${_OUT_FBX_VERSION} "unknown" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
###############################################################################
|
||||
# Main find package function
|
||||
###############################################################################
|
||||
|
||||
# Tries to find FBX SDK path
|
||||
set(FBX_SEARCH_PATHS
|
||||
"${FBX_DIR}"
|
||||
"$ENV{FBX_DIR}"
|
||||
"$ENV{ProgramW6432}/Autodesk/FBX/FBX SDK/*/"
|
||||
"$ENV{PROGRAMFILES}/Autodesk/FBX/FBX SDK/*/"
|
||||
"/Applications/Autodesk/FBX SDK/*/")
|
||||
|
||||
find_path(FBX_INCLUDE_DIR
|
||||
NAMES "include/fbxsdk.h"
|
||||
PATHS ${FBX_SEARCH_PATHS})
|
||||
|
||||
if(FBX_INCLUDE_DIR)
|
||||
# Deduce SDK root directory.
|
||||
set(FBX_ROOT_DIR "${FBX_INCLUDE_DIR}/")
|
||||
|
||||
# Fills CMake standard variables
|
||||
set(FBX_INCLUDE_DIRS "${FBX_INCLUDE_DIR}/include")
|
||||
|
||||
# Searches libraries according to the current compiler
|
||||
FindFbxLibrariesGeneric(${FBX_ROOT_DIR} FBX_LIBRARIES FBX_LIBRARIES_DEBUG)
|
||||
endif()
|
||||
|
||||
# Handles find_package arguments and set FBX_FOUND to TRUE if all listed variables and version are valid.
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(Fbx
|
||||
FOUND_VAR FBX_FOUND
|
||||
REQUIRED_VARS FBX_LIBRARIES FBX_INCLUDE_DIRS
|
||||
VERSION_VAR PATH_VERSION)
|
||||
|
||||
# Warn about how this script can fail to find the newest version.
|
||||
if(NOT FBX_FOUND)
|
||||
message("-- Note that the FindFbx.cmake script can fail to find the newest Fbx sdk if there are multiple ones installed. Please set \"FBX_DIR\" environment or cmake variable to choose a specific version/location.")
|
||||
endif()
|
||||
@@ -0,0 +1,37 @@
|
||||
# Setup packages informations.
|
||||
#-----------------------------
|
||||
|
||||
# Prepares installation
|
||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include" DESTINATION ".")
|
||||
|
||||
# Prepares packing
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${OZZ_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${OZZ_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${OZZ_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VENDOR "Guillaume Blanc")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ozz run-time animation library and tools. http://github.com/guillaumeblanc/ozz-animation")
|
||||
#set(CPACK_PACKAGE_ICON )
|
||||
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.md")
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
"/build/" # Out-of-source build directory.
|
||||
"/Testing/" # CDash generated files.
|
||||
"/\\\\.git/"
|
||||
".*\\\\.kdev4"
|
||||
".*~")
|
||||
set(CPACK_NSIS_MENU_LINKS
|
||||
"http://github.com/guillaumeblanc/ozz-animation;Ozz home"
|
||||
"bin/samples;Samples"
|
||||
"bin/tools;Tools")
|
||||
|
||||
# Defines local variables used for packaging
|
||||
STRING(SUBSTRING ${CMAKE_SYSTEM_NAME} 0 3 _PACKAGE_OS)
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4")
|
||||
set(_PACKAGE_BITS "32")
|
||||
else()
|
||||
set(_PACKAGE_BITS "64")
|
||||
endif()
|
||||
set(_PACKAGE_COMILER ${CMAKE_CXX_COMPILER_ID})
|
||||
set(_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${_PACKAGE_VERSION}-${_PACKAGE_OS}${_PACKAGE_BITS}-${_PACKAGE_COMILER}")
|
||||
include(CPack)
|
||||
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/python
|
||||
#----------------------------------------------------------------------------#
|
||||
# #
|
||||
# ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation #
|
||||
# and distributed under the MIT License (MIT). #
|
||||
# #
|
||||
# Copyright (c) Guillaume Blanc #
|
||||
# #
|
||||
# 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. #
|
||||
# #
|
||||
#----------------------------------------------------------------------------#
|
||||
|
||||
import os, glob
|
||||
import sys
|
||||
import itertools
|
||||
import string
|
||||
import re
|
||||
import time
|
||||
|
||||
def recurse_files(_folder, _filter):
|
||||
# Iterate files.
|
||||
for i in glob.iglob(os.path.join(_folder, _filter)):
|
||||
yield i
|
||||
# Iterate folders...
|
||||
for i in glob.iglob(os.path.join(_folder, '*/')):
|
||||
#... and recurse them.
|
||||
for j in recurse_files(i, _filter):
|
||||
if j.find('\\extern\\') == -1 and j.find('/extern/') == -1 and j.find('\\build\\') == -1 and j.find('/build/') == -1 and j.find('\\src_fused\\') == -1 and j.find('/src_fused/') == -1:
|
||||
yield j
|
||||
|
||||
license_text = "\
|
||||
//----------------------------------------------------------------------------//\n\
|
||||
// //\n\
|
||||
// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //\n\
|
||||
// and distributed under the MIT License (MIT). //\n\
|
||||
// //\n\
|
||||
// Copyright (c) Guillaume Blanc //\n\
|
||||
// //\n\
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a //\n\
|
||||
// copy of this software and associated documentation files (the \"Software\"), //\n\
|
||||
// to deal in the Software without restriction, including without limitation //\n\
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //\n\
|
||||
// and/or sell copies of the Software, and to permit persons to whom the //\n\
|
||||
// Software is furnished to do so, subject to the following conditions: //\n\
|
||||
// //\n\
|
||||
// The above copyright notice and this permission notice shall be included in //\n\
|
||||
// all copies or substantial portions of the Software. //\n\
|
||||
// //\n\
|
||||
// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //\n\
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //\n\
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //\n\
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //\n\
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //\n\
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //\n\
|
||||
// DEALINGS IN THE SOFTWARE. //\n\
|
||||
// //\n\
|
||||
//----------------------------------------------------------------------------//\n\
|
||||
\n\
|
||||
#"
|
||||
|
||||
def process_file(_file, _is_h):
|
||||
# Read
|
||||
fr = open(_file, 'rt')
|
||||
if fr == None:
|
||||
print "Failed to read file " + _file
|
||||
return False
|
||||
|
||||
text = fr.read();
|
||||
fr.close()
|
||||
|
||||
# Prepares output
|
||||
output = ""
|
||||
modified = False;
|
||||
|
||||
# Test for a valid license
|
||||
find_license = string.find(text, license_text)
|
||||
if find_license == -1:
|
||||
# Replaces license up to the first '#'
|
||||
first_define = string.find(text, '#')
|
||||
if first_define != -1:
|
||||
output = license_text + text[first_define + 1:]
|
||||
else:
|
||||
output = license_text + text
|
||||
modified = True
|
||||
else:
|
||||
output = text
|
||||
|
||||
# '#' must be found as it is part of the license
|
||||
first_define = string.find(output, '#')
|
||||
|
||||
if _is_h:
|
||||
# Test for a valid #define GUARD
|
||||
|
||||
# Removes pragma once
|
||||
pragma_once = '#pragma once'
|
||||
pragma_found = string.find(output[first_define:], pragma_once)
|
||||
if pragma_found == 0:
|
||||
output = output[:first_define] + output[first_define + len(pragma_once):]
|
||||
modified = True
|
||||
|
||||
# Prepares #define GUARD
|
||||
guard = string.upper(_file)
|
||||
to_replace = ['/', '\\', '.', '-']
|
||||
for i in to_replace:
|
||||
guard = string.replace(guard, i, '_')
|
||||
to_remove = ['INCLUDE_', 'SRC_']
|
||||
for i in to_remove:
|
||||
guard = string.replace(guard, i, '')
|
||||
guard = 'OZZ_' + guard + '_'
|
||||
guard = re.sub('_+', '_', guard)
|
||||
|
||||
header = '#ifndef ' + guard + '\n' + '#define ' + guard + '\n'
|
||||
footer = '#endif // ' + guard + '\n'
|
||||
|
||||
# Test for a valid header/footer
|
||||
found_match = re.search('^#ifndef (?P<found_guard>.+)\n^#define (?P=found_guard)\n(.*\n)*^#endif // (?P=found_guard)',
|
||||
output[first_define:],
|
||||
re.MULTILINE);
|
||||
if found_match == None:
|
||||
output = output[:first_define] + header + output[first_define:]
|
||||
if not output.endswith('\n'):
|
||||
output += '\n'
|
||||
output += footer;
|
||||
modified = True
|
||||
elif found_match.group('found_guard') != guard:
|
||||
output = string.replace(output, found_match.group('found_guard'), guard)
|
||||
modified = True
|
||||
|
||||
# Needs at least 1 \n
|
||||
if not output.endswith('\n'):
|
||||
output += '\n'
|
||||
|
||||
# remove \n after guard begin
|
||||
guard_pos = output.find(header) + len(header) - 1
|
||||
if not output.startswith('\n\n', guard_pos):
|
||||
output = output[:guard_pos] + '\n' + output[guard_pos:]
|
||||
modified = True
|
||||
while output.startswith('\n\n\n', guard_pos):
|
||||
output = output[:guard_pos] + output[guard_pos+1:]
|
||||
modified = True
|
||||
|
||||
# remove \n before guard end
|
||||
guard_pos = output.find(footer)
|
||||
while output.endswith('\n\n', 0, guard_pos):
|
||||
output = output[:guard_pos-1] + output[guard_pos:]
|
||||
guard_pos = output.find(footer)
|
||||
modified = True
|
||||
|
||||
# must end with a single \n
|
||||
if not output.endswith('\n'):
|
||||
output += '\n'
|
||||
modified = True
|
||||
else:
|
||||
while output.endswith('\n\n'):
|
||||
output = output[:len(output) - 1]
|
||||
modified = True
|
||||
|
||||
# Write
|
||||
if modified:
|
||||
fw = open(_file, 'wt')
|
||||
if fw == None:
|
||||
print "Failed to write file " + _file
|
||||
modified = False
|
||||
fw.write(output)
|
||||
fw.close()
|
||||
print _file + ' modified'
|
||||
|
||||
return modified
|
||||
|
||||
def process_h(_file):
|
||||
return process_file(_file, True)
|
||||
|
||||
def process_cc(_file):
|
||||
return process_file(_file, False)
|
||||
|
||||
def main():
|
||||
# Process .h
|
||||
for i in recurse_files('../../', '*.h'):
|
||||
process_h(i)
|
||||
# Process .cc
|
||||
for i in recurse_files('../../', '*.cc'):
|
||||
process_cc(i)
|
||||
#
|
||||
print 'Terminated'
|
||||
|
||||
while 1:
|
||||
time.sleep(10)
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user