]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/tools/vcpkg/ports/vcpkg-cmake/vcpkg_cmake_build.cmake
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / tools / vcpkg / ports / vcpkg-cmake / vcpkg_cmake_build.cmake
1 #[===[.md:
2 # vcpkg_cmake_build
3
4 Build a cmake project.
5
6 ```cmake
7 vcpkg_cmake_build(
8 [TARGET <target>]
9 [LOGFILE_BASE <base>]
10 [DISABLE_PARALLEL]
11 [ADD_BIN_TO_PATH]
12 )
13 ```
14
15 `vcpkg_cmake_build` builds an already-configured cmake project.
16 You can use the alias [`vcpkg_cmake_install()`] function
17 if your CMake build system supports the `install` TARGET,
18 and this is something we recommend doing whenever possible.
19 Otherwise, you can use `TARGET` to set the target to build.
20 This function defaults to not passing a target to cmake.
21
22 `LOGFILE_BASE` is used to set the base of the logfile names;
23 by default, this is `build`, and thus the logfiles end up being something like
24 `build-x86-windows-dbg.log`; if you use `vcpkg_cmake_install`,
25 this is set to `install`, so you'll get log names like `install-x86-windows-dbg.log`.
26
27 For build systems that are buggy when run in parallel,
28 using `DISABLE_PARALLEL` will run the build with only one job.
29
30 Finally, `ADD_BIN_TO_PATH` adds the appropriate (either release or debug)
31 `bin/` directories to the path during the build,
32 such that executables run during the build will be able to access those DLLs.
33 #]===]
34 if(Z_VCPKG_CMAKE_BUILD_GUARD)
35 return()
36 endif()
37 set(Z_VCPKG_CMAKE_BUILD_GUARD ON CACHE INTERNAL "guard variable")
38
39 function(vcpkg_cmake_build)
40 cmake_parse_arguments(PARSE_ARGV 0 "arg" "DISABLE_PARALLEL;ADD_BIN_TO_PATH" "TARGET;LOGFILE_BASE" "")
41
42 if(DEFINED arg_UNPARSED_ARGUMENTS)
43 message(FATAL_ERROR "vcpkg_cmake_build was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
44 endif()
45 if(NOT DEFINED arg_LOGFILE_BASE)
46 set(arg_LOGFILE_BASE "build")
47 endif()
48
49 set(build_args)
50 set(target_args)
51 set(parallel_args)
52 set(no_parallel_args)
53
54 if(Z_VCPKG_CMAKE_GENERATOR STREQUAL "Ninja")
55 set(build_args "-v") # verbose output
56 set(parallel_args "-j${VCPKG_CONCURRENCY}")
57 set(no_parallel_args "-j1")
58 elseif(Z_VCPKG_CMAKE_GENERATOR MATCHES "^Visual Studio")
59 set(build_args
60 "/p:VCPkgLocalAppDataDisabled=true"
61 "/p:UseIntelMKL=No"
62 )
63 set(parallel_args "/m")
64 elseif(Z_VCPKG_CMAKE_GENERATOR STREQUAL "NMake Makefiles")
65 # No options are currently added for nmake builds
66 else()
67 message(FATAL_ERROR "Unrecognized GENERATOR setting from vcpkg_configure_cmake(). Valid generators are: Ninja, Visual Studio, and NMake Makefiles")
68 endif()
69
70 if(DEFINED arg_TARGET)
71 set(target_args "--target" "${arg_TARGET}")
72 endif()
73
74 foreach(buildtype IN ITEMS debug release)
75 if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL buildtype)
76 if(buildtype STREQUAL "debug")
77 set(short_buildtype "dbg")
78 set(cmake_config "Debug")
79 else()
80 set(short_buildtype "rel")
81 set(cmake_config "Release")
82 endif()
83
84 message(STATUS "Building ${TARGET_TRIPLET}-${short_buildtype}")
85
86 if(arg_ADD_BIN_TO_PATH)
87 set(env_path_backup "$ENV{PATH}")
88 if(buildtype STREQUAL "debug")
89 vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
90 else()
91 vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
92 endif()
93 endif()
94
95 if (arg_DISABLE_PARALLEL)
96 vcpkg_execute_build_process(
97 COMMAND "${CMAKE_COMMAND}" --build . --config "${cmake_config}" ${target_args} -- ${build_args} ${no_parallel_args}
98 WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_buildtype}"
99 LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}-${short_buildtype}"
100 )
101 else()
102 vcpkg_execute_build_process(
103 COMMAND "${CMAKE_COMMAND}" --build . --config "${cmake_config}" ${target_args} -- ${build_args} ${parallel_args}
104 NO_PARALLEL_COMMAND "${CMAKE_COMMAND}" --build . --config "${cmake_config}" ${target_args} -- ${build_args} ${no_parallel_args}
105 WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${short_buildtype}"
106 LOGNAME "${arg_LOGFILE_BASE}-${TARGET_TRIPLET}-${short_buildtype}"
107 )
108 endif()
109
110 if(arg_ADD_BIN_TO_PATH)
111 set(ENV{PATH} "${env_path_backup}")
112 endif()
113 endif()
114 endforeach()
115 endfunction()