-
-
Notifications
You must be signed in to change notification settings - Fork 148
Conversation
export targets, add versioning, make standalone mode optional
install( | ||
EXPORT ${LIB_NAME}-targets | ||
NAMESPACE ${LIB_NAMESPACE}:: | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${LIB_NAME} |
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.
Install header-only library in non standalone mode by default is are bad idea in my opinion.
Please add an option to disable.
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.
What do these lines have to do with standalone mode? Unless you're talking about RH_STANDALONE_PROJECT
, whose default value is exactly what it was before, except that now it can be overridden as part of the invocation to cmake.
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.
You added "install" if RH_STANDALONE_PROJECT == OFF, this changes the behavior.
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.
You have to install the library or else it can't be consumed by other cmake projects
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.
If RH_STANDALONE_PROJECT == ON - yes.
If RH_STANDALONE_PROJECT == OFF I use add_subdirectory(path/to/robin-hood-hashing) to add library in my cmake project. In this case, installation of headers is not required to use the library. robin-hood-hashing - is header-only library.
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.
CMakeLists.txt:
cmake_minimum_required(VERSION 3.5)
project(test LANGUAGES CXX)
add_subdirectory(3rdparty/robin-hood-hashing)
Cli:
$ mkdir 3rdparty && cd 3rdparty
$ git clone https://github.com/Ryan-rsm-McKenzie/robin-hood-hashing.git
$ cd ../..
$ mkdir build && cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/Users/phprus/Devel/install ..
$ make install
Install the project...
-- Install configuration: ""
-- Installing: /Users/phprus/Devel/install/include/robin_hood.h
-- Installing: /Users/phprus/Devel/install/lib/cmake/robin_hood/robin_hoodConfig.cmake
-- Installing: /Users/phprus/Devel/install/lib/cmake/robin_hood/robin_hood-targets.cmake
What is it files on add_subdirectory case???
For the find_library case, the install commands should be in the RH_STANDALONE_PROJECT == ON branch.
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.
These files describe your transitive dependencies. If someone uses your library, they will also need your dependencies. These files describe those dependencies. This is working exactly as intended.
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.
Furthermore, the RH_STANDALONE_PROJECT=ON
is the development branch and is clearly not intended for consumption by third parties.
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.
In my example, NOBODY is using the library, but the unneeded files in this scenario were created by the install commands.
Please, see https://github.com/Cyan4973/xxHash/blob/dev/cmake_unofficial/CMakeLists.txt#L121 for example.
install commands used only if "NOT XXHASH_BUNDLED_MODE"
XXHASH_BUNDLED_MODE option is equivalent (NOT RH_STANDALONE_PROJECT)
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.
If you don't want subdirectories to run install
commands, then you can use add_subdirectory (robin_hood EXCLUDE_FROM_ALL)
Hi, sorry for the late reply! I can't really review this change as I don't know much about cmake. It works for me though, so I'll merge it. |
export targets, add versioning, make standalone mode optional