You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
5.2 KiB

########################################################################
# CMake build script for Google Typography sfntly.
cmake_minimum_required(VERSION 2.6.2)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "good configs" FORCE)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
project(sfntly)
set(GCC_OR_CLANG ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR CMAKE_COMPILER_IS_GNUCXX))
# For gcc, make the default be debug build and valgrind friendly.
if(GCC_OR_CLANG)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
add_definitions("-DDEBUG -D_DEBUG -g -fno-inline -fno-omit-frame-pointer -fno-builtin")
endif(NOT CMAKE_BUILD_TYPE)
endif(GCC_OR_CLANG)
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ext/gtest/include ext/gtest
${CMAKE_CURRENT_SOURCE_DIR}/src/sample ${CMAKE_CURRENT_SOURCE_DIR}/src/sample/subtly)
# The following simulates Chrome compilation flags
add_definitions(-DSFNTLY_NO_EXCEPTION)
if(GCC_OR_CLANG)
add_definitions(-D__wur=__attribute__\(\(warn_unused_result\)\) -Wall -Werror -fno-exceptions)
endif(GCC_OR_CLANG)
# Use STL for TinyXML library
add_definitions(-DTIXML_USE_STL)
# Enable CMap and Bitmap handling
add_definitions(-DSFNTLY_EXPERIMENTAL)
# VC specific flags
if(MSVC10 OR MSVC90)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo /W4 /WX /O2 /Ob2 /Oy /GF /Gm- /MT /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /GR-")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi /nologo /W4 /WX /Od /Oy- /RTC1 /MTd /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /GR-")
add_definitions(-D_UNICODE -DUNICODE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/icu/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/icu/lib)
endif(MSVC10 OR MSVC90)
file(GLOB SFNTLY_CORE_FILES src/sfntly/*.h src/sfntly/*.cc)
file(GLOB SFNTLY_PORT_FILES src/sfntly/port/*.h src/sfntly/port/*.cc)
file(GLOB SFNTLY_DATA_FILES src/sfntly/data/*.h src/sfntly/data/*.cc)
file(GLOB SFNTLY_MATH_FILES src/sfntly/math/*.h src/sfntly/math/*.cc)
file(GLOB SFNTLY_TABLE_COMMON_FILES src/sfntly/table/*.h src/sfntly/table/*.cc)
file(GLOB SFNTLY_TABLE_BITMAP_FILES src/sfntly/table/bitmap/*.h src/sfntly/table/bitmap/*.cc)
file(GLOB SFNTLY_TABLE_CORE_FILES src/sfntly/table/core/*.h src/sfntly/table/core/*.cc)
file(GLOB SFNTLY_TABLE_TTF_FILES src/sfntly/table/truetype/*.h src/sfntly/table/truetype/*.cc)
source_group(core FILES ${SFNTLY_CORE_FILES})
source_group(ports FILES ${SFNTLY_PORT_FILES})
source_group(data FILES ${SFNTLY_DATA_FILES})
source_group(math FILES ${SFNTLY_MATH_FILES})
source_group(table FILES ${SFNTLY_TABLE_COMMON_FILES})
source_group(table\\bitmap FILES ${SFNTLY_TABLE_BITMAP_FILES})
source_group(table\\core FILES ${SFNTLY_TABLE_CORE_FILES})
source_group(table\\truetype FILES ${SFNTLY_TABLE_TTF_FILES})
add_library(sfntly
${SFNTLY_CORE_FILES}
${SFNTLY_PORT_FILES}
${SFNTLY_DATA_FILES}
${SFNTLY_MATH_FILES}
${SFNTLY_TABLE_COMMON_FILES}
${SFNTLY_TABLE_BITMAP_FILES}
${SFNTLY_TABLE_CORE_FILES}
${SFNTLY_TABLE_TTF_FILES})
file(GLOB_RECURSE SIMPLE_SUBSETTER src/sample/subsetter/*.h src/sample/subsetter/*.cc
src/sfntly/tools/*.h src/sfntly/tools/*.cc)
add_executable(subsetter ${SIMPLE_SUBSETTER})
target_link_libraries(subsetter sfntly icuuc)
if(GCC_OR_CLANG)
target_link_libraries(subsetter pthread)
endif(GCC_OR_CLANG)
file(GLOB TINYXML src/test/tinyxml/*.cpp)
add_library(tinyxml
${TINYXML})
file(GLOB TEST_CASES src/test/*.cc src/test/autogenerated/*.cc)
file(GLOB CHROME_SUBSETTER_LIB
src/sample/chromium/subsetter_impl.h
src/sample/chromium/subsetter_impl.cc
src/sample/chromium/font_subsetter.cc
src/sample/chromium/font_subsetter.h)
add_executable(unit_test
${TEST_CASES} ${CHROME_SUBSETTER_LIB}
ext/gtest/src/gtest-all.cc
ext/gtest/src/gtest_main.cc)
target_link_libraries(unit_test sfntly icuuc tinyxml)
if(GCC_OR_CLANG)
target_link_libraries(unit_test pthread)
endif(GCC_OR_CLANG)
# subtly targets
file(GLOB SUBTLY_FILES src/sample/subtly/*.h src/sample/subtly/*.cc)
file(GLOB SUBTLY_MAINS src/sample/subtly/*main.cc)
list(REMOVE_ITEM SUBTLY_FILES ${SUBTLY_MAINS})
add_library(subtly
${SUBTLY_FILES})
add_executable(subtly_subsetter
src/sample/subtly/subsetter_main.cc)
target_link_libraries(subtly_subsetter subtly sfntly icuuc)
if(GCC_OR_CLANG)
target_link_libraries(subtly_subsetter pthread)
endif(GCC_OR_CLANG)
add_executable(subtly_merger
src/sample/subtly/merger_main.cc)
target_link_libraries(subtly_merger subtly sfntly icuuc)
if(GCC_OR_CLANG)
target_link_libraries(subtly_merger pthread)
endif(GCC_OR_CLANG)
add_executable(subtly_debug
src/sample/subtly/debug_main.cc)
target_link_libraries(subtly_debug subtly sfntly icuuc)
if(GCC_OR_CLANG)
target_link_libraries(subtly_debug pthread)
endif(GCC_OR_CLANG)
add_executable(chrome_subsetter
${CHROME_SUBSETTER_LIB}
src/sample/chromium/chrome_subsetter.cc
)
target_link_libraries(chrome_subsetter sfntly icuuc)
if(GCC_OR_CLANG)
target_link_libraries(chrome_subsetter pthread)
endif(GCC_OR_CLANG)