Skip to content

Commit

Permalink
Sync with ff7373f (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
HasKha committed Apr 4, 2024
1 parent 38be0f8 commit fff2d84
Show file tree
Hide file tree
Showing 264 changed files with 4,264 additions and 1,502 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ else()
set(BUILD_SHARED_LIBS OFF)
endif()

if(BUILD_SHARED_LIBS)
message(WARNING
"You are building Lagrange as a shared library. This is generally discouraged. You are responsible for "
"configuring any Lagrange dependency as a shared library itself. Anything that Lagrange pulls itself is not "
"guaranteed to be compiled as a shared library."
)
endif()

# Specific override for building on Jenkins
if(LAGRANGE_JENKINS)
# IPO is very slow and not needed for CI purposes
Expand Down Expand Up @@ -247,7 +255,7 @@ endif()
set(LAGRANGE_IDE_PREFIX ${LAGRANGE_IDE_PREFIX_DEFAULT} CACHE STRING "Folder prefix for Lagrange targets in MSVC/Xcode")

# When building python module, compile MKL/TBB as a shared library
if(LAGRANGE_MODULE_PYTHON OR LAGRANGE_ALL)
if(LAGRANGE_MODULE_PYTHON OR LAGRANGE_ALL OR BUILD_SHARED_LIBS)
set(MKL_LINKING "dynamic" CACHE STRING "Linking strategy to use with MKL (static, dynamic or sdl)")
option(TBB_PREFER_STATIC "Build with static TBB" OFF)
endif()
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.20.1
6.21.0
30 changes: 27 additions & 3 deletions cmake/lagrange/lagrange_add_module.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function(lagrange_add_module)
get_filename_component(module_name "${module_path}" NAME)

# Retrieve options
set(options INTERFACE)
set(options INTERFACE NO_INSTALL)
set(oneValueArgs "")
set(multiValueArgs "")
cmake_parse_arguments(OPTIONS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand Down Expand Up @@ -43,10 +43,29 @@ function(lagrange_add_module)

# Target sources
file(GLOB_RECURSE INC_FILES "include/*.h")
file(GLOB_RECURSE SRC_FILES "src/*.cpp")
file(GLOB_RECURSE SRC_FILES "src/*.cpp" "src/*.h")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include/" PREFIX "Header Files" FILES ${INC_FILES})
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src/" PREFIX "Source Files" FILES ${SRC_FILES})
target_sources(lagrange_${module_name} PRIVATE ${INC_FILES} ${SRC_FILES})
message(STATUS "Module ${module_name} using scope: ${module_scope}")
target_sources(lagrange_${module_name}
PRIVATE
${SRC_FILES}
PUBLIC
FILE_SET HEADERS
BASE_DIRS
include
FILES
${INC_FILES}
)

# Export headers for shared libraries
if(NOT OPTIONS_INTERFACE)
string(TOUPPER ${module_name} uc_module_name)
get_target_property(module_type lagrange_${module_name} TYPE)
if(module_type STREQUAL "STATIC_LIBRARY")
target_compile_definitions(lagrange_${module_name} PUBLIC "LA_${uc_module_name}_STATIC_DEFINE")
endif()
endif()

# Target folder for IDE
set_target_properties(lagrange_${module_name} PROPERTIES FOLDER "${LAGRANGE_IDE_PREFIX}Lagrange/Modules")
Expand All @@ -57,4 +76,9 @@ function(lagrange_add_module)
target_code_coverage(lagrange_${module_name} ${module_scope} AUTO ALL EXCLUDE "${FETCHCONTENT_BASE_DIR}/*")
endif()

# Create install rules
if(LAGRANGE_INSTALL AND NOT OPTIONS_NO_INSTALL)
lagrange_install(lagrange_${module_name})
endif()

endfunction()
14 changes: 14 additions & 0 deletions cmake/lagrange/lagrange_add_python_binding.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,19 @@ function(lagrange_add_python_binding)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

# Add scripts if any
if(SKBUILD)
if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/scripts)
MESSAGE(STATUS "Adding scripts for module ${module_name}")
MESSAGE(STATUS ${SKBUILD_SCRIPTS_DIR})
file(GLOB_RECURSE SCRIPTS ${CMAKE_CURRENT_LIST_DIR}/scripts/*)
install(PROGRAMS ${SCRIPTS}
DESTINATION ${SKBUILD_SCRIPTS_DIR}
COMPONENT Lagrange_Python_Runtime
)
endif()
endif()

# Keep track of active modules
set_property(TARGET lagrange_python APPEND PROPERTY LAGRANGE_ACTIVE_MODULES ${module_name})
endfunction()
10 changes: 5 additions & 5 deletions cmake/lagrange/lagrange_install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# governing permissions and limitations under the License.
#
function(lagrange_install target)
string(REPLACE "lagrange_" "" module_name ${target})
set_target_properties(${target} PROPERTIES EXPORT_NAME ${module_name})

include(GNUInstallDirs)
install(TARGETS ${target}
EXPORT Lagrange_Targets
Expand All @@ -22,13 +25,10 @@ function(lagrange_install target)
COMPONENT Lagrange_Runtime
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT Lagrange_Development
FILE_SET HEADERS
COMPONENT Lagrange_Development
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(DIRECTORY include/lagrange
DESTINATION include
COMPONENT Lagrange_Development
)

# TODO: Maybe set PUBLIC_HEADER target property (for macOS framework installation)
endfunction()
20 changes: 12 additions & 8 deletions cmake/lagrange/lagrange_runtime_dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function(lagrange_prepare_runtime_dependencies target)
add_custom_command(
TARGET ${target}
PRE_LINK
COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/runtime_deps/copy_dll_${target}_$<CONFIG>.cmake"
COMMENT "Copying dlls for target ${target}"
)
endfunction()
Expand Down Expand Up @@ -117,10 +117,14 @@ function(lagrange_populate_runtime_dependencies target)

# Instruction to copy target file if it exists
string(APPEND COPY_SCRIPT_CONTENT
"if(EXISTS \"$<TARGET_FILE:${DEPENDENCY}>\")\n "
"execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "
"if(EXISTS \"$<TARGET_FILE:${DEPENDENCY}>\")\n"
" message(\"Copying dll file: $<TARGET_FILE_NAME:${DEPENDENCY}>\")\n"
" execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different "
"\"$<TARGET_FILE:${DEPENDENCY}>\" "
"\"$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_NAME:${DEPENDENCY}>\")\n"
" if(NOT EXISTS \"$<TARGET_FILE_DIR:${target}>/$<TARGET_FILE_NAME:${DEPENDENCY}>\")\n"
" message(FATAL_ERROR \"Failed to copy dll file: $<TARGET_FILE_NAME:${DEPENDENCY}>\")\n"
" endif()\n"
"endif()\n"
)

Expand All @@ -135,19 +139,19 @@ function(lagrange_populate_runtime_dependencies target)
get_filename_component(resourceDir resourceDst DIRECTORY)
string(APPEND COPY_SCRIPT_CONTENT
"if(EXISTS \"$<TARGET_FILE:${DEPENDENCY}>\")\n"
" execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "
" execute_process(COMMAND \"${CMAKE_COMMAND}\" -E make_directory "
"\"$<TARGET_FILE_DIR:${target}>/${resourceDir}\")\n"
" execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "
" execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different "
"\"${resourceSrc}\" "
"\"$<TARGET_FILE_DIR:${target}>/${resourceDst}\")\n"
"endif()\n"
)
endforeach()
string(APPEND COPY_SCRIPT_CONTENT
"if(EXISTS \"$<TARGET_FILE:${DEPENDENCY}>\")\n"
" execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "
" execute_process(COMMAND \"${CMAKE_COMMAND}\" -E make_directory "
"\"$<TARGET_FILE_DIR:${target}>/usd\")\n"
" execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "
" execute_process(COMMAND \"${CMAKE_COMMAND}\" -E copy_if_different "
"\"${usd_BINARY_DIR}/usd_plugInfo.json\" "
"\"$<TARGET_FILE_DIR:${target}>/usd/plugInfo.json\")\n"
"endif()\n"
Expand Down
2 changes: 1 addition & 1 deletion cmake/lagrange/lagrange_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ add_library(lagrange::warnings ALIAS lagrange_warnings)

# installation
set_target_properties(lagrange_warnings PROPERTIES EXPORT_NAME warnings)
install(TARGETS lagrange_warnings EXPORT Lagrange_Targets)
install(TARGETS lagrange_warnings EXPORT Lagrange_Targets FILE_SET HEADERS)

include(lagrange_filter_flags)

Expand Down
15 changes: 9 additions & 6 deletions cmake/recipes/external/gl3w.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ endif()

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

include(CPM)
CPMAddPackage(
NAME gl3w
GITHUB_REPOSITORY adobe/lagrange-gl3w
GIT_TAG a9e41479e30266cecb72df413f4f6d71b0228a71
)
block()
set(BUILD_SHARED_LIBS OFF)
include(CPM)
CPMAddPackage(
NAME gl3w
GITHUB_REPOSITORY adobe/lagrange-gl3w
GIT_TAG a9e41479e30266cecb72df413f4f6d71b0228a71
)
endblock()

add_library(gl3w::gl3w ALIAS gl3w)

Expand Down
16 changes: 10 additions & 6 deletions cmake/recipes/external/imgui.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ endif()

message(STATUS "Third-party (external): creating target 'imgui::imgui' ('docking' branch)")

include(CPM)
CPMAddPackage(
NAME imgui
GITHUB_REPOSITORY adobe/imgui
GIT_TAG 447d0a713c635584471bd5bed3ebecdf953c0b5c # docking_v1.89.3
)
block()
set(BUILD_SHARED_LIBS OFF)
include(CPM)
CPMAddPackage(
NAME imgui
GITHUB_REPOSITORY adobe/imgui
GIT_TAG fbaad5ad4cc881f9139c3e9fa9d5747d285b1940 # docking_v1.90.4
)
endblock()

target_compile_definitions(imgui PUBLIC IMGUI_DISABLE_OBSOLETE_KEYIO)
target_compile_definitions(imgui PUBLIC IMGUI_DEFINE_MATH_OPERATORS)

set_target_properties(imgui PROPERTIES FOLDER third_party)

Expand Down
7 changes: 5 additions & 2 deletions cmake/recipes/external/imgui_fonts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ if(NOT COMMAND fonts_add_font)

endif()

fonts_add_font(fontawesome6)
fonts_add_font(source_sans_pro_regular)
block()
set(BUILD_SHARED_LIBS OFF)
fonts_add_font(fontawesome6)
fonts_add_font(source_sans_pro_regular)
endblock()

set_target_properties(fonts_fontawesome6 PROPERTIES FOLDER third_party)
set_target_properties(fonts_source_sans_pro_regular PROPERTIES FOLDER third_party)
2 changes: 1 addition & 1 deletion cmake/recipes/external/imguizmo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CPMAddPackage(
GIT_TAG e3174578bdc99c715e51c5ad88e7d50b4eeb19b0
)

add_library(imguizmo
add_library(imguizmo STATIC
"${imguizmo_SOURCE_DIR}/ImGuizmo.h"
"${imguizmo_SOURCE_DIR}/ImGuizmo.cpp"
)
Expand Down
6 changes: 6 additions & 0 deletions cmake/recipes/external/libfive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ if(MSVC)
/bigobj
)
endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
target_compile_options(libfive PRIVATE
"-Wno-enum-constexpr-conversion"
)
endif()
set_target_properties(libfive PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_library(libfive::libfive ALIAS libfive)
set_target_properties(libfive PROPERTIES FOLDER third_party/libfive)
2 changes: 1 addition & 1 deletion cmake/recipes/external/mikktspace.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CPMAddPackage(
GIT_TAG b57786fd7aa5404904985829ef8dda445d7feac0
)

add_library(mikktspace ${mikktspace_SOURCE_DIR}/mikktspace.c)
add_library(mikktspace STATIC ${mikktspace_SOURCE_DIR}/mikktspace.c)
add_library(mikktspace::mikktspace ALIAS mikktspace)
target_include_directories(mikktspace PUBLIC ${mikktspace_SOURCE_DIR})

Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/miniz.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CPMAddPackage(
URL_MD5 bc866f2def5214188cd6481e2694bd3c
)

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

include(GNUInstallDirs)
Expand Down
16 changes: 7 additions & 9 deletions cmake/recipes/external/nanoflann.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@ CPMAddPackage(
add_library(nanoflann INTERFACE)
add_library(nanoflann::nanoflann ALIAS nanoflann)

include(GNUInstallDirs)
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"
target_sources(nanoflann PUBLIC
FILE_SET HEADERS
BASE_DIRS
"${nanoflann_SOURCE_DIR}/include"
FILES
"${nanoflann_SOURCE_DIR}/include/nanoflann.hpp"
)

set_target_properties(nanoflann PROPERTIES FOLDER "third_party")

# Install rules
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME nanoflann)
install(FILES ${nanoflann_SOURCE_DIR}/include/nanoflann.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS nanoflann EXPORT Nanoflann_Targets)
install(TARGETS nanoflann EXPORT Nanoflann_Targets FILE_SET HEADERS INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT Nanoflann_Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/nanoflann NAMESPACE nanoflann::)
2 changes: 1 addition & 1 deletion cmake/recipes/external/stb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function(stb_make_target header target_name macro_definition)
)

add_library(
${FULL_TARGET} EXCLUDE_FROM_ALL
${FULL_TARGET} STATIC EXCLUDE_FROM_ALL
${stb_BINARY_DIR}/stb_${target_name}.cpp
)
add_library(${TARGET_ALIAS} ALIAS ${FULL_TARGET})
Expand Down
17 changes: 3 additions & 14 deletions cmake/recipes/external/tbb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,15 @@ function(tbb_copy_interface_dirs target)
endforeach()
endfunction()

# Generate a dummy .cpp so we can create a "real" target that depends on both tbb and tbbmalloc
# This is needed to trick embree 3.13.0 on Windows, which tries to access the location of the target TBB::tbb
# https://github.com/embree/embree/blob/12b99393438a4cc9e478e33459eed78bec6233fd/common/tasking/CMakeLists.txt#L42
file(WRITE "${tbb_BINARY_DIR}/tbb_dummy.cpp.in" [[
namespace {
void dummy() { }
}
]])

configure_file(${tbb_BINARY_DIR}/tbb_dummy.cpp.in ${tbb_BINARY_DIR}/tbb_dummy.cpp COPYONLY)

# Meta-target that brings both tbb and tbbmalloc.
add_library(tbb_tbb ${tbb_BINARY_DIR}/tbb_dummy.cpp)
add_library(tbb_tbb INTERFACE)
add_library(TBB::tbb ALIAS tbb_tbb)
if(TBB_PREFER_STATIC)
target_link_libraries(tbb_tbb PUBLIC tbb_static tbbmalloc_static)
target_link_libraries(tbb_tbb INTERFACE tbb_static tbbmalloc_static)
tbb_fix_include_dirs(tbb_static)
tbb_copy_interface_dirs(tbb_tbb tbb_static tbbmalloc_static)
else()
target_link_libraries(tbb_tbb PUBLIC tbb tbbmalloc)
target_link_libraries(tbb_tbb INTERFACE tbb tbbmalloc)
tbb_fix_include_dirs(tbb)
tbb_copy_interface_dirs(tbb_tbb tbb tbbmalloc)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/tinyexr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CPMAddPackage(
DOWNLOAD_ONLY ON
)

add_library(tinyexr
add_library(tinyexr STATIC
${tinyexr_SOURCE_DIR}/tinyexr.h
${tinyexr_SOURCE_DIR}/tinyexr.cc
)
Expand Down
4 changes: 2 additions & 2 deletions cmake/recipes/external/tinygltf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ message(STATUS "Third-party (external): creating target 'tinygltf::tinygltf'")

# tinygltf has its own version of json and stb headers in the same folder,
# so to avoid potential conflicts we just download the one header we want.
set(TINYGLTF_VERSION "v2.8.3")
set(TINYGLTF_VERSION "v2.8.21")
set(TINYGLTF_URL "https://raw.githubusercontent.com/syoyo/tinygltf/${TINYGLTF_VERSION}/tiny_gltf.h")

include(CPM)
Expand All @@ -39,7 +39,7 @@ file(WRITE "${tinygltf_BINARY_DIR}/tinygltf.cpp.in" [[
configure_file(${tinygltf_BINARY_DIR}/tinygltf.cpp.in ${tinygltf_BINARY_DIR}/tinygltf.cpp COPYONLY)

# define library
add_library(tinygltf ${tinygltf_BINARY_DIR}/tinygltf.cpp)
add_library(tinygltf STATIC ${tinygltf_BINARY_DIR}/tinygltf.cpp)
add_library(tinygltf::tinygltf ALIAS tinygltf)
target_compile_definitions(tinygltf PRIVATE
TINYGLTF_NO_INCLUDE_JSON
Expand Down
2 changes: 1 addition & 1 deletion cmake/recipes/external/tinyobjloader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ file(WRITE "${tinyobjloader_BINARY_DIR}/tiny_obj_loader.cpp.in" [[
configure_file(${tinyobjloader_BINARY_DIR}/tiny_obj_loader.cpp.in ${tinyobjloader_BINARY_DIR}/tiny_obj_loader.cpp COPYONLY)

# Define tinyobjloader library
add_library(tinyobjloader ${tinyobjloader_BINARY_DIR}/tiny_obj_loader.cpp)
add_library(tinyobjloader STATIC ${tinyobjloader_BINARY_DIR}/tiny_obj_loader.cpp)
add_library(tinyobjloader::tinyobjloader ALIAS tinyobjloader)
set_target_properties(tinyobjloader PROPERTIES POSITION_INDEPENDENT_CODE ON)

Expand Down
4 changes: 2 additions & 2 deletions cmake/recipes/external/ufbx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ CPMAddPackage(
)

include(GNUInstallDirs)
add_library(ufbx ${ufbx_SOURCE_DIR}/ufbx.c)
add_library(ufbx STATIC ${ufbx_SOURCE_DIR}/ufbx.c)
add_library(ufbx::ufbx ALIAS ufbx)
target_include_directories(ufbx PUBLIC
target_include_directories(ufbx PUBLIC
$<BUILD_INTERFACE:${ufbx_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
Expand Down
Loading

0 comments on commit fff2d84

Please sign in to comment.