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

Add --source-dir and --build-dir flags #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arichardson
Copy link
Contributor

This allows generating CMakeLists.txt that use ${CMAKE_SOURCE_DIR} and
${CMAKE_BINARY_DIR} instead of absolute paths from compile_commands.json.

This allows generating CMakeLists.txt that use ${CMAKE_SOURCE_DIR} and
${CMAKE_BINARY_DIR} instead of absolute paths from compile_commands.json.
Copy link
Owner

@AbigailBuccaneer AbigailBuccaneer left a 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)
Copy link
Owner

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:
Copy link
Owner

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.

@cjolivier01
Copy link

+1 for using these macros.
For one, it makes the project portable to different computers.
For another, it's basically required for CLion remote mode (pretty common these days where development is on seme high-powered AWS instance and the client-side is a Mac)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants