Cmake now is able to build SFML libraries as frameworks (closes #12)

Cmake can now automatically install the Xcode templates
This commit is contained in:
Marco Antognini 2011-08-20 12:14:55 +02:00
parent e5d635350e
commit e09db44906
3 changed files with 113 additions and 24 deletions

View file

@ -138,17 +138,29 @@ macro(sfml_add_library target)
target_link_libraries(${target} ${THIS_DEPENDS})
endif()
# build frameworks or dylibs
if(MACOSX AND BUILD_SHARED_LIBS)
if(BUILD_FRAMEWORKS)
# adapt target to build frameworks instead of dylibs
set_target_properties(${target} PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
else()
# adapt install directory to allow distributing dylibs in users frameworks
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@executable_path/../Frameworks")
endif()
endif()
# 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})
if (MACOSX)
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@executable_path/../Frameworks")
endif()
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
@ -160,7 +172,8 @@ macro(sfml_add_library target)
install(TARGETS ${target}
RUNTIME DESTINATION bin COMPONENT bin
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel)
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
endmacro()

View file

@ -11,7 +11,12 @@
# - SFML_INCLUDE_DIR, the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
#
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFMLDIR CMake variable or environment variable
# to tell CMake where SFML is.