Skip to content

Update build instructions to better use CMake#1017

Merged
dmah42 merged 1 commit intogoogle:masterfrom
adambadura:BetterUseOfCMakeCommandLine
Aug 19, 2020
Merged

Update build instructions to better use CMake#1017
dmah42 merged 1 commit intogoogle:masterfrom
adambadura:BetterUseOfCMakeCommandLine

Conversation

@adambadura
Copy link
Copy Markdown
Contributor

Build instructions needlessly referred to make when CMake offers a command-line interface to abstract away from the specific build system.

Furthermore, CMake offers command-line "tool mode" which performs basic filesystem operations. While the syntax is a bit more verbose than Linux commands it is platform-independent. Now the commands can be copy-pasted on both Linux and Windows and will just work.

Finally, the Release build type and link-time optimizations are included in initial commands. A natural flow for a new-comer is to read and execute the commands and only then learn that one has to go back and redo them again this time with proper parameters. Now instead the parameters are only explained later but present already in the initial commands.

@google-cla google-cla bot added the cla: yes label Aug 5, 2020

```bash
$ make test
$ cmake --build "build" --config Release --target test
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have checked the new commands on both Linux and Windows and all seem to work fine (well, the installation failed expectedly with the access rights but looked correct up to that point) except for running tests. I guess it works fine with Makefile (or Ninja) build systems where there is a test target. But Visual Studio doesn't have such a target and fails for the new command.

However, it would fail with the old one just as well obviously, so no regress here.

I'm afraid progress could be made here only by using ctest instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why don't we suggest ctest?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because we use enable_testing() instead of include(CTest). I think it would be better to do the other, but it would go beyond just changing README.md. Perhaps as a separate change?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

works for me :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

filed #1023 for this.

Copy link
Copy Markdown
Member

@dmah42 dmah42 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 changes. I agree this is much nicer.

README.md Outdated
$ cmake ../
$ cmake -E make_directory "build"
# Generate build system files with cmake.
$ cmake -E chdir "build" cmake -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_LTO=true ../
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ENABLE_LTO is considered an advanced feature which is why it's not in the initial instructions.

I think there's a separate discussion about whether it should just be defaulted to true :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, as a new user coming to the library I didn't have this impression reading the README.md. Instead, I was like: "well, why didn't you tell me this before I built it without the flag!" :)

So, perhaps we should change the README.md so that it explains what is "advanced" about it and why should one consider not using it. Or we should follow with adding it by default as you mentioned.

Anyway, I'm fine with removing it here if this is what you prefer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

filed #1022 to consider changing the default. i think we should remove it from here until we can resolve that so the initial build instructions are as short as possible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, I will prepare an update for this pull request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have fixed this in the new version.


```bash
$ make test
$ cmake --build "build" --config Release --target test
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why don't we suggest ctest?

@adambadura adambadura force-pushed the BetterUseOfCMakeCommandLine branch from 342e2c3 to f38fb79 Compare August 18, 2020 20:26
Build instructions needlessly referred to make when CMake offers
a command-line interface to abstract away from the specific build
system.

Furthermore, CMake offers command-line "tool mode" which performs basic
filesystem operations. While the syntax is a bit more verbose than
Linux commands it is platform-independent. Now the commands can be
copy-pasted on both Linux and Windows and will just work.

Finally, the Release build type and link-time optimizations are
included in initial commands. A natural flow for a new-comer is to read
and execute the commands and only then learn that one has to go back
and redo them again this time with proper parameters. Now instead the
parameters are only explained later but present already in the initial
commands.
@adambadura adambadura force-pushed the BetterUseOfCMakeCommandLine branch from f38fb79 to 492c310 Compare August 19, 2020 04:43
@dmah42 dmah42 merged commit bb978c0 into google:master Aug 19, 2020
@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Aug 19, 2020

thanks!

@adambadura adambadura deleted the BetterUseOfCMakeCommandLine branch August 19, 2020 11:00
JBakamovic pushed a commit to JBakamovic/benchmark that referenced this pull request Sep 11, 2020
Build instructions needlessly referred to make when CMake offers
a command-line interface to abstract away from the specific build
system.

Furthermore, CMake offers command-line "tool mode" which performs basic
filesystem operations. While the syntax is a bit more verbose than
Linux commands it is platform-independent. Now the commands can be
copy-pasted on both Linux and Windows and will just work.

Finally, the Release build type is included in initial commands. A natural flow
for a new-comer is to read and execute the commands and only then learn
that one has to go back and redo them again this time with proper parameters.
Now instead the parameters are only explained later but present already in the
initial commands.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants