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