Removed the hack that copied external libs into SFML static libs, users now have to link them explicitly
This commit is contained in:
parent
c2a9ed6b83
commit
dbf01a775b
@ -190,13 +190,22 @@ install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake
|
||||
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
|
||||
install(FILES readme.txt DESTINATION ${INSTALL_MISC_DIR})
|
||||
|
||||
# install 3rd-party libraries and tools on Windows and OS X
|
||||
if(SFML_OS_WINDOWS)
|
||||
if(ARCH_32BITS)
|
||||
install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin)
|
||||
install(FILES extlibs/bin/x86/openal32.dll DESTINATION bin)
|
||||
install(DIRECTORY extlibs/bin/x86/ DESTINATION bin)
|
||||
if(SFML_COMPILER_MSVC)
|
||||
install(DIRECTORY extlibs/libs-msvc/x86/ DESTINATION lib)
|
||||
else()
|
||||
install(DIRECTORY extlibs/libs-mingw/x86/ DESTINATION lib)
|
||||
endif()
|
||||
elseif(ARCH_64BITS)
|
||||
install(FILES extlibs/bin/x64/libsndfile-1.dll DESTINATION bin)
|
||||
install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin)
|
||||
install(DIRECTORY extlibs/bin/x64/ DESTINATION bin)
|
||||
if(SFML_COMPILER_MSVC)
|
||||
install(DIRECTORY extlibs/libs-msvc/x64/ DESTINATION lib)
|
||||
else()
|
||||
install(DIRECTORY extlibs/libs-mingw/x64/ DESTINATION lib)
|
||||
endif()
|
||||
endif()
|
||||
elseif(SFML_OS_MACOSX)
|
||||
install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||
|
@ -1,57 +1,5 @@
|
||||
include(CMakeParseArguments)
|
||||
|
||||
# this macro adds external dependencies to a static target,
|
||||
# compensating for the lack of a link step when building a static library.
|
||||
# every compiler has its own way of doing it:
|
||||
# - VC++ supports it directly through the static library flags
|
||||
# - MinGW/gcc doesn't support it, but as a static library is nothing more than an archive,
|
||||
# we can simply merge the external dependencies to our generated target as a post-build step
|
||||
# - for other compilers and OSes, static build is not encouraged so we don't try to
|
||||
# pre-link dependencies, we just "link" them so that the SFML samples can compile
|
||||
# out-of-the-box (CMake forwards the dependencies automatically)
|
||||
macro(sfml_static_add_libraries target)
|
||||
if(SFML_OS_WINDOWS AND SFML_COMPILER_GCC)
|
||||
# Windows - gcc
|
||||
foreach(lib ${ARGN})
|
||||
if(NOT ${lib} MATCHES ".*/.*")
|
||||
string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}")
|
||||
if(SFML_COMPILER_GCC_W64)
|
||||
set(lib "${STANDARD_LIBS_PATH}/${GCC_MACHINE}/lib/lib${lib}.a")
|
||||
else()
|
||||
set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a")
|
||||
endif()
|
||||
endif()
|
||||
string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
|
||||
get_target_property(TARGET_FILENAME ${target} ${BUILD_TYPE}_LOCATION)
|
||||
add_custom_command(TARGET ${target}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_AR} x ${lib}
|
||||
COMMAND ${CMAKE_AR} rcs ${TARGET_FILENAME} *.o
|
||||
COMMAND del *.o /f /q
|
||||
VERBATIM)
|
||||
endforeach()
|
||||
elseif(SFML_COMPILER_MSVC)
|
||||
# Visual C++
|
||||
set(LIBRARIES "")
|
||||
foreach(lib ${ARGN})
|
||||
if(NOT ${lib} MATCHES ".*\\.lib")
|
||||
set(lib ${lib}.lib)
|
||||
endif()
|
||||
if(MSVC_IDE AND SFML_MSVC_VERSION LESS 10)
|
||||
# for Visual Studio projects < 10, we must add double quotes
|
||||
# around paths because they may contain spaces
|
||||
set(LIBRARIES "${LIBRARIES} "\\;${lib}"\\;")
|
||||
else()
|
||||
set(LIBRARIES "${LIBRARIES} \"${lib}\"")
|
||||
endif()
|
||||
endforeach()
|
||||
set_target_properties(${target} PROPERTIES STATIC_LIBRARY_FLAGS ${LIBRARIES})
|
||||
else()
|
||||
# All other platforms
|
||||
target_link_libraries(${target} ${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# add a new target which is a SFML library
|
||||
# ex: sfml_add_library(sfml-graphics
|
||||
# SOURCES sprite.cpp image.cpp ...
|
||||
@ -138,14 +86,7 @@ macro(sfml_add_library target)
|
||||
|
||||
# link the target to its external dependencies
|
||||
if(THIS_EXTERNAL_LIBS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# in shared build, we use the regular linker commands
|
||||
target_link_libraries(${target} ${THIS_EXTERNAL_LIBS})
|
||||
else()
|
||||
# in static build there's no link stage, but with some compilers it is possible to force
|
||||
# the generated static library to directly contain the symbols from its dependencies
|
||||
sfml_static_add_libraries(${target} ${THIS_EXTERNAL_LIBS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add the install rule
|
||||
|
@ -110,14 +110,10 @@ endif()
|
||||
include_directories(${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
# build the list of libraries to link
|
||||
# GL and X11 are only needed for shared build, as they are already linked by sfml-window
|
||||
set(GRAPHICS_EXT_LIBS ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${OPENGL_gl_LIBRARY})
|
||||
set(GRAPHICS_EXT_LIBS ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY} ${OPENGL_gl_LIBRARY})
|
||||
if(SFML_OS_LINUX)
|
||||
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${X11_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# add preprocessor symbols
|
||||
add_definitions(-DGLEW_STATIC -DSTBI_FAILURE_USERMSG)
|
||||
|
Loading…
Reference in New Issue
Block a user