Cmake build: Adapt handling of mytheslib to automek behaviour

The added cmake-parameter is:
  -DLYX_EXTERNAL_MYTHES=<value>
where <value> is one of
  AUTO	(Default) Search first on system for mythes (lib and include)
  ON	Use installed only (errors if not installed)
  OFF	Compile the provided source in 3rdparty
This commit is contained in:
Kornel Benko 2017-03-07 14:27:08 +01:00
parent dc126bad04
commit 5d3d26b024
5 changed files with 51 additions and 18 deletions

25
3rdparty/mythes/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)
set(VERSION "1.2.5")
set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${VERSION})
file(GLOB support_mythes_sources ${SRCDIR}/*.cxx)
file(GLOB support_mythes_headers ${SRCDIR}/*.hxx)
include_directories(${VERSION})
#============================================================================
# lyxmytheslib
#============================================================================
add_library(mytheslibstatic STATIC ${support_mythes_sources} ${support_mythes_headers} )
set(MYTHESLIB_LIBRARY mytheslibstatic CACHE STRING "Mytheslib library" FORCE)
set(MYTHESLIB_INCLUDE_DIR ${SRCDIR} CACHE STRING "Mytheslib include dir" FORCE)
set(MYTHESLIB_FOUND CACHE STRING "Mytheslib found" FORCE )
set_target_properties(mytheslibstatic PROPERTIES FOLDER "3rd_party")

View File

@ -143,10 +143,10 @@ LYX_OPTION(ENABLE_KEYTESTS "Enable for keytests" OFF ALL)
LYX_OPTION(ASAN "Use address sanitizer" OFF ALL)
LYX_COMBO(USE_QT "Use Qt version as frontend" QT4 QT5)
#LYX_OPTION(3RDPARTY_BUILD "Build 3rdparty libs" OFF ALL)
LYX_OPTION(EXTERNAL_Z "Do not build 3rdparty lib zlib" ON ALL)
LYX_OPTION(EXTERNAL_ICONV "Do not build 3rdparty lib iconvlib" ON ALL)
LYX_OPTION(EXTERNAL_HUNSPELL "Do not build 3rdparty lib hunspelllib" ON ALL)
LYX_OPTION(EXTERNAL_MYTHES "Do not build 3rdparty lib mytheslib" OFF ALL)
LYX_OPTION(EXTERNAL_Z "OFF := Build 3rdparty lib zlib" ON ALL)
LYX_OPTION(EXTERNAL_ICONV "OFF := Build 3rdparty lib iconvlib" ON ALL)
LYX_OPTION(EXTERNAL_HUNSPELL "OFF := Build 3rdparty lib hunspelllib" ON ALL)
LYX_COMBO(EXTERNAL_MYTHES "OFF := Build 3rdparty lib mytheslib" AUTO OFF ON)
# GCC specific
LYX_OPTION(PROFILE "Build profile version" OFF GCC)
@ -184,12 +184,6 @@ if(LYX_DMG)
set(LYX_CPACK ON)
endif()
if (LYX_EXTERNAL_MYTHES)
message(FATAL_ERROR "Compilation with system mythes not supported yet")
else()
set(MYTHES_DIR "${TOP_SRC_DIR}/3rdparty/mythes/1.2.5")
endif()
if(LYX_CPACK)
set(LYX_INSTALL ON)
endif()
@ -328,6 +322,7 @@ if(LYX_3RDPARTY_BUILD)
set(LYX_EXTERNAL_Z OFF CACHE BOOL "Build 3rdparty lib zlib" FORCE)
set(LYX_EXTERNAL_ICONV OFF CACHE BOOL "Build 3rdparty iconvlib" FORCE)
set(LYX_EXTERNAL_HUNSPELL OFF CACHE BOOL "Build 3rdparty hunspelllib" FORCE)
set(LYX_EXTERNAL_MYTHES OFF CACHE STRING "Build 3rdparty mytheslib" FORCE)
endif()
macro(setstripped _varname)
@ -676,6 +671,22 @@ include_directories(${TOP_BINARY_DIR} ${TOP_SRC_DIR}/src)
set(Spelling_FOUND OFF)
set(Include_used_spellchecker) # String will be inserted into config.h
if (LYX_EXTERNAL_MYTHES MATCHES "AUTO")
# try system library first
find_package(MyThesLIB)
if (MYTHESLIB_FOUND)
set(LYX_EXTERNAL_MYTHES CACHE STRING "ON" FORCE)
else()
set(LYX_EXTERNAL_MYTHES CACHE STRING "OFF" FORCE)
endif()
endif()
if (LYX_EXTERNAL_MYTHES MATCHES "ON")
find_package(MyThesLIB REQUIRED)
else()
add_subdirectory(3rdparty/mythes)
endif()
set(MYTHES_DIR ${MYTHESLIB_INCLUDE_DIR})
if(NOT LYX_EXTERNAL_HUNSPELL)
add_subdirectory(3rdparty/hunspell)
add_definitions(-DHUNSPELL_STATIC)

View File

@ -15,7 +15,7 @@ find_path(MYTHESLIB_INCLUDE_DIR ${MYTHES_H}
/usr/include
/usr/local/include)
set(POTENTIAL_MYTHES_LIBS mythes)
set(POTENTIAL_MYTHES_LIBS mythes-1.2)
find_library(MYTHESLIB_LIBRARY NAMES ${POTENTIAL_MYTHES_LIBS}
PATHS ${SYSTEM_LIB_DIRS} )

View File

@ -130,6 +130,7 @@ target_link_libraries(${_lyx}
frontend_qt
graphics
support
${MYTHESLIB_LIBRARY}
${ICONV_LIBRARY}
${LYX_QTMAIN_LIBRARY}
${vld_dll})

View File

@ -18,9 +18,6 @@ endif()
file(GLOB support_headers ${TOP_SRC_DIR}/src/support/${LYX_HPP_FILES})
file(GLOB support_mythes_sources ${MYTHES_DIR}/*.cxx)
file(GLOB support_mythes_headers ${MYTHES_DIR}/*.hxx)
file(GLOB support_linkback_sources ${TOP_SRC_DIR}/src/support/linkback/*.m*)
file(GLOB support_linkback_headers ${TOP_SRC_DIR}/src/support/linkback/*.h)
@ -58,15 +55,14 @@ lyx_automoc(${support_sources})
include_directories(
${TOP_SRC_DIR}/src/support
${TOP_BINARY_DIR}/src/support
${MYTHES_DIR}
${QT_INCLUDES}
${ICONV_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR})
if(NOT LYX_MERGE_FILES)
set(support_sources ${support_sources} ${support_mythes_sources} ${support_linkback_sources})
set(support_headers ${support_headers} ${support_mythes_headers} ${support_linkback_headers})
set(support_sources ${support_sources} ${support_linkback_sources})
set(support_headers ${support_headers} ${support_linkback_headers})
add_library(support ${library_type} ${support_sources} ${support_headers} ${dont_merge})
else()
# GCC bug: gcc resolves ::bind as boost::bind
@ -79,7 +75,7 @@ else()
set_source_files_properties(_allinone_touched.C
PROPERTIES OBJECT_DEPENDS "${depends_moc}")
add_library(support ${library_type} ${_allinone_files} ${support_separate}
${support_mythes_sources} ${support_linkback_sources} ${support_headers} ${dont_merge})
${support_linkback_sources} ${support_headers} ${dont_merge})
endif()
set_target_properties(support PROPERTIES FOLDER "applications/LyX")