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

Update the CMakeLists.txt section in googletest README.md. #1139

Merged
merged 4 commits into from
Oct 24, 2017
Merged

Update the CMakeLists.txt section in googletest README.md. #1139

merged 4 commits into from
Oct 24, 2017

Conversation

chehsunliu
Copy link
Contributor

Add EXCLUDE_FROM_ALL in add_subdirectory to prevent make install from including lots of headers from gtest/gmock.

add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
                 ${CMAKE_BINARY_DIR}/googletest-build
                 EXCLUDE_FROM_ALL)

Before:

$ make install
[ 23%] Built target gmock_main
[ 41%] Built target gmock
[ 52%] Built target gtest
[ 64%] Built target gtest_main
[ 76%] Built target kuku
[ 88%] Built target testkuku
[100%] Built target myapp
Install the project...
-- Install configuration: ""
-- Installing: /home/edwin_liu/downloads/gg/lib/libgmock.so
-- Installing: /home/edwin_liu/downloads/gg/lib/libgmock_main.so
-- Installing: /home/edwin_liu/downloads/gg/include/gmock
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-actions.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-actions.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-matchers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-more-matchers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-more-actions.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-spec-builders.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/gmock-generated-internal-utils.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/gmock-internal-utils.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/gmock-port.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/custom
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/custom/gmock-generated-actions.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/custom/gmock-matchers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/custom/gmock-generated-actions.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/custom/gmock-port.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/internal/gmock-generated-internal-utils.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-matchers.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-actions.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-matchers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-nice-strict.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-nice-strict.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-cardinalities.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-function-mockers.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock.h
-- Installing: /home/edwin_liu/downloads/gg/include/gmock/gmock-generated-function-mockers.h
-- Installing: /home/edwin_liu/downloads/gg/lib/libgtest.so
-- Set runtime path of "/home/edwin_liu/downloads/gg/lib/libgtest.so" to ""
-- Installing: /home/edwin_liu/downloads/gg/lib/libgtest_main.so
-- Set runtime path of "/home/edwin_liu/downloads/gg/lib/libgtest_main.so" to ""
-- Installing: /home/edwin_liu/downloads/gg/include/gtest
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-typed-test.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-test-part.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest_pred_impl.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-param-test.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-death-test-internal.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-port-arch.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-linked_ptr.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-param-util-generated.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-internal.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-tuple.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-filepath.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-tuple.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/custom
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/custom/gtest-printers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/custom/gtest.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/custom/gtest-port.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-param-util-generated.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-type-util.h.pump
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-port.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-string.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-type-util.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/internal/gtest-param-util.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-message.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-spi.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-param-test.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-death-test.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest_prod.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest-printers.h
-- Installing: /home/edwin_liu/downloads/gg/include/gtest/gtest.h
-- Installing: /home/edwin_liu/downloads/gg/lib64/libkuku.so
-- Up-to-date: /home/edwin_liu/downloads/gg/include
-- Installing: /home/edwin_liu/downloads/gg/include/kuku
-- Installing: /home/edwin_liu/downloads/gg/include/kuku/core.hpp
-- Installing: /home/edwin_liu/downloads/gg/bin/myapp
-- Set runtime path of "/home/edwin_liu/downloads/gg/bin/myapp" to ""

After:

$ make install
[ 20%] Built target kuku
[ 40%] Built target gtest
[ 60%] Built target gtest_main
[ 80%] Built target testkuku
[100%] Built target myapp
Install the project...
-- Install configuration: ""
-- Installing: /home/edwin_liu/downloads/gg/lib64/libkuku.so
-- Installing: /home/edwin_liu/downloads/gg/include
-- Installing: /home/edwin_liu/downloads/gg/include/kuku
-- Installing: /home/edwin_liu/downloads/gg/include/kuku/core.hpp
-- Installing: /home/edwin_liu/downloads/gg/bin/myapp
-- Set runtime path of "/home/edwin_liu/downloads/gg/bin/myapp" to ""

Use `EXCLUDE_FROM_ALL` in `add_subdirectory` to prevent `make install` from including lots of headers from gtest/gmock.
```
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
                 ${CMAKE_BINARY_DIR}/googletest-build
                 EXCLUDE_FROM_ALL)
```
@gennadiycivil
Copy link
Contributor

I would like to see more review on this.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

The proposal is compliant to the CMake documentation which says:

If the ``EXCLUDE_FROM_ALL`` argument is provided then targets in the
subdirectory will not be included in the ``ALL`` target of the parent
directory by default, and will be excluded from IDE project files.
Users must explicitly build targets in the subdirectory.  This is
meant for use when the subdirectory contains a separate part of the
project that is useful but not necessary, such as a set of examples.
Typically the subdirectory should contain its own ``project()``
command invocation so that a full build system will be generated in the
subdirectory (such as a VS IDE solution file).  Note that inter-target
dependencies supercede this exclusion.  If a target built by the
parent project depends on a target in the subdirectory, the dependee
target will be included in the parent project build system to satisfy
the dependency.

@gennadiycivil gennadiycivil merged commit 6d0bb75 into google:master Oct 24, 2017
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.

2 participants