Skip to content

Commit bff4a69

Browse files
zsbzsbeXpl0it3r
authored andcommitted
Fixed an issue where it was impossible to link against static SFML libs on non Windows platforms
1 parent 3b41d93 commit bff4a69

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ csfml_set_option(BUILD_SHARED_LIBS TRUE BOOL "TRUE to build CSFML as shared libr
3434
csfml_set_option(CSFML_BUILD_DOC FALSE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
3535

3636
# add an option for linking to sfml either statically or dynamically
37-
csfml_set_option(CSFML_LINK_SFML_STATICALLY TRUE BOOL "TRUE to link to a static version of SFML, FALSE to link dynamically")
37+
# default on windows to static and on other platforms to dynamic
38+
if(SFML_OS_WINDOWS)
39+
set(LINK_STATICALLY_DEFAULT TRUE)
40+
else()
41+
set(LINK_STATICALLY_DEFAULT FALSE)
42+
endif()
43+
csfml_set_option(CSFML_LINK_SFML_STATICALLY ${LINK_STATICALLY_DEFAULT} BOOL "TRUE to link to a static version of SFML, FALSE to link dynamically")
3844

3945
# disable the rpath stuff
4046
set(CMAKE_SKIP_BUILD_RPATH TRUE)

src/SFML/CMakeLists.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ if(SFML_COMPILER_MSVC)
1717
endif()
1818

1919
# find SFML libraries (C++)
20-
if(SFML_OS_WINDOWS)
21-
if (CSFML_LINK_SFML_STATICALLY)
22-
set(SFML_STATIC_LIBRARIES TRUE)
23-
add_definitions(-DSFML_STATIC)
24-
endif()
20+
if(CSFML_LINK_SFML_STATICALLY)
21+
set(SFML_STATIC_LIBRARIES TRUE)
22+
add_definitions(-DSFML_STATIC)
2523
endif()
2624
find_package(SFML 2 COMPONENTS network graphics audio REQUIRED)
2725

0 commit comments

Comments
 (0)