@@ -23,99 +23,101 @@ include(GNUInstallDirs)
2323# Sets up the draco install targets. Must be called after the static library
2424# target is created.
2525macro (draco_setup_install_target )
26- set (bin_path "${CMAKE_INSTALL_BINDIR} " )
27- set (data_path "${CMAKE_INSTALL_DATAROOTDIR} " )
28- set (includes_path "${CMAKE_INSTALL_INCLUDEDIR} " )
29- set (libs_path "${CMAKE_INSTALL_LIBDIR} " )
30-
31- foreach (file ${draco_sources} )
32- if (file MATCHES "h$" )
33- list (APPEND draco_api_includes ${file} )
26+ if (DRACO_INSTALL)
27+ set (bin_path "${CMAKE_INSTALL_BINDIR} " )
28+ set (data_path "${CMAKE_INSTALL_DATAROOTDIR} " )
29+ set (includes_path "${CMAKE_INSTALL_INCLUDEDIR} " )
30+ set (libs_path "${CMAKE_INSTALL_LIBDIR} " )
31+
32+ foreach (file ${draco_sources} )
33+ if (file MATCHES "h$" )
34+ list (APPEND draco_api_includes ${file} )
35+ endif ()
36+ endforeach ()
37+
38+ list (REMOVE_DUPLICATES draco_api_includes)
39+
40+ # Strip $draco_src_root from the file paths: we need to install relative to
41+ # $include_directory.
42+ list (TRANSFORM draco_api_includes REPLACE "${draco_src_root} /" "" )
43+
44+ foreach (draco_api_include ${draco_api_includes} )
45+ get_filename_component (file_directory ${draco_api_include} DIRECTORY )
46+ set (target_directory "${includes_path} /draco/${file_directory} " )
47+ install (FILES ${draco_src_root} /${draco_api_include}
48+ DESTINATION "${target_directory} " )
49+ endforeach ()
50+
51+ install (FILES "${draco_build} /draco/draco_features.h"
52+ DESTINATION "${includes_path} /draco/" )
53+
54+ install (TARGETS draco_decoder DESTINATION "${bin_path} " )
55+ install (TARGETS draco_encoder DESTINATION "${bin_path} " )
56+
57+ if (DRACO_TRANSCODER_SUPPORTED)
58+ install (TARGETS draco_transcoder DESTINATION "${bin_path} " )
3459 endif ()
35- endforeach ()
3660
37- list (REMOVE_DUPLICATES draco_api_includes)
61+ if (MSVC )
62+ install (
63+ TARGETS draco
64+ EXPORT dracoExport
65+ RUNTIME DESTINATION "${bin_path} "
66+ ARCHIVE DESTINATION "${libs_path} "
67+ LIBRARY DESTINATION "${libs_path} " )
68+ else ()
69+ install (
70+ TARGETS draco_static
71+ EXPORT dracoExport
72+ DESTINATION "${libs_path} " )
73+
74+ if (BUILD_SHARED_LIBS )
75+ install (
76+ TARGETS draco_shared
77+ EXPORT dracoExport
78+ RUNTIME DESTINATION "${bin_path} "
79+ ARCHIVE DESTINATION "${libs_path} "
80+ LIBRARY DESTINATION "${libs_path} " )
81+ endif ()
82+ endif ()
3883
39- # Strip $draco_src_root from the file paths: we need to install relative to
40- # $include_directory.
41- list ( TRANSFORM draco_api_includes REPLACE " ${draco_src_root} /" "" )
84+ if (DRACO_UNITY_PLUGIN)
85+ install ( TARGETS dracodec_unity DESTINATION " ${libs_path} " )
86+ endif ( )
4287
43- foreach (draco_api_include ${draco_api_includes} )
44- get_filename_component (file_directory ${draco_api_include} DIRECTORY )
45- set (target_directory "${includes_path} /draco/${file_directory} " )
46- install (FILES ${draco_src_root} /${draco_api_include}
47- DESTINATION "${target_directory} " )
48- endforeach ()
88+ if (DRACO_MAYA_PLUGIN)
89+ install (TARGETS draco_maya_wrapper DESTINATION "${libs_path} " )
90+ endif ()
4991
50- install (FILES "${draco_build} /draco/draco_features.h"
51- DESTINATION "${includes_path} /draco/" )
92+ # pkg-config: draco.pc
93+ configure_file ("${draco_root} /cmake/draco.pc.template"
94+ "${draco_build} /draco.pc" @ONLY NEWLINE_STYLE UNIX )
95+ install (FILES "${draco_build} /draco.pc" DESTINATION "${libs_path} /pkgconfig" )
5296
53- install (TARGETS draco_decoder DESTINATION "${bin_path} " )
54- install (TARGETS draco_encoder DESTINATION "${bin_path} " )
97+ # CMake config: draco-config.cmake
98+ configure_package_config_file (
99+ "${draco_root} /cmake/draco-config.cmake.template"
100+ "${draco_build} /draco-config.cmake"
101+ INSTALL_DESTINATION "${data_path} /cmake/draco" )
55102
56- if (DRACO_TRANSCODER_SUPPORTED)
57- install (TARGETS draco_transcoder DESTINATION "${bin_path} " )
58- endif ()
103+ write_basic_package_version_file (
104+ "${draco_build} /draco-config-version.cmake"
105+ VERSION ${DRACO_VERSION}
106+ COMPATIBILITY AnyNewerVersion )
59107
60- if (MSVC )
61- install (
62- TARGETS draco
108+ export (
63109 EXPORT dracoExport
64- RUNTIME DESTINATION "${bin_path} "
65- ARCHIVE DESTINATION "${libs_path} "
66- LIBRARY DESTINATION "${libs_path} " )
67- else ()
110+ NAMESPACE draco::
111+ FILE "${draco_build} /draco-targets.cmake" )
112+
68113 install (
69- TARGETS draco_static
70114 EXPORT dracoExport
71- DESTINATION "${libs_path} " )
72-
73- if (BUILD_SHARED_LIBS )
74- install (
75- TARGETS draco_shared
76- EXPORT dracoExport
77- RUNTIME DESTINATION "${bin_path} "
78- ARCHIVE DESTINATION "${libs_path} "
79- LIBRARY DESTINATION "${libs_path} " )
80- endif ()
81- endif ()
82-
83- if (DRACO_UNITY_PLUGIN)
84- install (TARGETS dracodec_unity DESTINATION "${libs_path} " )
85- endif ()
86-
87- if (DRACO_MAYA_PLUGIN)
88- install (TARGETS draco_maya_wrapper DESTINATION "${libs_path} " )
89- endif ()
90-
91- # pkg-config: draco.pc
92- configure_file ("${draco_root} /cmake/draco.pc.template"
93- "${draco_build} /draco.pc" @ONLY NEWLINE_STYLE UNIX )
94- install (FILES "${draco_build} /draco.pc" DESTINATION "${libs_path} /pkgconfig" )
95-
96- # CMake config: draco-config.cmake
97- configure_package_config_file (
98- "${draco_root} /cmake/draco-config.cmake.template"
99- "${draco_build} /draco-config.cmake"
100- INSTALL_DESTINATION "${data_path} /cmake/draco" )
101-
102- write_basic_package_version_file (
103- "${draco_build} /draco-config-version.cmake"
104- VERSION ${DRACO_VERSION}
105- COMPATIBILITY AnyNewerVersion )
106-
107- export (
108- EXPORT dracoExport
109- NAMESPACE draco::
110- FILE "${draco_build} /draco-targets.cmake" )
111-
112- install (
113- EXPORT dracoExport
114- NAMESPACE draco::
115- FILE draco-targets .cmake
116- DESTINATION "${data_path} /cmake/draco" )
117-
118- install (FILES "${draco_build} /draco-config.cmake"
119- "${draco_build} /draco-config-version.cmake"
120- DESTINATION "${data_path} /cmake/draco" )
115+ NAMESPACE draco::
116+ FILE draco-targets .cmake
117+ DESTINATION "${data_path} /cmake/draco" )
118+
119+ install (FILES "${draco_build} /draco-config.cmake"
120+ "${draco_build} /draco-config-version.cmake"
121+ DESTINATION "${data_path} /cmake/draco" )
122+ endif (DRACO_INSTALL )
121123endmacro ()
0 commit comments