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

CMake: Use GNUInstallDirs for install destination #186

Merged
merged 3 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
48 changes: 26 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ include(CMakeDependentOption)
include(CheckCXXCompilerFlag)
include(FeatureSummary)
include(FindPackageHandleStandardArgs)
include(GNUInstallDirs)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Avoid "Policy CMP0042 is not set" warning on macOS.
Expand Down Expand Up @@ -333,7 +334,7 @@ install(FILES src/s2/_fp_contract_off.h
src/s2/s2wedge_relations.h
src/s2/sequence_lexicon.h
src/s2/value_lexicon.h
DESTINATION include/s2)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2")
install(FILES src/s2/base/casts.h
src/s2/base/commandlineflags.h
src/s2/base/integral_types.h
Expand All @@ -342,11 +343,11 @@ install(FILES src/s2/base/casts.h
src/s2/base/mutex.h
src/s2/base/port.h
src/s2/base/spinlock.h
DESTINATION include/s2/base)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/base")
install(FILES src/s2/strings/ostringstream.h
DESTINATION include/s2/strings)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/strings")
install(FILES src/s2/third_party/absl/algorithm/algorithm.h
DESTINATION include/s2/third_party/absl/algorithm)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/algorithm")
install(FILES src/s2/third_party/absl/base/attributes.h
src/s2/third_party/absl/base/casts.h
src/s2/third_party/absl/base/config.h
Expand All @@ -357,42 +358,42 @@ install(FILES src/s2/third_party/absl/base/attributes.h
src/s2/third_party/absl/base/policy_checks.h
src/s2/third_party/absl/base/port.h
src/s2/third_party/absl/base/thread_annotations.h
DESTINATION include/s2/third_party/absl/base)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/base")
install(FILES src/s2/third_party/absl/base/internal/identity.h
src/s2/third_party/absl/base/internal/inline_variable.h
src/s2/third_party/absl/base/internal/invoke.h
src/s2/third_party/absl/base/internal/throw_delegate.h
src/s2/third_party/absl/base/internal/unaligned_access.h
DESTINATION include/s2/third_party/absl/base/internal)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/base/internal")
install(FILES src/s2/third_party/absl/container/inlined_vector.h
DESTINATION include/s2/third_party/absl/container)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/container")
install(FILES src/s2/third_party/absl/container/internal/compressed_tuple.h
src/s2/third_party/absl/container/internal/container_memory.h
src/s2/third_party/absl/container/internal/layout.h
DESTINATION include/s2/third_party/absl/container/internal)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/container/internal")
install(FILES src/s2/third_party/absl/memory/memory.h
DESTINATION include/s2/third_party/absl/memory)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/memory")
install(FILES src/s2/third_party/absl/meta/type_traits.h
DESTINATION include/s2/third_party/absl/meta)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/meta")
install(FILES src/s2/third_party/absl/numeric/int128.h
src/s2/third_party/absl/numeric/int128_have_intrinsic.inc
src/s2/third_party/absl/numeric/int128_no_intrinsic.inc
DESTINATION include/s2/third_party/absl/numeric)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/numeric")
install(FILES src/s2/third_party/absl/strings/numbers.h
src/s2/third_party/absl/strings/str_cat.h
src/s2/third_party/absl/strings/string_view.h
DESTINATION include/s2/third_party/absl/strings)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/strings")
install(FILES src/s2/third_party/absl/types/span.h
DESTINATION include/s2/third_party/absl/types)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/types")
install(FILES src/s2/third_party/absl/utility/utility.h
DESTINATION include/s2/third_party/absl/utility)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/third_party/absl/utility")
install(FILES src/s2/util/bits/bits.h
DESTINATION include/s2/util/bits)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/bits")
install(FILES src/s2/util/coding/coder.h
src/s2/util/coding/varint.h
DESTINATION include/s2/util/coding)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/coding")
install(FILES src/s2/util/endian/endian.h
DESTINATION include/s2/util/endian)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/endian")
install(FILES src/s2/util/gtl/btree.h
src/s2/util/gtl/btree_container.h
src/s2/util/gtl/btree_map.h
Expand All @@ -403,18 +404,21 @@ install(FILES src/s2/util/gtl/btree.h
src/s2/util/gtl/densehashtable.h
src/s2/util/gtl/hashtable_common.h
src/s2/util/gtl/layout.h
DESTINATION include/s2/util/gtl)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/gtl")
install(FILES src/s2/util/hash/mix.h
DESTINATION include/s2/util/hash)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/hash")
install(FILES src/s2/util/math/mathutil.h
src/s2/util/math/matrix3x3.h
src/s2/util/math/vector.h
src/s2/util/math/vector3_hash.h
DESTINATION include/s2/util/math)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/math")
install(FILES src/s2/util/units/length-units.h
src/s2/util/units/physical-units.h
DESTINATION include/s2/util/units)
install(TARGETS s2 s2testing DESTINATION lib)
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/units")
install(TARGETS s2 s2testing
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")

message("GTEST_ROOT: ${GTEST_ROOT}")
if (GTEST_ROOT)
Expand Down
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,44 @@ cd build
cmake -DGTEST_ROOT=/usr/src/gtest ..
make
make test # If GTEST_ROOT specified above.
sudo make install
```

Enable gflags and glog with `cmake -DWITH_GFLAGS=ON -DWITH_GLOG=ON ...`.

Disable building of shared libraries with `-DBUILD_SHARED_LIBS=OFF`.

## Installing

From `build` subdirectory:

```
make install
```

Prefix it with `sudo` if needed:

```
sudo make install
```

_NOTE_: The `uninstall` target missed but `install_manifest.txt` may be helpfull.
podsvirov marked this conversation as resolved.
Show resolved Hide resolved

All files will be installed at location specified in `CMAKE_INSTALL_PREFIX` variable.

Several suffix variables used for some file groups:

Variable | Description
-------- | -----------
`CMAKE_INSTALL_INCLUDEDIR` | For header files
`CMAKE_INSTALL_BINDIR` | For executables and `*.dll` files on `DLL`-based platforms
`CMAKE_INSTALL_LIBDIR` | For library files (`*.so`, `*.a`, `*.lib` etc)

To edit cached variables type:
podsvirov marked this conversation as resolved.
Show resolved Hide resolved

```
make edit_cache
```

## Python

If you want the Python interface, you will also need:
Expand Down