Skip to content

Commit

Permalink
Add tracy options
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcasmar committed Dec 19, 2022
1 parent 45260cd commit f33f7c0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 22 additions & 5 deletions recipes/tracy/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ class TracyConan(ConanFile):
# Existing CMake tracy options with default value
_tracy_options = {
"enable": ([True, False], True),
"on_demand": ([True, False], False),
"callstack": ([True, False], False),
"no_callstack": ([True, False], False),
"no_callstack_inlines": ([True, False], False),
"only_localhost": ([True, False], False),
"no_broadcast": ([True, False], False),
"only_ipv": ([True, False], False),
"no_code_transfer": ([True, False], False),
"no_context_switch": ([True, False], False),
"no_exit": ([True, False], False),
"no_frame_image": ([True, False], False),
"no_sampling": ([True, False], False),
"no_verify": ([True, False], False),
"no_vsync_capture": ([True, False], False),
"no_frame_image": ([True, False], False),
"no_system_tracing": ([True, False], False),
"delayed_init": ([True, False], False),
}
options = {
"shared": [True, False],
Expand Down Expand Up @@ -76,7 +82,8 @@ def build(self):
cmake.build()

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "LICENSE", src=self.source_folder,
dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))
Expand All @@ -87,15 +94,25 @@ def package_info(self):
# TODO: back to global scope in conan v2
self.cpp_info.components["tracyclient"].libs = ["TracyClient"]
if self.options.shared:
self.cpp_info.components["tracyclient"].defines.append("TRACY_IMPORTS")
self.cpp_info.components["tracyclient"].defines.append(
"TRACY_IMPORTS")
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["tracyclient"].system_libs.append("pthread")
self.cpp_info.components["tracyclient"].system_libs.append(
"pthread")
if self.settings.os == "Linux":
self.cpp_info.components["tracyclient"].system_libs.append("dl")

# Tracy CMake adds options set to ON as public
for opt in self._tracy_options.keys():
switch = getattr(self.options, opt)
opt = f"TRACY_{opt.upper()}"
if switch:
self.cpp_info.components["tracyclient"].defines.append(opt)

# TODO: to remove in conan v2
self.cpp_info.names["cmake_find_package"] = "Tracy"
self.cpp_info.names["cmake_find_package_multi"] = "Tracy"
self.cpp_info.components["tracyclient"].names["cmake_find_package"] = "TracyClient"
self.cpp_info.components["tracyclient"].names["cmake_find_package_multi"] = "TracyClient"
self.cpp_info.components["tracyclient"].set_property("cmake_target_name", "Tracy::TracyClient")
self.cpp_info.components["tracyclient"].set_property(
"cmake_target_name", "Tracy::TracyClient")
2 changes: 1 addition & 1 deletion recipes/tracy/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#endif

int main(int argc, char **argv) {
ZoneScopedN("main")
ZoneScopedN("main");

return 0;
}

0 comments on commit f33f7c0

Please sign in to comment.