-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add --source-dir and --build-dir flags #33
base: master
Are you sure you want to change the base?
Conversation
This allows generating CMakeLists.txt that use ${CMAKE_SOURCE_DIR} and ${CMAKE_BINARY_DIR} instead of absolute paths from compile_commands.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, and sorry it took me so long to get around to reviewing!
There's a couple of minor bugs below.
What's the benefit of using specifically ${CMAKE_SOURCE_DIR}
? There are also a bunch of other relevant-sounding directories:
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_LIST_DIR}
I think it'd help me understand your use case if you gave an example of the project layout you're trying to achieve.
if not relative_to_source.startswith(os.path.pardir): | ||
file = '${CMAKE_SOURCE_DIR}/' + relative_to_source | ||
elif build_directory: | ||
relative_to_build = os.path.relpath(file, source_directory) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/source_directory/build_directory/
relative_to_source = os.path.relpath(file, source_directory) | ||
if not relative_to_source.startswith(os.path.pardir): | ||
file = '${CMAKE_SOURCE_DIR}/' + relative_to_source | ||
elif build_directory: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This branch will never be taken if source_directory and build_directory
, but I think it should.
+1 for using these macros. |
This allows generating CMakeLists.txt that use ${CMAKE_SOURCE_DIR} and
${CMAKE_BINARY_DIR} instead of absolute paths from compile_commands.json.