mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
FindSFML.cmake is now installed to the same directory as other SFML files, not to <cmake install>/Modules anymore (admin rights problems)
This commit is contained in:
parent
00147856da
commit
d943f22c93
224
CMakeLists.txt
224
CMakeLists.txt
@ -31,14 +31,14 @@ set(BUILD_EXAMPLES FALSE CACHE BOOL "TRUE to build the SFML examples, FALSE to i
|
|||||||
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
set(BUILD_DOC FALSE CACHE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
|
||||||
|
|
||||||
# Mac OS X specific options
|
# Mac OS X specific options
|
||||||
if(MACOSX)
|
if(MACOSX)
|
||||||
# add an option to build frameworks instead of dylibs (release only)
|
# add an option to build frameworks instead of dylibs (release only)
|
||||||
set(BUILD_FRAMEWORKS FALSE CACHE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
set(BUILD_FRAMEWORKS FALSE CACHE BOOL "TRUE to build SFML as frameworks libraries (release only), FALSE to build according to BUILD_SHARED_LIBS")
|
||||||
|
|
||||||
# add an option to let the user specify a custom directory for frameworks installation (SFML, sndfile, ...)
|
# add an option to let the user specify a custom directory for frameworks installation (SFML, sndfile, ...)
|
||||||
set(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" CACHE STRING "Frameworks installation directory")
|
set(CMAKE_INSTALL_FRAMEWORK_PREFIX "/Library/Frameworks" CACHE STRING "Frameworks installation directory")
|
||||||
|
|
||||||
# add an option to automatically install Xcode 4 templates
|
# add an option to automatically install Xcode 4 templates
|
||||||
set(INSTALL_XCODE4_TEMPLATES FALSE CACHE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it")
|
set(INSTALL_XCODE4_TEMPLATES FALSE CACHE BOOL "TRUE to automatically install the Xcode 4 templates, FALSE to do nothing about it")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -71,59 +71,59 @@ endif()
|
|||||||
# disable the rpath stuff
|
# disable the rpath stuff
|
||||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
|
|
||||||
# Setup Mac OS X stuff
|
# Setup Mac OS X stuff
|
||||||
if(MACOSX)
|
if(MACOSX)
|
||||||
# multi arch support - by default : i386 and x86_64
|
# multi arch support - by default : i386 and x86_64
|
||||||
if(NOT CMAKE_OSX_ARCHITECTURES)
|
if(NOT CMAKE_OSX_ARCHITECTURES)
|
||||||
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "Build architectures for OSX" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# multi SDK support - by default we choose the older SDK available starting by 10.5 SDK
|
# multi SDK support - by default we choose the older SDK available starting by 10.5 SDK
|
||||||
if(NOT OSX_CONFIG_HAS_BEEN_RUN_BEFORE)
|
if(NOT OSX_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||||
if(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
if(EXISTS /Developer/SDKs/MacOSX10.5.sdk)
|
||||||
# target 10.5 system
|
# target 10.5 system
|
||||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk"
|
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.5.sdk"
|
||||||
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
||||||
FORCE)
|
FORCE)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5"
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.5"
|
||||||
CACHE STRING "Minimum OS X version to target for deployment (at runtime); ewer APIs weak linked."
|
CACHE STRING "Minimum OS X version to target for deployment (at runtime); ewer APIs weak linked."
|
||||||
FORCE)
|
FORCE)
|
||||||
elseif(EXISTS /Developer/SDKs/MacOSX10.6.sdk)
|
elseif(EXISTS /Developer/SDKs/MacOSX10.6.sdk)
|
||||||
# target 10.6 system
|
# target 10.6 system
|
||||||
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk"
|
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk"
|
||||||
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
CACHE STRING "The product will be built against the headers and libraries located inside the indicated SDK. Set to empty string for default value."
|
||||||
FORCE)
|
FORCE)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
|
||||||
CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked."
|
CACHE STRING "Minimum OS X version to target for deployment (at runtime); newer APIs weak linked."
|
||||||
FORCE)
|
FORCE)
|
||||||
else()
|
else()
|
||||||
# use default SDK.
|
# use default SDK.
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# note : we use OSX_CONFIG_HAS_BEEN_RUN_BEFORE to be able to let the user set his/her custom settings
|
# note : we use OSX_CONFIG_HAS_BEEN_RUN_BEFORE to be able to let the user set his/her custom settings
|
||||||
# so we don't always have to FORCE the value of CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT
|
# so we don't always have to FORCE the value of CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT
|
||||||
set(OSX_CONFIG_HAS_BEEN_RUN_BEFORE TRUE
|
set(OSX_CONFIG_HAS_BEEN_RUN_BEFORE TRUE
|
||||||
CACHE BOOL "Don't edit this value; you should instead empty your cache."
|
CACHE BOOL "Don't edit this value; you should instead empty your cache."
|
||||||
FORCE)
|
FORCE)
|
||||||
mark_as_advanced(OSX_CONFIG_HAS_BEEN_RUN_BEFORE)
|
mark_as_advanced(OSX_CONFIG_HAS_BEEN_RUN_BEFORE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# BUILD_FRAMEWORKS needs two things :
|
# BUILD_FRAMEWORKS needs two things :
|
||||||
# first, it's available only for release
|
# first, it's available only for release
|
||||||
# (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible)
|
# (because cmake currently doesn't allow specifying a custom framework name so XXX-d is not possible)
|
||||||
# secondly, it works only with BUILD_SHARED_LIBS enabled
|
# secondly, it works only with BUILD_SHARED_LIBS enabled
|
||||||
if(BUILD_FRAMEWORKS)
|
if(BUILD_FRAMEWORKS)
|
||||||
# requirement #1
|
# requirement #1
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
message(WARNING "CMAKE_BUILD_TYPE should be \"Release\" when BUILD_FRAMEWORKS is TRUE")
|
message(WARNING "CMAKE_BUILD_TYPE should be \"Release\" when BUILD_FRAMEWORKS is TRUE")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# requirement #2
|
# requirement #2
|
||||||
if(NOT BUILD_SHARED_LIBS)
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
message(WARNING "BUILD_SHARED_LIBS should be TRUE when BUILD_FRAMEWORKS is TRUE")
|
message(WARNING "BUILD_SHARED_LIBS should be TRUE when BUILD_FRAMEWORKS is TRUE")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -136,59 +136,59 @@ if(BUILD_DOC)
|
|||||||
add_subdirectory(doc)
|
add_subdirectory(doc)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# setup the install rules
|
# setup the install rules
|
||||||
if(NOT BUILD_FRAMEWORKS)
|
if(NOT BUILD_FRAMEWORKS)
|
||||||
install(DIRECTORY include
|
install(DIRECTORY include
|
||||||
DESTINATION .
|
DESTINATION .
|
||||||
COMPONENT devel
|
COMPONENT devel
|
||||||
PATTERN ".svn" EXCLUDE)
|
PATTERN ".svn" EXCLUDE)
|
||||||
else()
|
else()
|
||||||
# find only "root" headers
|
# find only "root" headers
|
||||||
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")
|
file(GLOB SFML_HEADERS RELATIVE ${PROJECT_SOURCE_DIR} "include/SFML/*")
|
||||||
|
|
||||||
# in fact we have to fool cmake to copy all the headers in subdirectories
|
# in fact we have to fool cmake to copy all the headers in subdirectories
|
||||||
# to do that we have to add the "root" headers to the PUBLIC_HEADER
|
# to do that we have to add the "root" headers to the PUBLIC_HEADER
|
||||||
# then we can run a post script to copy the remaining headers
|
# then we can run a post script to copy the remaining headers
|
||||||
|
|
||||||
# we need a dummy file in order to compile the framework
|
# we need a dummy file in order to compile the framework
|
||||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp
|
||||||
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
|
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
|
||||||
|
|
||||||
set(SFML_SOURCES ${SFML_HEADERS})
|
set(SFML_SOURCES ${SFML_HEADERS})
|
||||||
list(APPEND SFML_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
|
list(APPEND SFML_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp)
|
||||||
|
|
||||||
# create SFML.framework
|
# create SFML.framework
|
||||||
add_library(SFML ${SFML_SOURCES})
|
add_library(SFML ${SFML_SOURCES})
|
||||||
|
|
||||||
# edit target properties
|
# edit target properties
|
||||||
set_target_properties(SFML PROPERTIES
|
set_target_properties(SFML PROPERTIES
|
||||||
FRAMEWORK TRUE
|
FRAMEWORK TRUE
|
||||||
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||||
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.SFML
|
MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.SFML
|
||||||
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||||
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
|
||||||
PUBLIC_HEADER "${SFML_HEADERS}")
|
PUBLIC_HEADER "${SFML_HEADERS}")
|
||||||
|
|
||||||
# add the remaining headers
|
# add the remaining headers
|
||||||
add_custom_command(TARGET SFML
|
add_custom_command(TARGET SFML
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* SFML.framework/Versions/2.0.0/Headers)
|
COMMAND cp -r ${PROJECT_SOURCE_DIR}/include/SFML/* SFML.framework/Versions/2.0.0/Headers)
|
||||||
|
|
||||||
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
# adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
|
||||||
# NOTE : it's not required to link agains SFML.framework
|
# NOTE : it's not required to link agains SFML.framework
|
||||||
set_target_properties(SFML PROPERTIES
|
set_target_properties(SFML PROPERTIES
|
||||||
BUILD_WITH_INSTALL_RPATH 1
|
BUILD_WITH_INSTALL_RPATH 1
|
||||||
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
INSTALL_NAME_DIR "@executable_path/../Frameworks")
|
||||||
|
|
||||||
# install rule
|
# install rule
|
||||||
install(TARGETS SFML
|
install(TARGETS SFML
|
||||||
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX}
|
||||||
COMPONENT devel)
|
COMPONENT devel)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${CMAKE_ROOT}/Modules)
|
install(FILES cmake/Modules/FindSFML.cmake DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules)
|
||||||
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
|
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
|
||||||
|
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
if(ARCH_32BITS)
|
if(ARCH_32BITS)
|
||||||
install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin)
|
install(FILES extlibs/bin/x86/libsndfile-1.dll DESTINATION bin)
|
||||||
@ -198,9 +198,9 @@ if(WINDOWS)
|
|||||||
install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin)
|
install(FILES extlibs/bin/x64/openal32.dll DESTINATION bin)
|
||||||
endif()
|
endif()
|
||||||
elseif(MACOSX)
|
elseif(MACOSX)
|
||||||
install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
install(DIRECTORY extlibs/libs-osx/Frameworks/sndfile.framework DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
|
||||||
|
|
||||||
if(INSTALL_XCODE4_TEMPLATES)
|
if(INSTALL_XCODE4_TEMPLATES)
|
||||||
install(DIRECTORY xcode/templates/SFML DESTINATION $ENV{HOME}/Library/Developer/Xcode/Templates)
|
install(DIRECTORY xcode/templates/SFML DESTINATION $ENV{HOME}/Library/Developer/Xcode/Templates)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user