Skip to content

Commit

Permalink
Sync with 0c9715b
Browse files Browse the repository at this point in the history
  • Loading branch information
HasKha committed Dec 13, 2021
1 parent 2a49d3e commit aeebd56
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 76 deletions.
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if(LAGRANGE_WITH_CCACHE AND CCACHE_PROGRAM)
endif()

################################################################################
project(Lagrange VERSION 5.5.0)
project(Lagrange VERSION 5.6.0)

# Detects whether internal libs are available
if(IS_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/recipes/internal")
Expand Down Expand Up @@ -148,15 +148,23 @@ list(PREPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/lagrange/")

# Lagrange folder prefix for IDE
if(LAGRANGE_TOPLEVEL_PROJECT)
set(LAGRANGE_IDE_PREFIX "")
set(LAGRANGE_IDE_PREFIX_DEFAULT "")
else()
set(LAGRANGE_IDE_PREFIX "third_party/")
set(LAGRANGE_IDE_PREFIX_DEFAULT "third_party/")
endif()
set(LAGRANGE_IDE_PREFIX ${LAGRANGE_IDE_PREFIX_DEFAULT} CACHE STRING "Folder prefix for Lagrange targets in MSVC/Xcode")

# Register project source/binary dir in global properties, so they can be
# retrieved from Lagrange CMake functions when called by client code.
set_property(GLOBAL PROPERTY __lagrange_source_dir ${PROJECT_SOURCE_DIR})
set_property(GLOBAL PROPERTY __lagrange_binary_dir ${PROJECT_BINARY_DIR})

include(lagrange_add_example)
include(lagrange_add_executable)
include(lagrange_add_module)
include(lagrange_add_performance)
include(lagrange_add_test)
include(lagrange_download_data)
include(lagrange_global_flags)
include(lagrange_include_modules)
include(lagrange_install)
Expand Down
133 changes: 68 additions & 65 deletions cmake/lagrange/lagrange_download_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,78 @@
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
function(lagrange_download_data)
get_property(lagrange_source_dir GLOBAL PROPERTY __lagrange_source_dir)

# Data folder path can be overriden by the user
set(LAGRANGE_DATA_FOLDER "${PROJECT_SOURCE_DIR}/data"
CACHE PATH
"Where should Lagrange download and look for test data?"
)
message(STATUS "Using test data folder: ${LAGRANGE_DATA_FOLDER}")

if(LAGRANGE_EXTERNAL_ONLY)
# For now we use CMake ExternalProject to git clone the repository containing the test data.
# In the future we might switch to another provider and download each file directy.
include(ExternalProject)
include(FetchContent)
ExternalProject_Add(
lagrange-test-data
PREFIX "${FETCHCONTENT_BASE_DIR}/lagrange-test-data"
SOURCE_DIR ${LAGRANGE_DATA_FOLDER}
GIT_REPOSITORY https://github.com/adobe/lagrange-test-data.git
GIT_TAG 921e4ba12179d87b8bdcf89a61a2e95027107552
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
# Data folder path can be overriden by the user
set(LAGRANGE_DATA_FOLDER "${lagrange_source_dir}/data"
CACHE PATH
"Where should Lagrange download and look for test data?"
)
message(STATUS "Using test data folder: ${LAGRANGE_DATA_FOLDER}")

# Create a dummy target for convenience
add_custom_target(lagrange_download_data)
set_target_properties(lagrange_download_data PROPERTIES FOLDER "Lagrange//Utils")
else()
# Corp version, we automatically download test data via Artifactory
file(STRINGS "${PROJECT_SOURCE_DIR}/scripts/manifest.txt" FILE_LIST)
unset(DATA_DEPENDS)
foreach(entry IN ITEMS ${FILE_LIST})
separate_arguments(entry UNIX_COMMAND ${entry})
list(GET entry 0 local_relpath)
list(GET entry 1 remote_path)
list(GET entry 2 checksum)
set(local_path "${LAGRANGE_DATA_FOLDER}/${local_relpath}")

add_custom_command(
OUTPUT
${local_path}
COMMAND
${CMAKE_COMMAND} -P
"${PROJECT_SOURCE_DIR}/cmake/recipes/internal/artifactory.cmake"
"https://artifactory.corp.adobe.com/artifactory/generic-lagrange-test/main"
"${LAGRANGE_DATA_FOLDER}"
"${local_relpath}"
"${remote_path}"
"${checksum}"
"${LAGRANGE_ARTIFACTORY_KEYFILE}"
COMMENT
"Downloading file ${local_path}"
VERBATIM
if(LAGRANGE_EXTERNAL_ONLY)
# For now we use CMake ExternalProject to git clone the repository containing the test data.
# In the future we might switch to another provider and download each file directy.
include(ExternalProject)
include(FetchContent)
ExternalProject_Add(
lagrange-test-data
PREFIX "${FETCHCONTENT_BASE_DIR}/lagrange-test-data"
SOURCE_DIR ${LAGRANGE_DATA_FOLDER}
GIT_REPOSITORY https://github.com/adobe/lagrange-test-data.git
GIT_TAG 921e4ba12179d87b8bdcf89a61a2e95027107552
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
)

list(APPEND DATA_DEPENDS "${local_path}")
endforeach()
# Create a dummy target for convenience
add_custom_target(lagrange_download_data)
set_target_properties(lagrange_download_data PROPERTIES FOLDER "Lagrange//Utils")
else()
# Corp version, we automatically download test data via Artifactory
file(STRINGS "${lagrange_source_dir}/scripts/manifest.txt" FILE_LIST)
unset(DATA_DEPENDS)
foreach(entry IN ITEMS ${FILE_LIST})
separate_arguments(entry UNIX_COMMAND ${entry})
list(GET entry 0 local_relpath)
list(GET entry 1 remote_path)
list(GET entry 2 checksum)
set(local_path "${LAGRANGE_DATA_FOLDER}/${local_relpath}")

# Mark all binary data as dependencies of our target
add_custom_target(
lagrange_download_data
DEPENDS ${DATA_DEPENDS}
)
set_target_properties(lagrange_download_data PROPERTIES FOLDER "Lagrange//Utils")
add_custom_command(
OUTPUT
${local_path}
COMMAND
${CMAKE_COMMAND} -P
"${lagrange_source_dir}/cmake/recipes/internal/artifactory.cmake"
"https://artifactory.corp.adobe.com/artifactory/generic-lagrange-test/main"
"${LAGRANGE_DATA_FOLDER}"
"${local_relpath}"
"${remote_path}"
"${checksum}"
"${LAGRANGE_ARTIFACTORY_KEYFILE}"
COMMENT
"Downloading file ${local_path}"
VERBATIM
)

# Tell the build system to re-run CMake when those files are updated
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${PROJECT_SOURCE_DIR}/scripts/manifest.txt
${PROJECT_SOURCE_DIR}/cmake/internal/artifactory.cmake
)
endif()
list(APPEND DATA_DEPENDS "${local_path}")
endforeach()

# Mark all binary data as dependencies of our target
add_custom_target(
lagrange_download_data
DEPENDS ${DATA_DEPENDS}
)
set_target_properties(lagrange_download_data PROPERTIES FOLDER "Lagrange//Utils")

# Tell the build system to re-run CMake when those files are updated
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${lagrange_source_dir}/scripts/manifest.txt
${lagrange_source_dir}/cmake/internal/artifactory.cmake
)
endif()
endfunction()
4 changes: 3 additions & 1 deletion cmake/lagrange/lagrange_include_modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ function(lagrange_include_modules)
endif()

if(NOT TARGET lagrange::${name})
add_subdirectory(${PROJECT_SOURCE_DIR}/modules/${name} ${PROJECT_BINARY_DIR}/modules/lagrange_${name})
get_property(lagrange_source_dir GLOBAL PROPERTY __lagrange_source_dir)
get_property(lagrange_binary_dir GLOBAL PROPERTY __lagrange_binary_dir)
add_subdirectory(${lagrange_source_dir}/modules/${name} ${lagrange_binary_dir}/modules/lagrange_${name})
endif()

if(NOT TARGET lagrange::${name})
Expand Down
5 changes: 4 additions & 1 deletion cmake/recipes/external/assimp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include(FetchContent)
FetchContent_Declare(
assimp
GIT_REPOSITORY https://github.com/assimp/assimp.git
GIT_TAG 40f9d37a38209f0dbd10b71361bc905d314f10a7
GIT_TAG b1c83f437fc3d54ec9efd6a7a1ab388a1e01bef0
)

option(BUILD_SHARED_LIBS "Build package with shared libraries." OFF)
Expand All @@ -42,6 +42,9 @@ set(Clipper_SRCS "" CACHE STRING "" FORCE)
# Disable IFC importer, since it requires clipper
option(ASSIMP_BUILD_IFC_IMPORTER "Build Assimp with IFC importer" OFF)

# Disable 3MF exporter, since it requires kuba--/zip (which wraps a modified version of miniz)
option(ASSIMP_BUILD_3MF_EXPORTER "Build Assimp with 3MF exporter" OFF)

FetchContent_MakeAvailable(assimp)

set_target_properties(assimp PROPERTIES FOLDER third_party//assimp)
Expand Down
4 changes: 4 additions & 0 deletions cmake/recipes/external/embree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ option(EMBREE_STATIC_LIB "Build Embree as a static library."
set(EMBREE_TESTING_INTENSITY 0 CACHE STRING "Intensity of testing (0 = no testing, 1 = verify and tutorials, 2 = light testing, 3 = intensive testing.")
set(EMBREE_TASKING_SYSTEM "TBB" CACHE STRING "Selects tasking system")

# The following options are necessary to ensure packed-ray support
option(EMBREE_RAY_MASK "Enable the usage of mask for packed ray." ON)
option(EMBREE_RAY_PACKETS "Enable the usage packed ray." ON)

if(APPLE)
set(EMBREE_MAX_ISA "NEON" CACHE STRING "Selects highest ISA to support.")
else()
Expand Down
46 changes: 46 additions & 0 deletions cmake/recipes/external/miniz.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright 2021 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
#
if(TARGET miniz::miniz)
return()
endif()

message(STATUS "Third-party (external): creating target 'miniz::miniz'")

include(FetchContent)
FetchContent_Declare(
miniz
URL https://github.com/richgel999/miniz/releases/download/2.2.0/miniz-2.2.0.zip
URL_MD5 bc866f2def5214188cd6481e2694bd3c
)
FetchContent_MakeAvailable(miniz)

add_library(miniz ${miniz_SOURCE_DIR}/miniz.c)
add_library(miniz::miniz ALIAS miniz)

include(GNUInstallDirs)
target_include_directories(miniz PUBLIC
$<BUILD_INTERFACE:${miniz_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

set_target_properties(miniz PROPERTIES FOLDER third_party)

target_include_directories(miniz PUBLIC
$<BUILD_INTERFACE:${miniz_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME miniz)
install(FILES ${miniz_SOURCE_DIR}/miniz.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS miniz EXPORT Miniz_Targets)
install(EXPORT Miniz_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/miniz NAMESPACE miniz::)
5 changes: 5 additions & 0 deletions cmake/recipes/external/nanoflann.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ target_include_directories(nanoflann SYSTEM INTERFACE
"$<BUILD_INTERFACE:${nanoflann_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_sources(nanoflann PRIVATE
"${nanoflann_SOURCE_DIR}/include/nanoflann.hpp"
)

set_target_properties(nanoflann PROPERTIES FOLDER "third_party")

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME nanoflann)
Expand Down
3 changes: 2 additions & 1 deletion cmake/recipes/external/onetbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ include(FetchContent)
FetchContent_Declare(
tbb
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG 1098f48187c718ef782b0aa01861184886906cf4
GIT_TAG v2021.4.0
GIT_SHALLOW TRUE
)

option(TBB_TEST "Enable testing" OFF)
Expand Down
5 changes: 2 additions & 3 deletions modules/io/include/lagrange/io/load_mesh_assimp.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ std::vector<std::unique_ptr<MeshType>> extract_meshes_assimp(const aiScene* scen
template <typename MeshType>
std::unique_ptr<MeshType> convert_mesh_assimp(const aiMesh* mesh);


std::unique_ptr<aiScene> load_scene_assimp(const lagrange::fs::path& filename)
inline std::unique_ptr<aiScene> load_scene_assimp(const lagrange::fs::path& filename)
{
Assimp::Importer importer;
const aiScene* scene = importer.ReadFile(filename.string(), 0);
Expand All @@ -58,7 +57,7 @@ std::unique_ptr<aiScene> load_scene_assimp(const lagrange::fs::path& filename)
return std::unique_ptr<aiScene>(importer.GetOrphanedScene());
}

std::unique_ptr<aiScene> load_scene_assimp_from_memory(const void* buffer, size_t size)
inline std::unique_ptr<aiScene> load_scene_assimp_from_memory(const void* buffer, size_t size)
{
Assimp::Importer importer;

Expand Down
2 changes: 1 addition & 1 deletion modules/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ target_link_libraries(lagrange_testing PUBLIC
)

# 3. test-specific properties
include(lagrange_download_data)
lagrange_download_data()
add_dependencies(lagrange_testing lagrange_download_data)

target_compile_definitions(lagrange_testing
Expand Down
5 changes: 4 additions & 1 deletion modules/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ include(nlohmann_json)
include(lagrange-assets)
include(entt)
target_link_libraries(imgui PUBLIC Eigen3::Eigen)

get_property(lagrange_source_dir GLOBAL PROPERTY __lagrange_source_dir)
target_compile_definitions(imgui PUBLIC
IMGUI_USER_CONFIG="${PROJECT_SOURCE_DIR}/modules/ui/include/lagrange/ui/imgui/imconfig.h"
IMGUI_USER_CONFIG="${lagrange_source_dir}/modules/ui/include/lagrange/ui/imgui/imconfig.h"
)

target_link_libraries(lagrange_ui
PRIVATE
lagrange::assets
Expand Down

0 comments on commit aeebd56

Please sign in to comment.