Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: CMake & MSVC & SFML 2 Static Issue  (Read 3328 times)

0 Members and 2 Guests are viewing this topic.

coolhome

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
CMake & MSVC & SFML 2 Static Issue
« on: January 31, 2012, 08:25:08 am »
Hello everyone!

I just noticed that I cannot compile SFML 2.0 (latest git version) as a static library. I unchecked BUILD_SHARED_LIBS and it compiles the dll's. I have tried this multiple times. Can anyone else confirm this behavior?

I'm digging into the CMake files to see if I can find the problem.
CoderZilla - Everything Programming

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #1 on: January 31, 2012, 08:34:43 am »
Quote
Can anyone else confirm this behavior?

Nop. Static build have always worked so far. It is controlled by CMake so you'll hardly find something in SFML's makefiles.

Maybe you're compiling a different build than the one you configured as static? Or maybe the DLLs were not removed after you changed to static?
Laurent Gomila - SFML developer

coolhome

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
CMake & MSVC & SFML 2 Static Issue
« Reply #2 on: January 31, 2012, 08:43:50 am »
Okay so I got it to work. I was using the 7417870 commit. So I just updated to 84d75ed and it worked perfectly. No idea why that would of made them DLL's. I just deleted the 7417870 folder and extracted and tried it again.. same thing. Oh well it works now so we are good  8)
CoderZilla - Everything Programming

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #3 on: February 07, 2012, 08:53:16 am »
I've got an issue, too. When building statically with nmake/VS2010, the output filenames don't have a "-s" appended. Result is that other CMake-powered projects using FindSFML.cmake can't find the libraries when SFML_STATIC_LIBRARIES is set, becase it looks for -s except for sfml-main.lib.

I also made sure to remove all SFML_* CMake vars except the SFML_STATIC_LIBRARIES so the libs are really searched for again.

Git commit ID: e7256e3324a196bb1432786c678f195c9ffb982b
OS: Win7
CC:  MSVC 2010 (nmake)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #4 on: February 07, 2012, 09:48:13 am »
Strange, the code is quite straight-forward I don't see how it could be broken.
Code: [Select]
if(BUILD_SHARED_LIBS)
    ...
else()
    set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
    set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
endif()

And it has always worked so far.

Unfortunately I can't test on VC++ 2010.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #5 on: February 07, 2012, 10:17:59 am »
Got it: Add MINSIZEREL_POSTFIX. :)

I'm usually building with "MinSizeRel" as the build type to get smaller libraries, however RELEASE_POSTFIX only applies to "Release".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #6 on: February 08, 2012, 07:31:27 pm »
Thanks!

It's fixed.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
CMake & MSVC & SFML 2 Static Issue
« Reply #7 on: February 08, 2012, 08:42:46 pm »
Great, thank you.

 

anything