From 02f2170432bf9f2c4bfa39d283b7152539edb814 Mon Sep 17 00:00:00 2001 From: Alexey Petruchik Date: Fri, 16 May 2014 08:09:43 +0200 Subject: [PATCH] [cmake] Add option to build OS X framework. * CMakeLists.txt: Update accordingly. * builds/mac/freetype-Info.plist: New file. --- CMakeLists.txt | 48 +++++++++++++++++++++++++++++++--- ChangeLog | 8 ++++++ builds/mac/freetype-Info.plist | 36 +++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 builds/mac/freetype-Info.plist diff --git a/CMakeLists.txt b/CMakeLists.txt index 85e8e18f5..df77d96bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,11 +16,16 @@ # # cmake CMakeLists.txt # -# to create a Makefile that builds a static version of the library. For a -# dynamic library, use +# to create a Makefile that builds a static version of the library. +# +# For a dynamic library, use # # cmake CMakeLists.txt -DBUILD_SHARED_LIBS:BOOL=true # +# For a framework on OS X, use +# +# cmake CMakeLists.txt -DBUILD_FRAMEWORK:BOOL=true -G Xcode +# # instead. Please refer to the cmake manual for further options, in # particular, how to modify compilation and linking parameters. # @@ -39,6 +44,14 @@ cmake_minimum_required(VERSION 2.6) project(freetype) +if (BUILD_FRAMEWORK) + if (NOT "${CMAKE_GENERATOR}" STREQUAL "Xcode") + message(FATAL_ERROR "You should use Xcode generator with BUILD_FRAMEWORK enabled") + endif () + set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_64_BIT)") + set(BUILD_SHARED_LIBS ON) +endif () + set(VERSION_MAJOR "2") set(VERSION_MINOR "5") set(VERSION_PATCH "3") @@ -63,6 +76,10 @@ execute_process( OUTPUT_FILE ${PROJECT_BINARY_DIR}/include/freetype2/ftconfig.h ) +file(GLOB PUBLIC_HEADERS "include/*.h") +file(GLOB PUBLIC_CONFIG_HEADERS "include/config/*.h") +file(GLOB PRIVATE_HEADERS "include/internal/*.h") + set(BASE_SRCS src/autofit/autofit.c src/base/ftadvanc.c @@ -126,7 +143,31 @@ include_directories("src/raster") include_directories("src/psaux") include_directories("src/psnames") -add_library(freetype ${BASE_SRCS}) +if (BUILD_FRAMEWORK) + set(BASE_SRCS + ${BASE_SRCS} + builds/mac/freetype-Info.plist + ) +endif () + +add_library(freetype + ${PUBLIC_HEADERS} + ${PUBLIC_CONFIG_HEADERS} + ${PRIVATE_HEADERS} + ${BASE_SRCS} +) + +if (BUILD_FRAMEWORK) + set_property(SOURCE ${PUBLIC_CONFIG_HEADERS} + PROPERTY MACOSX_PACKAGE_LOCATION Headers/config + ) + set_target_properties(freetype PROPERTIES + FRAMEWORK TRUE + MACOSX_FRAMEWORK_INFO_PLIST builds/mac/freetype-Info.plist + PUBLIC_HEADER "${PUBLIC_HEADERS}" + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + ) +endif () # Installations # Note the trailing slash in the argument to the `DIRECTORY' directive @@ -138,6 +179,7 @@ install(TARGETS freetype RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib + FRAMEWORK DESTINATION Library/Frameworks ) # Packaging diff --git a/ChangeLog b/ChangeLog index b9cd440a3..16c9cfb23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-05-16 Alexey Petruchik + + [cmake] Add option to build OS X framework. + + * CMakeLists.txt: Update accordingly. + + * builds/mac/freetype-Info.plist: New file. + 2014-05-13 Pavel Koshevoy * CMakeLists.txt (BASE_SRCS): Add missing `ftbdf.c'. diff --git a/builds/mac/freetype-Info.plist b/builds/mac/freetype-Info.plist new file mode 100644 index 000000000..b3d114dad --- /dev/null +++ b/builds/mac/freetype-Info.plist @@ -0,0 +1,36 @@ + + + + + + + CFBundleDevelopmentRegion + English + + CFBundleExecutable + FreeType + + CFBundleGetInfoString + FreeType ${PROJECT_VERSION} + + CFBundleInfoDictionaryVersion + 6.0 + + CFBundleName + FreeType + + CFBundlePackageType + FMWK + + CFBundleShortVersionString + ${PROJECT_VERSION} + + CFBundleSignature + ???? + + CFBundleVersion + ${PROJECT_VERSION} + + +