Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.idea
build
output
dist
ninjabuild
**/node_modules/**

Expand Down
146 changes: 95 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,77 @@
#
cmake_minimum_required (VERSION 3.20)

add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)

project(NauEngine)


# TODO: set enviroment variables for other platforms
if (WIN32)
execute_process( COMMAND "${CMAKE_SOURCE_DIR}/cmake/platformSpec/set_env.bat")
endif(WIN32)
execute_process(COMMAND "${CMAKE_SOURCE_DIR}/cmake/platformSpec/set_env.bat")
endif()

if(POLICY CMP0091)
if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()

if(NOT DEFINED ${NauEngineFolder})
set(NauEngineFolder "NauEngine")
endif(NOT DEFINED ${NauEngineFolder})

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output CACHE PATH "" FORCE)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
# ${CMAKE_SOURCE_DIR}/cmake/modules
${CMAKE_CURRENT_SOURCE_DIR}/cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/defaults
)


# Compiler config
set(CMAKE_CXX_STANDARD 20)
# TODO: define C standard

add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP>)

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()


# Required packages
find_package(Python REQUIRED)


# Global config
if (NOT DEFINED NauEngineFolder)
set(NauEngineFolder "NauEngine")
endif()

if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output CACHE PATH "" FORCE)
message(STATUS "Use default install folder: ${CMAKE_INSTALL_PREFIX}")
else()
message(STATUS "Defined install folder: ${CMAKE_INSTALL_PREFIX}")
endif()

if (DEFINED CMAKE_BUILD_TYPE)
message(STATUS "Build configuration: ${CMAKE_BUILD_TYPE}")
else()
if (DEFINED CMAKE_CONFIGURATION_TYPES)
message(STATUS "Use multi-configuration. Allowed configurations at build time: ${CMAKE_CONFIGURATION_TYPES}")
else()
set(CMAKE_BUILD_TYPE "Debug")
message(STATUS "Use default build configuration: ${CMAKE_BUILD_TYPE}")
endif()
endif()

if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Toolchain not selected! Please define -DCMAKE_TOOLCHAIN_FILE")
else()
cmake_path(SET CMAKE_TOOLCHAIN_FILE NORMALIZE "${CMAKE_TOOLCHAIN_FILE}")
message(STATUS "Toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/$<CONFIG>)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>)


# Nau options
option(NAU_ENGINE_KERNEL "Build kernel" ON)
option(NAU_ENGINE_MODULES "Build modules" ON)
option(NAU_ENGINE_FRAMEWORK "Build framework" ON)
Expand All @@ -41,77 +87,75 @@ option(NAU_FORCE_ENABLE_SHADER_COMPILER_TOOL "Enable build for ShaderCompilerToo
option(NAU_PACKAGE_BUILD "Enabled for packaged build" OFF)
option(NAU_MATH_USE_DOUBLE_PRECISION "Enable double precision for math" OFF)

# Global options
option(BUILD_SHARED_LIBS "Build shared libs" ON)


# Process options
if (BUILD_SHARED_LIBS)
message (STATUS "Configure for dynamic (DLL) runtime")
message(STATUS "Configure for dynamic (DLL) runtime")
else()
message (STATUS "Configure for static (monolith) runtime")
message(STATUS "Configure for static (monolith) runtime")
endif()

if (NAU_PACKAGE_BUILD)
add_definitions(-DNAU_PACKAGE_BUILD)
endif()

set(CMAKE_CXX_STANDARD 20)

find_package(Python
REQUIRED
)


include(NauCommon)
include(NauModule)
include(NauGenFunctions)
include(platformSpec/NauPlatformSetup)
if(BUILD_SHARED_LIBS)
message (STATUS "Adding UsdPackages")
include(UsdPackages)
else()
message (STATUS "Skipping UsdPackages")
endif()
include(UsdPackages)
include(CTest)
nau_check_python()

enable_testing()


# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

include(cmake/NauGitVersion.cmake)

nau_check_python()
git_check_version()

file (STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/.nauversion NAU_VERSION_STRING)
nau_set_version("${NAU_VERSION_STRING}")
message(STATUS "NAU core version: ${NAU_VERSION_MAJOR}.${NAU_VERSION_MINOR}.${NAU_VERSION_PATCH}")

enable_testing()

configure_file("run_tests.bat.in" "${CMAKE_SOURCE_DIR}/run_tests.bat")

add_subdirectory(engine)
add_subdirectory(tools)
add_subdirectory(samples)

nau_generate_es_targets()

configure_file("run_tests.bat.in" "${CMAKE_SOURCE_DIR}/run_tests.bat")

install(DIRECTORY cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}
FILES_MATCHING
PATTERN "*.cmake"
PATTERN "*.bat"
# Install
foreach(_folder cmake/defaults cmake/platformSpec cmake/_scripts)
install(DIRECTORY ${_folder}
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
FILES_MATCHING
PATTERN "*.cmake"
PATTERN "*.bat"
PATTERN "*.py"
)
endforeach()
install(FILES
cmake/NauCommon.cmake
cmake/NauGenFunctions.cmake
cmake/NauGitVersion.cmake
cmake/NauModule.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake
)

install(DIRECTORY cmake/for_build/
DESTINATION ${CMAKE_INSTALL_PREFIX}
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
install(DIRECTORY project_templates
DESTINATION ${CMAKE_INSTALL_PREFIX}
)

install(CODE "
message(STATUS \"Installing USD plugins from ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/plugins to ${CMAKE_INSTALL_PREFIX}/bin/$<CONFIG>/plugins\")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/plugins ${CMAKE_INSTALL_PREFIX}/bin/$<CONFIG>/plugins)
")

install(DIRECTORY DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/$<CONFIG>/plugins) # always create plugins folder
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/$<CONFIG>/plugins/
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/$<CONFIG>/plugins
OPTIONAL
)
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"CMAKE_EXPORT_COMPILE_COMMANDS": true,
"CMAKE_SYSTEM_VERSION": "10.0",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"NAU_BUILD_SDK": true,
"BUILD_SHARED_LIBS": false,
"EASTL_BUILD_BENCHMARK": false,
"EASTL_BUILD_TESTS": false,
Expand Down
24 changes: 20 additions & 4 deletions cmake/NauCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,30 @@ function(nau_install target subPath)
install(TARGETS ${target}
EXPORT ${target}
RUNTIME DESTINATION "bin/$<CONFIG>"
ARCHIVE DESTINATION "lib/$<CONFIG>/${subPath}/${target}"
LIBRARY DESTINATION "lib/$<CONFIG>/${subPath}/${target}"
ARCHIVE DESTINATION "lib/$<CONFIG>"
LIBRARY DESTINATION "lib/$<CONFIG>"
PUBLIC_HEADER DESTINATION "include/${subPath}/${target}"
)

get_target_property(Target_BINARY_DIR ${target} BINARY_DIR)
get_target_property(Target_SOURCE_DIR ${target} SOURCE_DIR)
foreach(include ${ARGN})
get_filename_component(dir ${include} DIRECTORY)
INSTALL(FILES ${include} DESTINATION "include/${subPath}/${target}/${dir}")
cmake_path(IS_ABSOLUTE dir isDirAbs)
if(${isDirAbs})
cmake_path(IS_PREFIX Target_BINARY_DIR ${dir} isBinDir)
cmake_path(IS_PREFIX Target_SOURCE_DIR ${dir} isSourceDir)
if(${isBinDir})
cmake_path(RELATIVE_PATH dir BASE_DIRECTORY ${Target_BINARY_DIR})
INSTALL(FILES ${include} DESTINATION "include/${subPath}/${target}/${dir}")
elseif(${isSourceDir})
cmake_path(RELATIVE_PATH dir BASE_DIRECTORY ${Target_SOURCE_DIR})
INSTALL(FILES ${include} DESTINATION "include/${subPath}/${target}/${dir}")
else()
message(FATAL_ERROR "Unsupported install directory!")
endif()
else()
INSTALL(FILES ${include} DESTINATION "include/${subPath}/${target}/${dir}")
endif()
endforeach(include)

install(EXPORT ${target}
Expand Down
4 changes: 2 additions & 2 deletions cmake/NauModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ macro(nau_generate_module_config_file targetName)
)

target_include_directories(${targetName} PUBLIC
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/${targetName}/generated>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/generated/${targetName}>
)

target_compile_definitions(${targetName} PUBLIC
"NAU_${moduleUpper}_EXPORT="
)

install(FILES ${GEN_PATH} DESTINATION "include/${targetName}/generated")
install(FILES ${GEN_PATH} DESTINATION "include/generated/${targetName}")

message(NOTICE "nau_generate_module_config_file finished")
endmacro()
Expand Down
28 changes: 19 additions & 9 deletions cmake/defaults/UsdPackages.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
# file to find packages
include(FetchContent)
FetchContent_Declare(
Usd
URL https://cdn.nauengine.org/s3/naungn-portal-prod/documents/usd24.08_no_Hydra.zip
SOURCE_DIR exdeps/usd
)
FetchContent_MakeAvailable(Usd)
FetchContent_GetProperties(Usd SOURCE_DIR UsdDir)

cmake_path(SET pxr_DIR NORMALIZE "${UsdDir}")
if(DEFINED pxr_DIR)
message(STATUS "Defined pxr directory: ${pxr_DIR}")
cmake_path(SET pxr_DIR NORMALIZE "${pxr_DIR}")
else()
message(STATUS "Fetching pxr OpenUSD...")
FetchContent_Declare(
Usd
URL https://cdn.nauengine.org/s3/naungn-portal-prod/documents/usd24.08_no_Hydra.zip
SOURCE_DIR exdeps/usd
)
FetchContent_MakeAvailable(Usd)
FetchContent_GetProperties(Usd SOURCE_DIR UsdDir)

cmake_path(SET pxr_DIR NORMALIZE "${UsdDir}")
endif()

set(Python3_EXECUTABLE "${pxr_DIR}/python/python.exe")
set(Python3_LIBRARY "${pxr_DIR}/python/libs/python310.lib")
Expand Down Expand Up @@ -55,7 +62,10 @@ function(nau_process_usd_schema target shemaFile output_files)
WORKING_DIRECTORY "${OUTPUT_DIR}"
)
endif()
target_include_directories(${target} PUBLIC ${OUTPUT_BASE})
target_include_directories(${target} PUBLIC
$<BUILD_INTERFACE:${OUTPUT_BASE}>
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/generated_src/schema_plugins>
)
nau_collect_files(${output_files}
DIRECTORIES ${OUTPUT_DIR}
MASK "*.cpp" "*.h" "*.usda" "*.json"
Expand Down
Loading