1######################################################################## 2# CMake build script for Google Typography sfntly. 3cmake_minimum_required(VERSION 2.6.2) 4set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "good configs" FORCE) 5set(CMAKE_LEGACY_CYGWIN_WIN32 0) 6 7project(sfntly) 8 9set(GCC_OR_CLANG ((CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR CMAKE_COMPILER_IS_GNUCXX)) 10 11# For gcc, make the default be debug build and valgrind friendly. 12if(GCC_OR_CLANG) 13 if(NOT CMAKE_BUILD_TYPE) 14 set(CMAKE_BUILD_TYPE Debug) 15 add_definitions("-DDEBUG -D_DEBUG -g -fno-inline -fno-omit-frame-pointer -fno-builtin") 16 endif(NOT CMAKE_BUILD_TYPE) 17endif(GCC_OR_CLANG) 18 19 set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib) 20 set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) 21 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ext/gtest/include ext/gtest 22 ${CMAKE_CURRENT_SOURCE_DIR}/src/sample ${CMAKE_CURRENT_SOURCE_DIR}/src/sample/subtly) 23 24# The following simulates Chrome compilation flags 25 add_definitions(-DSFNTLY_NO_EXCEPTION) 26if(GCC_OR_CLANG) 27 add_definitions(-D__wur=__attribute__\(\(warn_unused_result\)\) -Wall -Werror -fno-exceptions) 28endif(GCC_OR_CLANG) 29 30# Use STL for TinyXML library 31 add_definitions(-DTIXML_USE_STL) 32 33# Enable CMap and Bitmap handling 34 add_definitions(-DSFNTLY_EXPERIMENTAL) 35 36# VC specific flags 37if(MSVC10 OR MSVC90) 38 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-") 39 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-") 40 add_definitions(-D_UNICODE -DUNICODE) 41 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/icu/include) 42 link_directories(${CMAKE_CURRENT_SOURCE_DIR}/ext/icu/lib) 43endif(MSVC10 OR MSVC90) 44 45 file(GLOB SFNTLY_CORE_FILES src/sfntly/*.h src/sfntly/*.cc) 46 file(GLOB SFNTLY_PORT_FILES src/sfntly/port/*.h src/sfntly/port/*.cc) 47 file(GLOB SFNTLY_DATA_FILES src/sfntly/data/*.h src/sfntly/data/*.cc) 48 file(GLOB SFNTLY_MATH_FILES src/sfntly/math/*.h src/sfntly/math/*.cc) 49 file(GLOB SFNTLY_TABLE_COMMON_FILES src/sfntly/table/*.h src/sfntly/table/*.cc) 50 file(GLOB SFNTLY_TABLE_BITMAP_FILES src/sfntly/table/bitmap/*.h src/sfntly/table/bitmap/*.cc) 51 file(GLOB SFNTLY_TABLE_CORE_FILES src/sfntly/table/core/*.h src/sfntly/table/core/*.cc) 52 file(GLOB SFNTLY_TABLE_TTF_FILES src/sfntly/table/truetype/*.h src/sfntly/table/truetype/*.cc) 53 source_group(core FILES ${SFNTLY_CORE_FILES}) 54 source_group(ports FILES ${SFNTLY_PORT_FILES}) 55 source_group(data FILES ${SFNTLY_DATA_FILES}) 56 source_group(math FILES ${SFNTLY_MATH_FILES}) 57 source_group(table FILES ${SFNTLY_TABLE_COMMON_FILES}) 58 source_group(table\\bitmap FILES ${SFNTLY_TABLE_BITMAP_FILES}) 59 source_group(table\\core FILES ${SFNTLY_TABLE_CORE_FILES}) 60 source_group(table\\truetype FILES ${SFNTLY_TABLE_TTF_FILES}) 61 add_library(sfntly 62 ${SFNTLY_CORE_FILES} 63 ${SFNTLY_PORT_FILES} 64 ${SFNTLY_DATA_FILES} 65 ${SFNTLY_MATH_FILES} 66 ${SFNTLY_TABLE_COMMON_FILES} 67 ${SFNTLY_TABLE_BITMAP_FILES} 68 ${SFNTLY_TABLE_CORE_FILES} 69 ${SFNTLY_TABLE_TTF_FILES}) 70 file(GLOB_RECURSE SIMPLE_SUBSETTER src/sample/subsetter/*.h src/sample/subsetter/*.cc 71 src/sfntly/tools/*.h src/sfntly/tools/*.cc) 72 add_executable(subsetter ${SIMPLE_SUBSETTER}) 73 target_link_libraries(subsetter sfntly icuuc) 74if(GCC_OR_CLANG) 75 target_link_libraries(subsetter pthread) 76endif(GCC_OR_CLANG) 77 file(GLOB TINYXML src/test/tinyxml/*.cpp) 78 add_library(tinyxml 79 ${TINYXML}) 80 file(GLOB TEST_CASES src/test/*.cc src/test/autogenerated/*.cc) 81 file(GLOB CHROME_SUBSETTER_LIB 82 src/sample/chromium/subsetter_impl.h 83 src/sample/chromium/subsetter_impl.cc 84 src/sample/chromium/font_subsetter.cc 85 src/sample/chromium/font_subsetter.h) 86 add_executable(unit_test 87 ${TEST_CASES} ${CHROME_SUBSETTER_LIB} 88 ext/gtest/src/gtest-all.cc 89 ext/gtest/src/gtest_main.cc) 90 target_link_libraries(unit_test sfntly icuuc tinyxml) 91if(GCC_OR_CLANG) 92 target_link_libraries(unit_test pthread) 93endif(GCC_OR_CLANG) 94 # subtly targets 95 file(GLOB SUBTLY_FILES src/sample/subtly/*.h src/sample/subtly/*.cc) 96 file(GLOB SUBTLY_MAINS src/sample/subtly/*main.cc) 97 list(REMOVE_ITEM SUBTLY_FILES ${SUBTLY_MAINS}) 98 add_library(subtly 99 ${SUBTLY_FILES}) 100 add_executable(subtly_subsetter 101 src/sample/subtly/subsetter_main.cc) 102 target_link_libraries(subtly_subsetter subtly sfntly icuuc) 103if(GCC_OR_CLANG) 104 target_link_libraries(subtly_subsetter pthread) 105endif(GCC_OR_CLANG) 106 add_executable(subtly_merger 107 src/sample/subtly/merger_main.cc) 108 target_link_libraries(subtly_merger subtly sfntly icuuc) 109if(GCC_OR_CLANG) 110 target_link_libraries(subtly_merger pthread) 111endif(GCC_OR_CLANG) 112 add_executable(subtly_debug 113 src/sample/subtly/debug_main.cc) 114 target_link_libraries(subtly_debug subtly sfntly icuuc) 115if(GCC_OR_CLANG) 116 target_link_libraries(subtly_debug pthread) 117endif(GCC_OR_CLANG) 118 add_executable(chrome_subsetter 119 ${CHROME_SUBSETTER_LIB} 120 src/sample/chromium/chrome_subsetter.cc 121 ) 122 target_link_libraries(chrome_subsetter sfntly icuuc) 123 if(GCC_OR_CLANG) 124 target_link_libraries(chrome_subsetter pthread) 125 endif(GCC_OR_CLANG) 126