]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/ports/ignition-modularscripts/ignition_modular_library.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / ports / ignition-modularscripts / ignition_modular_library.cmake
CommitLineData
1e59de90
TL
1
2function(ignition_modular_build_library NAME MAJOR_VERSION SOURCE_PATH CMAKE_PACKAGE_NAME DEFAULT_CMAKE_PACKAGE_NAME IML_DISABLE_PKGCONFIG_INSTALL)
3 vcpkg_configure_cmake(
4 SOURCE_PATH ${SOURCE_PATH}
5 PREFER_NINJA
6 DISABLE_PARALLEL_CONFIGURE
7 OPTIONS -DBUILD_TESTING=OFF
8 )
9
10 vcpkg_install_cmake(ADD_BIN_TO_PATH)
11
12 # If necessary, move the CMake config files
13 if(EXISTS "${CURRENT_PACKAGES_DIR}/lib/cmake")
14 # Some ignition libraries install library subcomponents, that are effectively additional cmake packages
15 # with name ${CMAKE_PACKAGE_NAME}-${COMPONENT_NAME}, so it is needed to call vcpkg_fixup_cmake_targets for them as well
16 file(GLOB COMPONENTS_CMAKE_PACKAGE_NAMES
17 LIST_DIRECTORIES TRUE
18 RELATIVE "${CURRENT_PACKAGES_DIR}/lib/cmake/"
19 "${CURRENT_PACKAGES_DIR}/lib/cmake/*")
20
21 foreach(COMPONENT_CMAKE_PACKAGE_NAME IN LISTS COMPONENTS_CMAKE_PACKAGE_NAMES)
22 vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/${COMPONENT_CMAKE_PACKAGE_NAME}"
23 TARGET_PATH "share/${COMPONENT_CMAKE_PACKAGE_NAME}"
24 DO_NOT_DELETE_PARENT_CONFIG_PATH)
25 endforeach()
26
27 file(GLOB_RECURSE CMAKE_RELEASE_FILES
28 "${CURRENT_PACKAGES_DIR}/lib/cmake/${CMAKE_PACKAGE_NAME}/*")
29
30 file(COPY ${CMAKE_RELEASE_FILES} DESTINATION
31 "${CURRENT_PACKAGES_DIR}/share/${CMAKE_PACKAGE_NAME}/")
32 endif()
33
34 # Remove unused files files
35 file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake
36 ${CURRENT_PACKAGES_DIR}/debug/include
37 ${CURRENT_PACKAGES_DIR}/debug/lib/cmake
38 ${CURRENT_PACKAGES_DIR}/debug/share)
39
40 # Make pkg-config files relocatable
41 if(NOT IML_DISABLE_PKGCONFIG_INSTALL)
42 if(VCPKG_TARGET_IS_LINUX)
43 set(SYSTEM_LIBRARIES SYSTEM_LIBRARIES pthread)
44 endif()
45 vcpkg_fixup_pkgconfig(${SYSTEM_LIBRARIES})
46 else()
47 file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/pkgconfig
48 ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig)
49 endif()
50
51 # Find the relevant license file and install it
52 if(EXISTS "${SOURCE_PATH}/LICENSE")
53 set(LICENSE_PATH "${SOURCE_PATH}/LICENSE")
54 elseif(EXISTS "${SOURCE_PATH}/README.md")
55 set(LICENSE_PATH "${SOURCE_PATH}/README.md")
56 endif()
57 file(INSTALL ${LICENSE_PATH} DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
58endfunction()
59
60## # ignition_modular_library
61##
62## Download and build a library from the Ignition Robotics project ( https://ignitionrobotics.org/ ).
63##
64## ## Usage:
65## ```cmake
66## ignition_modular_library(NAME <name>
67## VERSION <version>
68## SHA512 <sha512>
69## [REF <ref>]
70## [HEAD_REF <head_ref>]
71## [PATCHES <patches>]
72## [CMAKE_PACKAGE_NAME <cmake_package_name>]
73## [DISABLE_PKGCONFIG_INSTALL])
74## ```
75##
76## ## Parameters:
77## ### NAME
78## The name of the specific ignition library, i.e. `cmake` for `ignition-cmake0`, `math` for `ignition-math4`.
79##
80## ### VERSION
81## The complete version number.
82##
83## ### SHA512
84## The SHA512 hash that should match the downloaded archive. This is forwarded to the `vcpkg_from_github` command.
85##
86## ### REF
87## Reference to the tag of the desired release. This is forwarded to the `vcpkg_from_github` command.
88## If not specified, defaults to `ignition-${NAME}${MAJOR_VERSION}_${VERSION}`.
89##
90## ### HEAD_REF
91## Reference (tag) to the desired release. This is forwarded to the `vcpkg_from_github` command.
92## If not specified, defaults to `ign-${NAME}${MAJOR_VERSION}`.
93##
94## ### PATCHES
95## A list of patches to be applied to the extracted sources.
96## This is forwarded to the `vcpkg_from_github` command.
97##
98## ### CMAKE_PACKAGE_NAME
99## The name of the CMake package for the port.
100## If not specified, defaults to `ignition-${NAME}${MAJOR_VERSION}`.
101##
102## ### DISABLE_PKGCONFIG_INSTALL
103## If present, disable installation of .pc pkg-config configuration files.
104##
105##
106## ## Examples:
107##
108## * [ignition-cmake0](https://github.com/Microsoft/vcpkg/blob/master/ports/ignition-cmake0/portfile.cmake)
109## * [ignition-math4](https://github.com/Microsoft/vcpkg/blob/master/ports/ignition-math4/portfile.cmake)
110## * [ignition-fuel-tools1](https://github.com/Microsoft/vcpkg/blob/master/ports/ignition-fuel-tools1/portfile.cmake)
111function(ignition_modular_library)
112 set(options DISABLE_PKGCONFIG_INSTALL)
113 set(oneValueArgs NAME VERSION SHA512 REF HEAD_REF CMAKE_PACKAGE_NAME)
114 set(multiValueArgs PATCHES)
115 cmake_parse_arguments(IML "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
116
117 string(REPLACE "." ";" IML_VERSION_LIST ${IML_VERSION})
118 list(GET IML_VERSION_LIST 0 IML_MAJOR_VERSION)
119
120 # If the REF option is omitted, use the canonical one
121 if(NOT DEFINED IML_REF)
122 set(IML_REF "ignition-${IML_NAME}${IML_MAJOR_VERSION}_${IML_VERSION}")
123 endif()
124
125 # If the HEAD_REF option is omitted, use the canonical one
126 if(NOT DEFINED IML_HEAD_REF)
127 set(IML_HEAD_REF "ign-${IML_NAME}${IML_MAJOR_VERSION}")
128 endif()
129
130 # If the CMAKE_PACKAGE_NAME option is omitted, use the canonical one
131 set(DEFAULT_CMAKE_PACKAGE_NAME "ignition-${IML_NAME}${IML_MAJOR_VERSION}")
132 if(NOT DEFINED IML_CMAKE_PACKAGE_NAME)
133 set(IML_CMAKE_PACKAGE_NAME ${DEFAULT_CMAKE_PACKAGE_NAME})
134 endif()
135
136 # Download library from github, to support also the --head option
137 vcpkg_from_github(
138 OUT_SOURCE_PATH SOURCE_PATH
139 REPO ignitionrobotics/ign-${IML_NAME}
140 REF ${IML_REF}
141 SHA512 ${IML_SHA512}
142 HEAD_REF ${IML_HEAD_REF}
143 PATCHES ${IML_PATCHES}
144 )
145
146 # Build library
147 ignition_modular_build_library(${IML_NAME} ${IML_MAJOR_VERSION} ${SOURCE_PATH} ${IML_CMAKE_PACKAGE_NAME} ${DEFAULT_CMAKE_PACKAGE_NAME} ${IML_DISABLE_PKGCONFIG_INSTALL})
148endfunction()