Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile compile command cleanup #130

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions FindGrpc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include("GenericFindDependency")

option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_11) that propagate to targets that link to Abseil" true)

GenericFindDependency(
TARGET grpc++
SOURCE_DIR grpc
SYSTEM_INCLUDES
)
3 changes: 0 additions & 3 deletions FindOrion-Engine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

include("GenericFindDependency")

option(orion-engine_ENABLE_DOCS "" false)
option(orion-engine_ENABLE_EXAMPLES "" false)
Comment on lines -15 to -16
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were generating warning messages

option(orion-engine_ENABLE_TESTS "" false)
option(orion-engine_ENABLE_TEST_LIBS "" false)

GenericFindDependency(
TARGET orion_engine
Expand Down
32 changes: 32 additions & 0 deletions FindPrometheus-Cpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
include("GenericFindDependency")
option(ENABLE_TESTING "Build tests" OFF)
option(ENABLE_PUSH "Build prometheus-cpp push library" OFF)
option(ENABLE_COMPRESSION "Enable gzip compression" ON)
GenericFindDependency(
TARGET prometheus-cpp::core
SOURCE_DIR "prometheus-cpp"
)

# Change all of Prometheus's include directories to be system includes, to avoid
# compiler errors. The generalised version of this in GenericFindDependency won't
# work here because we are dealing with an aliased target
get_target_property(_aliased prometheus-cpp::core ALIASED_TARGET)
if(_aliased)
get_target_property(prometheus_include_directories ${_aliased} INTERFACE_INCLUDE_DIRECTORIES)
if(prometheus_include_directories)
set_target_properties(${_aliased} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
target_include_directories(${_aliased} SYSTEM INTERFACE ${prometheus_include_directories})
endif()
endif()

# Change all of Prometheus's include directories to be system includes, to avoid
# compiler errors. The generalised version of this in GenericFindDependency won't
# work here because we are dealing with an aliased target
get_target_property(_aliased prometheus-cpp::pull ALIASED_TARGET)
if(_aliased)
get_target_property(prometheus_include_directories ${_aliased} INTERFACE_INCLUDE_DIRECTORIES)
if(prometheus_include_directories)
set_target_properties(${_aliased} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
target_include_directories(${_aliased} SYSTEM INTERFACE ${prometheus_include_directories})
endif()
endif()
27 changes: 27 additions & 0 deletions scripts/compile_commands_cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

#
# Application will allow users to strip away source files from the compile_commands.json file.
#

import argparse
import json
import sys

parser = argparse.ArgumentParser(description="Modifies a compile_commands.json file", allow_abbrev=False)
parser.add_argument("file", type=str, help="path to the compile_commands.json file")
parser.add_argument("--remove-third-party", action="store_true", help="removes all third party files")
arguments = parser.parse_args()

try:
with open(arguments.file, "r") as file:
data = json.load(file)

if arguments.remove_third_party:
data = [x for x in data if "third_party" not in x["file"]]

with open(arguments.file, "w") as file:
json.dump(data, file, indent=4)
except BaseException as e:
print(e, file=sys.stderr)
exit(1)