igl_install.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function(igl_install module_name)
  2. if(NOT LIBIGL_INSTALL)
  3. return()
  4. endif()
  5. # Check if category is `copyleft` or `restricted`
  6. if(${module_name} MATCHES "^igl_copyleft")
  7. set(suffix "_copyleft")
  8. elseif(${module_name} MATCHES "^igl_restricted")
  9. set(suffix "_restricted")
  10. else()
  11. set(suffix "")
  12. endif()
  13. ########################
  14. # Install CMake target #
  15. ########################
  16. set_property(TARGET ${module_name} PROPERTY EXPORT_NAME ${module_export})
  17. include(GNUInstallDirs)
  18. install(TARGETS ${module_name}
  19. EXPORT LibiglTargets${suffix}
  20. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  21. COMPONENT LibiglRuntime
  22. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  23. COMPONENT LibiglRuntime
  24. NAMELINK_COMPONENT LibiglDevelopment
  25. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  26. COMPONENT LibiglRuntime
  27. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  28. COMPONENT LibiglDevelopment
  29. INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  30. )
  31. ###################
  32. # Install headers #
  33. ###################
  34. # TODO: When moving module definition to their own CMakeLists.txt, we should
  35. # refactor this to use the folder where the target was defined (via the
  36. # target property SOURCE_DIR).
  37. set(target_include_dir ${libigl_SOURCE_DIR}/include)
  38. foreach(source_path IN ITEMS ${ARGN})
  39. # Filter out .cpp files in "static lib" mode
  40. if(LIBIGL_USE_STATIC_LIBRARY)
  41. get_filename_component(extension ${source_path} LAST_EXT)
  42. if(extension MATCHES ".cpp")
  43. continue()
  44. endif()
  45. endif()
  46. # Compute relative path to copy
  47. get_filename_component(source_directory ${source_path} DIRECTORY)
  48. file(RELATIVE_PATH source_subdir ${target_include_dir} ${source_directory})
  49. # Create install rule to copy specific header
  50. install(
  51. FILES ${source_path}
  52. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${source_subdir}
  53. )
  54. endforeach()
  55. endfunction()