2024-03-17 12:47:11 +01:00
|
|
|
cmake_minimum_required(VERSION 3.24)
|
2021-11-11 21:22:24 +01:00
|
|
|
|
|
|
|
# Defines the project's name
|
|
|
|
project(ozz)
|
|
|
|
|
2023-04-15 00:07:29 +02:00
|
|
|
# Check if project is top level or a sub project
|
|
|
|
get_directory_property(is_sub_project PARENT_DIRECTORY)
|
|
|
|
|
2021-11-11 21:22:24 +01:00
|
|
|
# Current version
|
|
|
|
set(OZZ_VERSION_MAJOR 0)
|
2023-03-26 11:44:29 +02:00
|
|
|
set(OZZ_VERSION_MINOR 14)
|
2024-03-17 12:47:11 +01:00
|
|
|
set(OZZ_VERSION_PATCH 3)
|
2021-11-11 21:22:24 +01:00
|
|
|
set(OZZ_VERSION ${OZZ_VERSION_MAJOR}.${OZZ_VERSION_MINOR}.${OZZ_VERSION_PATCH})
|
|
|
|
|
|
|
|
# Add project build options
|
2023-03-26 11:44:29 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Build ozz as shared libraries" OFF)
|
2021-11-11 21:22:24 +01:00
|
|
|
option(ozz_build_tools "Build tools" ON)
|
|
|
|
option(ozz_build_fbx "Build Fbx pipeline (Requires Fbx SDK)" ON)
|
|
|
|
option(ozz_build_gltf "Build glTF importer (Requires c++11)" ON)
|
|
|
|
option(ozz_build_data "Build data on code change" OFF)
|
|
|
|
option(ozz_build_samples "Build samples" ON)
|
|
|
|
option(ozz_build_howtos "Build howtos" ON)
|
|
|
|
option(ozz_build_tests "Build unit tests" ON)
|
|
|
|
option(ozz_build_simd_ref "Force SIMD math reference implementation" OFF)
|
|
|
|
option(ozz_build_postfix "Use per config postfix name" ON)
|
2023-03-26 11:44:29 +02:00
|
|
|
option(ozz_build_msvc_rt_dll "Select msvc DLL runtime library" OFF)
|
|
|
|
|
|
|
|
# Checks DLL flags
|
|
|
|
if(WIN32 AND BUILD_SHARED_LIBS AND NOT ozz_build_msvc_rt_dll)
|
|
|
|
message("Forcing ozz_build_msvc_rt_dll to ON as ozz is being built as dll (BUILD_SHARED_LIBS is ON).")
|
|
|
|
set(ozz_build_msvc_rt_dll ON)
|
|
|
|
endif()
|
2024-03-17 12:47:11 +01:00
|
|
|
|
2023-04-15 00:07:29 +02:00
|
|
|
if(is_sub_project)
|
|
|
|
set(ozz_build_msvc_rt_dll ${ozz_build_msvc_rt_dll} PARENT_SCOPE)
|
|
|
|
endif()
|
2021-11-11 21:22:24 +01:00
|
|
|
|
|
|
|
# Include ozz cmake parameters and scripts
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/build-utils/cmake/compiler_settings.cmake)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/build-utils/cmake/package_settings.cmake)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/build-utils/cmake/fuse_target.cmake)
|
|
|
|
include(${PROJECT_SOURCE_DIR}/build-utils/cmake/clang_format.cmake)
|
2023-03-26 11:44:29 +02:00
|
|
|
include(${PROJECT_SOURCE_DIR}/build-utils/cmake/shared_library.cmake)
|
2021-11-11 21:22:24 +01:00
|
|
|
|
|
|
|
# Add project execution options
|
|
|
|
option(ozz_run_tests_headless "Run samples without rendering (used for unit tests)" ON)
|
|
|
|
set(ozz_sample_testing_loops "20" CACHE STRING "Number of loops while running sample tests (used for unit tests)")
|
|
|
|
|
|
|
|
# Configure CMake module path
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/build-utils/cmake/modules/")
|
|
|
|
|
|
|
|
# Detects Fbx SDK, required to build Fbx pipeline.
|
|
|
|
if(ozz_build_tools AND ozz_build_fbx)
|
|
|
|
# Select a msvc runtime compatible with ozz_build_msvc_rt_dll
|
2023-03-26 11:44:29 +02:00
|
|
|
set(FBX_SHARED ${BUILD_SHARED_LIBS})
|
2021-11-11 21:22:24 +01:00
|
|
|
set(FBX_MSVC_RT_DLL ${ozz_build_msvc_rt_dll})
|
|
|
|
|
|
|
|
# Search for FBX sdk package
|
|
|
|
find_package(Fbx 2016)
|
|
|
|
|
|
|
|
# Disables ozz_build_fbx if Fbx SDK isn't found.
|
|
|
|
if(NOT FBX_FOUND)
|
|
|
|
message("Fbx SDK not found, FBX tools libraries and samples will be skipped.")
|
|
|
|
set(ozz_build_fbx OFF)
|
|
|
|
endif()
|
2023-03-26 11:44:29 +02:00
|
|
|
|
2021-11-11 21:22:24 +01:00
|
|
|
else()
|
|
|
|
# Disables fbx if tools are disabled
|
|
|
|
set(ozz_build_fbx OFF)
|
|
|
|
endif()
|
2024-03-17 12:47:11 +01:00
|
|
|
|
2023-04-15 00:07:29 +02:00
|
|
|
if(is_sub_project)
|
|
|
|
set(ozz_build_fbx ${ozz_build_fbx} PARENT_SCOPE)
|
|
|
|
endif()
|
2021-11-11 21:22:24 +01:00
|
|
|
|
2024-03-17 12:47:11 +01:00
|
|
|
# gltf
|
2021-11-11 21:22:24 +01:00
|
|
|
if(ozz_build_tools AND ozz_build_gltf)
|
|
|
|
else()
|
|
|
|
set(ozz_build_gltf OFF)
|
|
|
|
endif()
|
2024-03-17 12:47:11 +01:00
|
|
|
|
2023-04-15 00:07:29 +02:00
|
|
|
if(is_sub_project)
|
|
|
|
set(ozz_build_gltf ${ozz_build_gltf} PARENT_SCOPE)
|
|
|
|
endif()
|
2021-11-11 21:22:24 +01:00
|
|
|
|
|
|
|
# Enables unit tests.
|
|
|
|
if(ozz_build_tests)
|
|
|
|
enable_testing()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Locates media directory.
|
|
|
|
set(ozz_media_directory "${PROJECT_SOURCE_DIR}/media")
|
|
|
|
|
|
|
|
# Creates temporary directory for tests inputs/outputs.
|
|
|
|
set(ozz_temp_directory ${PROJECT_BINARY_DIR}/temp)
|
|
|
|
file(MAKE_DIRECTORY ${ozz_temp_directory})
|
|
|
|
|
|
|
|
# Outputs selected options (can be modified by the command line)
|
|
|
|
message("-- ---------------------------------------------------------")
|
|
|
|
message("-- Selected options:")
|
2023-03-26 11:44:29 +02:00
|
|
|
message("-- - BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
|
2021-11-11 21:22:24 +01:00
|
|
|
message("-- - ozz_build_tools: " ${ozz_build_tools})
|
|
|
|
message("-- - ozz_build_fbx: " ${ozz_build_fbx})
|
|
|
|
message("-- - ozz_build_gltf: " ${ozz_build_gltf})
|
|
|
|
message("-- - ozz_build_data: " ${ozz_build_data})
|
|
|
|
message("-- - ozz_build_samples: " ${ozz_build_samples})
|
|
|
|
message("-- - ozz_build_howtos: " ${ozz_build_howtos})
|
|
|
|
message("-- - ozz_build_tests: " ${ozz_build_tests})
|
|
|
|
message("-- - ozz_build_simd_ref: " ${ozz_build_simd_ref})
|
|
|
|
message("-- - ozz_build_msvc_rt_dll: " ${ozz_build_msvc_rt_dll})
|
|
|
|
message("-- - ozz_build_postfix: " ${ozz_build_postfix})
|
|
|
|
|
|
|
|
# Starts building the sources tree
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
|
|
|
# Continues with howtos
|
|
|
|
if(ozz_build_howtos AND NOT EMSCRIPTEN)
|
|
|
|
add_subdirectory(howtos)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Continues with samples
|
|
|
|
if(ozz_build_samples)
|
|
|
|
add_subdirectory(samples)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Continues with the tests tree
|
|
|
|
if(ozz_build_tests AND NOT EMSCRIPTEN)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(FILES
|
|
|
|
${PROJECT_SOURCE_DIR}/CHANGES.md
|
|
|
|
${PROJECT_SOURCE_DIR}/LICENSE.md
|
|
|
|
${PROJECT_SOURCE_DIR}/README.md
|
2024-03-17 12:47:11 +01:00
|
|
|
DESTINATION "share/doc/ozz-animation/")
|