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

Use gflags ALIAS target instead of ${gflags_XXX} variables #198

Closed
v1bri opened this issue Jun 20, 2017 · 5 comments
Closed

Use gflags ALIAS target instead of ${gflags_XXX} variables #198

v1bri opened this issue Jun 20, 2017 · 5 comments

Comments

@v1bri
Copy link
Contributor

v1bri commented Jun 20, 2017

The gflags project recently added an ALIAS library target for gflags which can be used instead of the legacy ${gflags_INCLUDES} and ${gflags_LIBRARIES} variables. This will also allow removal of the target_include_directories line for gflags. Happy to submit a pull request if this sounds good.

@Mizux
Copy link
Contributor

Mizux commented Dec 29, 2017

Sorry for the necro posting but why the gflags ALIAS is not used in DetermineGflagsNamespace.cmake#L37 ?

note: As a workaround when using glog and gflags as subprojects you can use:

add_subdirectory(gflags EXCLUDE_FROM_ALL)
...
# Download and unpack glog at configure time using ExternalProject
...
# Bypass DetermineGflagsNamespace
set(gflags_NAMESPACE "gflags" CACHE INTERNAL "Namespace for gflags")
add_subdirectory(${CMAKE_BINARY_DIR}/glog-src ${CMAKE_BINARY_DIR}/glog-build
	EXCLUDE_FROM_ALL)

@sergiud
Copy link
Collaborator

sergiud commented Jan 4, 2018

@Mizux Please create a new issue. Thanks!

@Mizux
Copy link
Contributor

Mizux commented Jan 4, 2018

Well, according to the try_compile command doc

LINK_LIBRARIES <libs>...
Specify libraries to be linked in the generated project.
The list of libraries may refer to system libraries and to Imported Targets from the calling project.

So in my case where I have gflags and glog as subproject of a meta CMake it didn't work either...

@sergiud
Copy link
Collaborator

sergiud commented Jan 4, 2018

@Mizux Maybe the $<TARGET_NAME:gflags> generator expression can help here?

@Mizux
Copy link
Contributor

Mizux commented Jan 4, 2018

@sergiud I doesn't help
Actually, the CMake source code just ignore target which are not "imported" so having gflags as subdirectory won't work but for a legal find_package(gflags) it should not be a problem IMHO.

EDIT: since try_compile() is done at configure time, you can't rely on target which will be available at buildtime...

durswd pushed a commit to durswd/glog that referenced this issue Sep 2, 2019
The gflags project updated their CMake config last year with a
`gflags` ALIAS target. This can be used instead of the legacy
`${gflags_LIBRARIES}` and `${gflags_INCLUDE_DIRS}` variables. It also
looks cleaner.

Fixes google#198
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

No branches or pull requests

3 participants