Files
Hoops_Exchange/cmake/MeshViewerDependenciesConfig.cmake
2025-12-15 23:22:33 +08:00

108 lines
2.8 KiB
CMake

#[=======================================================================[
MeshViewerDependenciesConfig.cmake
----------------
CMake module to find MeshViewerDependencies library and include directories.
Usage
-----
find_package(MeshViewerDependencies)
Target
---------
MeshViewerDependencies: INTERFACE target to link against.
Author
------
TechSoft3D
#]=======================================================================]
find_path(GLAD_INCLUDE_DIR
NAMES "glad"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/glad/include
${CMAKE_CURRENT_BINARY_DIR}/external/glad/include
)
find_path(GLM_INCLUDE_DIR
NAMES "glm"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/glm/include
${CMAKE_CURRENT_BINARY_DIR}/external/glm/include
)
find_path(GLFW_INCLUDE_DIR
NAMES "GLFW"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/GLFW/include
${CMAKE_CURRENT_BINARY_DIR}/external/GLFW/include
)
find_path(PUGI_INCLUDE_DIR
NAMES "pugixml.hpp"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/pugixml/include
${CMAKE_CURRENT_BINARY_DIR}/external/pugixml/include
)
# MeshViewer available only on x86 and x64
if(${CMAKE_SIZEOF_VOID_P} EQUAL 4)
set(hoops_arch_dir "x86")
else()
set(hoops_arch_dir "x86_64")
endif()
find_library(GLAD_LIBRARY
NAMES "glad"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/glad/lib/${hoops_arch_dir}
${CMAKE_CURRENT_BINARY_DIR}/external/glad/lib/${hoops_arch_dir}
)
find_library(GLFW_LIBRARY
NAMES glfw glfw3dll
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/GLFW/lib/${hoops_arch_dir}
${CMAKE_CURRENT_BINARY_DIR}/external/GLFW/lib/${hoops_arch_dir}
)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .dll)
find_library(GLFW_LIBRARY_DLL
NAMES "glfw3"
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/external/GLFW/dll/${hoops_arch_dir}
${CMAKE_CURRENT_BINARY_DIR}/external/GLFW/dll/${hoops_arch_dir}
)
endif()
# Create the MeshViewerDependencies target
add_library(MeshViewerDependencies INTERFACE)
# Set include directories
target_include_directories(MeshViewerDependencies INTERFACE
${GLAD_INCLUDE_DIR}
${GLM_INCLUDE_DIR}
${GLFW_INCLUDE_DIR}
${PUGI_INCLUDE_DIR}
)
# Set libraries to link
target_link_libraries(MeshViewerDependencies INTERFACE
${GLAD_LIBRARY}
${GLFW_LIBRARY}
${CMAKE_DL_LIBS}
)
# Check if the target is correctly configured
if(TARGET MeshViewerDependencies)
set(MeshViewer_FOUND TRUE)
message(STATUS "MeshViewerDependencies found")
else()
set(MeshViewer_FOUND FALSE)
if(MeshViewerDependencies_FIND_REQUIRED)
message(FATAL_ERROR "MeshViewerDependencies not found (required)")
else()
message(WARNING "MeshViewerDependencies not found")
endif()
message(STATUS "MeshViewerDependencies not found")
endif()