|
| 1 | +# CMakeLists |
| 2 | +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) |
| 3 | +cmake_policy(SET CMP0079 NEW) # Allow linking with targets in other directories |
| 4 | +project( |
| 5 | + micromesh_toolkit |
| 6 | + VERSION 1.0 |
| 7 | + DESCRIPTION "Micromesh Tools" |
| 8 | + LANGUAGES C CXX) |
| 9 | + |
| 10 | +set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 11 | + |
| 12 | +set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/_install" CACHE PATH "folder in which INSTALL will put everything needed to run the binaries" FORCE) |
| 13 | + |
| 14 | +# Enable bounds and other error checking for gcc debug builds in std::vector |
| 15 | +set_directory_properties(PROPERTIES COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_GLIBCXX_DEBUG>) |
| 16 | + |
| 17 | +# Look for nvpro_core 1) as a sub-folder 2) at some other locations |
| 18 | +if(NOT BASE_DIRECTORY) |
| 19 | + find_path(BASE_DIRECTORY |
| 20 | + NAMES nvpro_core/cmake/setup.cmake |
| 21 | + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/.. |
| 22 | + REQUIRED |
| 23 | + DOC "Directory containing nvpro_core" |
| 24 | + ) |
| 25 | +endif() |
| 26 | + |
| 27 | +if(EXISTS ${BASE_DIRECTORY}/nvpro_core/cmake/setup.cmake) |
| 28 | + set(OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin_x64) |
| 29 | + include(${BASE_DIRECTORY}/nvpro_core/cmake/setup.cmake) |
| 30 | + include(${BASE_DIRECTORY}/nvpro_core/cmake/utilities.cmake) |
| 31 | +else() |
| 32 | + message(FATAL_ERROR "could not find base directory, please set BASE_DIRECTORY to folder containing nvpro_core") |
| 33 | +endif() |
| 34 | + |
| 35 | +set(NVPRO_CORE_DIR ${BASE_DIRECTORY}/nvpro_core) |
| 36 | + |
| 37 | +if(MSVC) |
| 38 | + add_definitions(/wd26812) # 'enum class' over 'enum' |
| 39 | + add_definitions(/wd26451) # Arithmetic overflow, casting 4 byte value to 8 byte value |
| 40 | +endif() |
| 41 | + |
| 42 | +#-------------------------------------------------------------------------------------------------- |
| 43 | +# Package shared by all projects |
| 44 | + |
| 45 | +# set(SUPPORT_AFTERMATH on) |
| 46 | +# _add_package_NsightAftermath() |
| 47 | +_add_package_ZLIB() |
| 48 | +_add_package_VulkanSDK() |
| 49 | +_add_package_ShaderC() |
| 50 | +_add_package_ImGUI() |
| 51 | +_add_nvpro_core_lib() |
| 52 | + |
| 53 | +_add_package_Glm() |
| 54 | +# nvpro_core hides GLM_INCLUDE_DIR, but it's commonly missing if not included with the vulkan SDK |
| 55 | +mark_as_advanced(CLEAR GLM_INCLUDE_DIR) |
| 56 | +if(NOT GLM_FOUND) |
| 57 | + message(FATAL_ERROR "GLM not found. Aborting. Set `GLM_INCLUDE_DIR` or include `GLM` with the Vulkan SDK install") |
| 58 | +endif() |
| 59 | + |
| 60 | +set(COMMON_DIR ${CMAKE_CURRENT_SOURCE_DIR}/common) |
| 61 | + |
| 62 | +# Override BARY_CORE_BUILD_UTILS. bary_utils is needed by meshops_core |
| 63 | +set(BARY_CORE_BUILD_UTILS "ON" CACHE INTERNAL "meshops_core requires bary_utils") |
| 64 | + |
| 65 | +function(find_first RESULT NAME) |
| 66 | + foreach(DIR ${ARGN}) |
| 67 | + if(EXISTS ${DIR}) |
| 68 | + message(STATUS "Dependency ${NAME} found at ${DIR}") |
| 69 | + set(${RESULT} ${DIR} PARENT_SCOPE) |
| 70 | + return() |
| 71 | + else() |
| 72 | + message(STATUS "Dependency ${NAME} not found at ${DIR}") |
| 73 | + endif() |
| 74 | + endforeach() |
| 75 | + message(FATAL_ERROR "${NAME} not found") |
| 76 | +endfunction() |
| 77 | + |
| 78 | +find_first(PATH_BARY_CORE Displacement-MicroMap-BaryFile |
| 79 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-BaryFile |
| 80 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/bary_core |
| 81 | + ${CMAKE_CURRENT_SOURCE_DIR}/../bary_core |
| 82 | + ${CMAKE_CURRENT_SOURCE_DIR}/../sdk/bary_core |
| 83 | + ) |
| 84 | +add_subdirectory(${PATH_BARY_CORE} ${CMAKE_BINARY_DIR}/bary_core) |
| 85 | + |
| 86 | +find_first(PATH_MICROMESH_CORE Displacement-MicroMap-SDK/micromesh_core |
| 87 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_core |
| 88 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_core |
| 89 | + ${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_core |
| 90 | + ${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_core |
| 91 | + ) |
| 92 | +add_subdirectory(${PATH_MICROMESH_CORE} ${CMAKE_BINARY_DIR}/micromesh_core) |
| 93 | + |
| 94 | +find_first(PATH_SDK_COMPRESSION Displacement-MicroMap-SDK/micromesh_displacement_compression |
| 95 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_displacement_compression |
| 96 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_displacement_compression |
| 97 | + ${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_displacement_compression |
| 98 | + ${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_displacement_compression |
| 99 | + ) |
| 100 | +add_subdirectory(${PATH_SDK_COMPRESSION} ${CMAKE_BINARY_DIR}/micromesh_displacement_compression) |
| 101 | + |
| 102 | +find_first(PATH_SDK_REMESHING Displacement-MicroMap-SDK/micromesh_displacement_remeshing |
| 103 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/Displacement-MicroMap-SDK/micromesh_displacement_remeshing |
| 104 | + ${CMAKE_CURRENT_SOURCE_DIR}/external/micromesh_displacement_remeshing |
| 105 | + ${CMAKE_CURRENT_SOURCE_DIR}/../micromesh_displacement_remeshing |
| 106 | + ${CMAKE_CURRENT_SOURCE_DIR}/../sdk/micromesh_displacement_remeshing |
| 107 | + ) |
| 108 | +add_subdirectory(${PATH_SDK_REMESHING} ${CMAKE_BINARY_DIR}/micromesh_displacement_remeshing) |
| 109 | + |
| 110 | +### |
| 111 | +# Custom build modifications for libpng. |
| 112 | +option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" ON) |
| 113 | +option(PNG_EXECUTABLES "Build libpng executables" OFF) |
| 114 | +option(PNG_SHARED "Build shared PNG lib" OFF) |
| 115 | +option(PNG_TESTS "Build libpng tests" OFF) |
| 116 | +set(SKIP_INSTALL_ALL ON) # Skip all libpng install targets |
| 117 | +# This is a bit of a hack: we must include zlibstatic from nvpro_core, so we |
| 118 | +# must also turn off libpng's build configuration (since this configuration |
| 119 | +# fails on WSL, and since it produces a compile-time error if the detected zlib |
| 120 | +# version doesn't match nvpro_core's zlib version). To do this, we set IOS |
| 121 | +# around libpng's CMake files. |
| 122 | +set(IOS ON) |
| 123 | +add_subdirectory(external/libpng) |
| 124 | +unset(IOS) |
| 125 | +target_link_libraries(png_static zlibstatic) |
| 126 | +target_include_directories(png_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/external/libpng> ${CMAKE_CURRENT_LIST_DIR}/external/libpng) |
| 127 | +### |
| 128 | +add_subdirectory(external/tinyexr) |
| 129 | +add_subdirectory(meshops_core) |
| 130 | +add_subdirectory(meshops_bake) |
| 131 | +add_subdirectory(meshops_remesher) |
| 132 | +add_subdirectory(mini_samples) |
| 133 | +add_subdirectory(micromesh_tool) |
| 134 | +add_subdirectory(micromesh_python) |
| 135 | +add_subdirectory(micromesh_toolbox) |
| 136 | + |
| 137 | +# Enable some additional warnings for micromesh toolkit projects Attempt to |
| 138 | +# match warnings between different compilers |
| 139 | +if(WIN32) # Windows |
| 140 | + set(MICROMESH_COMPILE_WARNINGS |
| 141 | + ) |
| 142 | +else() # Linux |
| 143 | + set(MICROMESH_COMPILE_WARNINGS |
| 144 | + -Wsign-compare |
| 145 | + -Wconversion |
| 146 | + ) |
| 147 | +endif() |
| 148 | + |
| 149 | +# Add per-source file compile options because many third party dependencies |
| 150 | +# are not compatible with more strict warnings. |
| 151 | +foreach(TARGET |
| 152 | + meshops_core |
| 153 | + meshops_bake |
| 154 | + meshops_remesher |
| 155 | + dmm_displacement |
| 156 | + micromesh_tool_lib |
| 157 | + micromesh_tool |
| 158 | + micromesh_python |
| 159 | + micromesh_toolbox |
| 160 | + ) |
| 161 | + if (TARGET ${TARGET}) |
| 162 | + set_property(TARGET ${TARGET} APPEND PROPERTY COMPILE_OPTIONS ${MICROMESH_COMPILE_WARNINGS}) |
| 163 | + endif() |
| 164 | +endforeach() |
| 165 | + |
| 166 | +set_target_properties(bary_core PROPERTIES FOLDER "bary_libs") |
| 167 | +set_target_properties(bary_utils PROPERTIES FOLDER "bary_libs") |
| 168 | + |
| 169 | +set_target_properties(meshops_core PROPERTIES FOLDER "meshops_libs") |
| 170 | +set_target_properties(meshops_bake PROPERTIES FOLDER "meshops_libs") |
| 171 | +set_target_properties(meshops_remesher PROPERTIES FOLDER "meshops_libs") |
| 172 | + |
| 173 | +set_target_properties(micromesh_core PROPERTIES FOLDER "micromesh_libs") |
| 174 | +set_target_properties(micromesh_displacement_compression PROPERTIES FOLDER "micromesh_libs") |
| 175 | +set_target_properties(micromesh_displacement_remeshing PROPERTIES FOLDER "micromesh_libs") |
| 176 | + |
| 177 | +set_target_properties(micromesh_tool_lib PROPERTIES FOLDER "tool_libs") |
| 178 | +if (TARGET micromesh_python) |
| 179 | + set_target_properties(micromesh_python PROPERTIES FOLDER "tool_libs") |
| 180 | +endif() |
| 181 | + |
| 182 | +set_target_properties(micromesh_tool PROPERTIES FOLDER "tools") |
| 183 | +set_target_properties(micromesh_toolbox PROPERTIES FOLDER "tools") |
| 184 | + |
| 185 | +set_target_properties(nvpro_core PROPERTIES FOLDER "ThirdParty") |
| 186 | +set_target_properties(tinyexr PROPERTIES FOLDER "ThirdParty") |
| 187 | +set_target_properties(png_static PROPERTIES FOLDER "ThirdParty") |
| 188 | +set_target_properties(genfiles PROPERTIES FOLDER "ThirdParty") # From libpng |
| 189 | + |
| 190 | +install(DIRECTORY "media" DESTINATION ${CMAKE_INSTALL_BINDIR}) |
0 commit comments