CMakeLists.txt (5590B)
1 # GRAPHITE2 LICENSING 2 # 3 # Copyright 2010, SIL International 4 # All rights reserved. 5 # 6 # This library is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU Lesser General Public License as published 8 # by the Free Software Foundation; either version 2.1 of License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 # Lesser General Public License for more details. 15 # 16 # You should also have received a copy of the GNU Lesser General Public 17 # License along with this library in the file named "LICENSE". 18 # If not, write to the Free Software Foundation, 51 Franklin Street, 19 # Suite 500, Boston, MA 02110-1335, USA or visit their web page on the 20 # internet at http://www.fsf.org/licenses/lgpl.html. 21 22 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR) 23 project(graphite2_core) 24 cmake_policy(SET CMP0012 NEW) 25 INCLUDE(CheckCXXSourceCompiles) 26 27 set(GRAPHITE_API_CURRENT 3) 28 set(GRAPHITE_API_REVISION 2) 29 set(GRAPHITE_API_AGE 1) 30 set(GRAPHITE_VERSION ${GRAPHITE_API_CURRENT}.${GRAPHITE_API_REVISION}.${GRAPHITE_API_AGE}) 31 set(GRAPHITE_SO_VERSION ${GRAPHITE_API_CURRENT}) 32 33 include(TestBigEndian) 34 35 include_directories(${PROJECT_SOURCE_DIR}) 36 37 set(FILEFACE FileFace.cpp) 38 if (GRAPHITE2_NFILEFACE) 39 add_definitions(-DGRAPHITE2_NFILEFACE) 40 set(FILEFACE) 41 endif() 42 43 set(TRACING json.cpp) 44 if (GRAPHITE2_NTRACING) 45 add_definitions(-DGRAPHITE2_NTRACING) 46 set(TRACING) 47 endif() 48 49 if (GRAPHITE2_TELEMETRY) 50 add_definitions(-DGRAPHITE2_TELEMETRY) 51 endif() 52 53 if (NOT BUILD_SHARED_LIBS) 54 add_definitions(-DGRAPHITE2_STATIC) 55 endif() 56 57 set(GRAPHITE_HEADERS 58 ../include/graphite2/Font.h 59 ../include/graphite2/Segment.h 60 ../include/graphite2/Types.h 61 ../include/graphite2/Log.h 62 ) 63 64 file(GLOB PRIVATE_HEADERS inc/*.h) 65 66 add_library(graphite2 67 ${GRAPHITE2_VM_TYPE}_machine.cpp 68 gr_char_info.cpp 69 gr_features.cpp 70 gr_face.cpp 71 gr_font.cpp 72 gr_logging.cpp 73 gr_segment.cpp 74 gr_slot.cpp 75 CmapCache.cpp 76 Code.cpp 77 Collider.cpp 78 Decompressor.cpp 79 Face.cpp 80 FeatureMap.cpp 81 Font.cpp 82 GlyphFace.cpp 83 GlyphCache.cpp 84 Intervals.cpp 85 Justifier.cpp 86 NameTable.cpp 87 Pass.cpp 88 Position.cpp 89 Segment.cpp 90 Silf.cpp 91 Slot.cpp 92 Sparse.cpp 93 TtfUtil.cpp 94 UtfCodec.cpp 95 ${FILEFACE} 96 ${TRACING}) 97 98 set_target_properties(graphite2 PROPERTIES PUBLIC_HEADER "${GRAPHITE_HEADERS}" 99 SOVERSION ${GRAPHITE_SO_VERSION} 100 VERSION ${GRAPHITE_VERSION} 101 LT_VERSION_CURRENT ${GRAPHITE_API_CURRENT} 102 LT_VERSION_REVISION ${GRAPHITE_API_REVISION} 103 LT_VERSION_AGE ${GRAPHITE_API_AGE}) 104 105 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") 106 set_target_properties(graphite2 PROPERTIES 107 COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wendif-labels -Wshadow -Wctor-dtor-privacy -Wnon-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden" 108 LINK_FLAGS "-nodefaultlibs ${GRAPHITE_LINK_FLAGS}" 109 LINKER_LANGUAGE C) 110 if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86") 111 add_definitions(-mfpmath=sse -msse2) 112 endif() 113 if (CMAKE_COMPILER_IS_GNUCXX) 114 add_definitions(-Wno-class-memaccess -Wdouble-promotion) 115 endif() 116 message(STATUS "Compiler ID is: ${CMAKE_CXX_COMPILER_ID}") 117 if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") 118 add_definitions(-Wimplicit-fallthrough -Wshorten-64-to-32) 119 endif() 120 if (${CMAKE_CXX_COMPILER} MATCHES ".*mingw.*") 121 target_link_libraries(graphite2 kernel32 msvcr90 mingw32 gcc user32) 122 else (${CMAKE_CXX_COMPILER} MATCHES ".*mingw.*") 123 if (GRAPHITE2_SANITIZERS) 124 target_link_libraries(graphite2 c gcc_s) 125 else () 126 target_link_libraries(graphite2 c gcc) 127 endif () 128 endif() 129 include(Graphite) 130 if (BUILD_SHARED_LIBS) 131 nolib_test(stdc++ $<TARGET_SONAME_FILE:graphite2>) 132 endif () 133 set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") 134 CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") 135 endif() 136 137 if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 138 set_target_properties(graphite2 PROPERTIES 139 COMPILE_FLAGS "-Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -Wendif-labels -Wshadow -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -fno-rtti -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden" 140 LINK_FLAGS "-nodefaultlibs" 141 LINKER_LANGUAGE C) 142 if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86|i.86") 143 add_definitions(-mfpmath=sse -msse2) 144 endif() 145 target_link_libraries(graphite2 c) 146 include(Graphite) 147 nolib_test(stdc++ $<TARGET_SONAME_FILE:graphite2>) 148 set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "") 149 CREATE_LIBTOOL_FILE(graphite2 "/lib${LIB_SUFFIX}") 150 endif() 151 152 if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") 153 set_target_properties(graphite2 PROPERTIES 154 COMPILE_DEFINITIONS "_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;UNICODE;GRAPHITE2_EXPORTING") 155 endif() 156 157 158 install(TARGETS graphite2 EXPORT graphite2 LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} PUBLIC_HEADER DESTINATION include/graphite2 RUNTIME DESTINATION bin) 159 install(EXPORT graphite2 DESTINATION share/graphite2 NAMESPACE gr2_)