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

FindSFML: dynamic remain libraries cached after setting SFML_STATIC_LIBRARIES #637

Closed
Ceylo opened this Issue Jun 15, 2014 · 10 comments

Comments

Projects
None yet
6 participants
@Ceylo
Contributor

Ceylo commented Jun 15, 2014

Hello,

When using the FindSFML.cmake script, if the user runs CMake's configure step before setting SFML_STATIC_LIBRARIES, he won't be able to use static libraries unless cache entries for the dynamic libraries are manually removed.

This is annoying because usually the user will just set the SFML_STATIC_LIBRARIES entry, re-run configure. And his project is built he realizes that dynamic libraries have been used instead of static ones.

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Jun 15, 2014

Member

This is a CMake limitation as I mentioned here. I don't know of any clean workarounds for this. It seems this is intended behaviour according to this.

Member

binary1248 commented Jun 15, 2014

This is a CMake limitation as I mentioned here. I don't know of any clean workarounds for this. It seems this is intended behaviour according to this.

@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Jun 15, 2014

Contributor

Yes I realized this, which is why I also asked to CMake developers (no answer yet).

At the moment the only workaround I can think of if doing something like:

if SFML_STATIC_LIBRARIES is set, check that the libraries names have -s in them, if not, clear the SFML_XXXX_LIBRARY variables

Contributor

Ceylo commented Jun 15, 2014

Yes I realized this, which is why I also asked to CMake developers (no answer yet).

At the moment the only workaround I can think of if doing something like:

if SFML_STATIC_LIBRARIES is set, check that the libraries names have -s in them, if not, clear the SFML_XXXX_LIBRARY variables

@binary1248

This comment has been minimized.

Show comment
Hide comment
@binary1248

binary1248 Jun 15, 2014

Member

The CMake developers can seem rather lethargic at times 😉. An even better workaround would be to know how you want to link from the start and set SFML_STATIC_LIBRARIES before even configuring 😄.

Member

binary1248 commented Jun 15, 2014

The CMake developers can seem rather lethargic at times 😉. An even better workaround would be to know how you want to link from the start and set SFML_STATIC_LIBRARIES before even configuring 😄.

@Bromeon Bromeon added the m:config label Jun 15, 2014

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Jun 15, 2014

Member

It's very usual to have to clean the cache after changing one variable. I think CMake users quickly get used to that behaviour.

Member

LaurentGomila commented Jun 15, 2014

It's very usual to have to clean the cache after changing one variable. I think CMake users quickly get used to that behaviour.

@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Jun 15, 2014

Contributor

@binary1248 Yes, supposing it's possible :)
@LaurentGomila Well, depends on the point of view… if a way is possible to avoid users not realizing what's happening, that's a good point.

Apart from that I've got an answer on the CMake mailing list, and it looks like a interesting one :)

Perhaps you could use distinct cache variables for static and shared libraries.

e.g.

find_library(FOO_STATIC_LIBRARY ...)
find_library(FOO_SHARED_LIBRARY ...)

set(FOO_LIBRARIES "")

if(FOO_LINK_STATIC)
   list(APPEND FOO_LIBRARIES ${FOO_STATIC_LIBRARY})
else()
   list(APPEND FOO_LIBRARIES ${FOO_SHARED_LIBRARY})
endif()

Nils
Contributor

Ceylo commented Jun 15, 2014

@binary1248 Yes, supposing it's possible :)
@LaurentGomila Well, depends on the point of view… if a way is possible to avoid users not realizing what's happening, that's a good point.

Apart from that I've got an answer on the CMake mailing list, and it looks like a interesting one :)

Perhaps you could use distinct cache variables for static and shared libraries.

e.g.

find_library(FOO_STATIC_LIBRARY ...)
find_library(FOO_SHARED_LIBRARY ...)

set(FOO_LIBRARIES "")

if(FOO_LINK_STATIC)
   list(APPEND FOO_LIBRARIES ${FOO_STATIC_LIBRARY})
else()
   list(APPEND FOO_LIBRARIES ${FOO_SHARED_LIBRARY})
endif()

Nils
@TankOs

This comment has been minimized.

Show comment
Hide comment
@TankOs

TankOs Jun 16, 2014

Member

For me that sounds like a very good idea. There's no reason in continuing supporting bad habits. ;)

Member

TankOs commented Jun 16, 2014

For me that sounds like a very good idea. There's no reason in continuing supporting bad habits. ;)

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Jun 16, 2014

Member

Ok, let's do this.

Member

LaurentGomila commented Jun 16, 2014

Ok, let's do this.

@eXpl0it3r eXpl0it3r added this to the 2.2 milestone Jul 8, 2014

@eXpl0it3r eXpl0it3r self-assigned this Jul 8, 2014

@eXpl0it3r eXpl0it3r removed the s:unassigned label Jul 8, 2014

@eXpl0it3r eXpl0it3r removed their assignment Aug 18, 2014

binary1248 added a commit that referenced this issue Aug 19, 2014

Fixed FindSFML.cmake not updating library entries when the user chang…
…es the value of SFML_STATIC_LIBRARIES after the initial configure (#637).
@binary1248

This comment has been minimized.

Show comment
Hide comment
Member

binary1248 commented Aug 19, 2014

@Ceylo

This comment has been minimized.

Show comment
Hide comment
@Ceylo

Ceylo Aug 21, 2014

Contributor

Great news :)

Contributor

Ceylo commented Aug 21, 2014

Great news :)

binary1248 added a commit that referenced this issue Aug 26, 2014

Fixed FindSFML.cmake not updating library entries when the user chang…
…es the value of SFML_STATIC_LIBRARIES after the initial configure (#637).
@TankOs

This comment has been minimized.

Show comment
Hide comment
@TankOs

TankOs Aug 26, 2014

Member

Merged.

Member

TankOs commented Aug 26, 2014

Merged.

@TankOs TankOs closed this Aug 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment