From 5d3d26b0241da8f28e0b6b7cce23a8c5761e43de Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Tue, 7 Mar 2017 14:27:08 +0100 Subject: [PATCH] Cmake build: Adapt handling of mytheslib to automek behaviour The added cmake-parameter is: -DLYX_EXTERNAL_MYTHES= where 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 --- 3rdparty/mythes/CMakeLists.txt | 25 +++++++++++++++ CMakeLists.txt | 31 +++++++++++++------ development/cmake/modules/FindMyThesLIB.cmake | 2 +- src/CMakeLists.txt | 1 + src/support/CMakeLists.txt | 10 ++---- 5 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 3rdparty/mythes/CMakeLists.txt diff --git a/3rdparty/mythes/CMakeLists.txt b/3rdparty/mythes/CMakeLists.txt new file mode 100644 index 0000000000..f096faa14d --- /dev/null +++ b/3rdparty/mythes/CMakeLists.txt @@ -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") diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bd6c3d794..369f1904af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/development/cmake/modules/FindMyThesLIB.cmake b/development/cmake/modules/FindMyThesLIB.cmake index 680c7f8a12..dca24502a4 100644 --- a/development/cmake/modules/FindMyThesLIB.cmake +++ b/development/cmake/modules/FindMyThesLIB.cmake @@ -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} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fc6e225cb..696b0ead2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,6 +130,7 @@ target_link_libraries(${_lyx} frontend_qt graphics support + ${MYTHESLIB_LIBRARY} ${ICONV_LIBRARY} ${LYX_QTMAIN_LIBRARY} ${vld_dll}) diff --git a/src/support/CMakeLists.txt b/src/support/CMakeLists.txt index 1cb6c4aef3..06920ad0f3 100644 --- a/src/support/CMakeLists.txt +++ b/src/support/CMakeLists.txt @@ -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")