From 3fbbf7a4abf1a609a0e5d86ed79b348831313f98 Mon Sep 17 00:00:00 2001 From: lasconic Date: Tue, 20 Dec 2016 21:57:13 +0100 Subject: [PATCH] Add option to use system FreeType (see PR #2915) --- CMakeLists.txt | 33 +++++++++++++++++++++++++++++---- mscore/CMakeLists.txt | 22 +++++++++++++++------- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2e91f3fe2..067af5c0da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,6 +94,7 @@ option(OCR "Enable OCR, requires OMR" OFF) # Requires tesser option(SOUNDFONT3 "Ogg Vorbis compressed fonts" ON) # Enable Ogg Vorbis compressed fonts, requires Ogg & Vorbis option(HAS_AUDIOFILE "Enable audio export" ON) # Requires libsndfile option(USE_SYSTEM_QTSINGLEAPPLICATION "Use system QtSingleApplication" OFF) +option(USE_SYSTEM_FREETYPE "Use system FreeType" OFF) # requires freetype >= 2.5.2, does not work on win option(BUILD_LAME "Enable MP3 export" ON) # Requires libmp3lame (non-free), call CMake with -DBUILD_LAME="OFF" to disable SET(JACK_LONGNAME "JACK (Jack Audio Connection Kit)") @@ -198,6 +199,25 @@ else (MINGW OR APPLE) SET(Mscore_SHARE_NAME "share/") endif (MINGW OR APPLE) +## +## freetype2 >= 2.5.2 +## + +if (USE_SYSTEM_FREETYPE) + if (APPLE) + PKGCONFIG (freetype2 2.5.2 FREETYPE_INCLUDE_DIRS FREETYPE_LIBDIR FREETYPE_LIBRARIES FREETYPE_CPP) + if (FREETYPE_INCLUDE_DIRS) + STRING(REGEX REPLACE "\"" "" FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS}) + STRING(REGEX REPLACE "\"" "" FREETYPE_LIBDIR ${FREETYPE_LIBDIR}) + message("freetype2 detected ${FREETYPE_INCLUDE_DIRS} ${FREETYPE_LIBDIR} ${FREETYPE_LIBRARIES}") + else (FREETYPE_INCLUDE_DIRS) + message(FATAL_ERROR "freetype >= 2.5.2 is required\n") + endif (FREETYPE_INCLUDE_DIRS) + else (APPLE) + find_package(Freetype REQUIRED) + endif (APPLE) +endif (USE_SYSTEM_FREETYPE) + ## ## ALSA >= 1.0.0 ## @@ -571,8 +591,9 @@ if (OSC) subdirs (thirdparty/ofqf) endif (OSC) -subdirs (thirdparty/freetype) - +if (NOT USE_SYSTEM_FREETYPE) + subdirs (thirdparty/freetype) +endif (NOT USE_SYSTEM_FREETYPE) ## ## Includes @@ -587,10 +608,14 @@ include_directories( ${VORBIS_INCDIR} ${SNDFILE_INCDIR} ${LAME_INCLUDE_DIR} -# ${FREETYPE_INCLUDE_DIRS} - ${PROJECT_SOURCE_DIR}/thirdparty/freetype/include ) +if (USE_SYSTEM_FREETYPE) + include_directories(${FREETYPE_INCLUDE_DIRS}) +else (USE_SYSTEM_FREETYPE) + include_directories(${PROJECT_SOURCE_DIR}/thirdparty/freetype/include) +endif (USE_SYSTEM_FREETYPE) + if (OMR) include_directories(${PROJECT_SOURCE_DIR}/thirdparty/poppler) include_directories(${PROJECT_SOURCE_DIR}/thirdparty/poppler/poppler) diff --git a/mscore/CMakeLists.txt b/mscore/CMakeLists.txt index fc81adf5d4..db746524a1 100644 --- a/mscore/CMakeLists.txt +++ b/mscore/CMakeLists.txt @@ -25,8 +25,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/thirdparty -# ${PROJECT_SOURCE_DIR}/thirdparty/freetype/include - ${FREETYPE_INCLUDE_DIRS} ${QTSINGLEAPPLICATION_INCLUDE_DIRS} ) @@ -321,6 +319,10 @@ target_link_libraries(mscore kqoauth ) +if (USE_SYSTEM_FREETYPE) + target_link_libraries(mscore ${FREETYPE_LIBRARIES}) +endif (USE_SYSTEM_FREETYPE) + if (MINGW) set(MSCORE_OUTPUT_NAME ${MUSESCORE_NAME}) elseif (MSCORE_INSTALL_SUFFIX) @@ -340,13 +342,13 @@ endif (MSCORE_OUTPUT_NAME) if (ZERBERUS) target_link_libraries(mscore zerberus synthesizer) -endif () +endif (ZERBERUS) if (AEOLUS) target_link_libraries(mscore aeolus) -endif () +endif (AEOLUS) if (SOUNDFONT3) target_link_libraries(mscore ${VORBIS_LIB} ${OGG_LIB}) -endif () +endif (SOUNDFONT3) if (HAS_AUDIOFILE) target_link_libraries(mscore audiofile ${SNDFILE_LIB}) @@ -360,7 +362,7 @@ if (APPLE) #set_target_properties (mscore # PROPERTIES # XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym") -endif(APPLE) +endif (APPLE) if (OSC) target_link_libraries(mscore ofqf) @@ -483,11 +485,17 @@ else (MINGW) target_link_libraries(mscore ${ALSA_LIB} ${QT_LIBRARIES} - mscore_freetype z dl pthread ) + + if (USE_SYSTEM_FREETYPE) + target_link_libraries(mscore freetype) + else (USE_SYSTEM_FREETYPE) + target_link_libraries(mscore mscore_freetype) + endif (USE_SYSTEM_FREETYPE) + if (USE_PORTAUDIO) target_link_libraries(mscore ${PORTAUDIO_LIB}) endif (USE_PORTAUDIO)