]> git.lyx.org Git - lyx.git/commitdiff
Cmake build: Adapt handling of mytheslib to automek behaviour
authorKornel Benko <kornel@lyx.org>
Tue, 7 Mar 2017 13:27:08 +0000 (14:27 +0100)
committerKornel Benko <kornel@lyx.org>
Tue, 7 Mar 2017 13:27:08 +0000 (14:27 +0100)
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

3rdparty/mythes/CMakeLists.txt [new file with mode: 0644]
CMakeLists.txt
development/cmake/modules/FindMyThesLIB.cmake
src/CMakeLists.txt
src/support/CMakeLists.txt

diff --git a/3rdparty/mythes/CMakeLists.txt b/3rdparty/mythes/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f096faa
--- /dev/null
@@ -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")
index 7bd6c3d794de60fcb41a5d86ece925c22970ccd1..369f1904af98ad04578f4fc25e9edffa47f048d8 100644 (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)
index 680c7f8a12177a69bb7e47b647af93d16cc2019f..dca24502a40e3f5c32057d2c581afdf16cb846f1 100644 (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} )
index 8fc6e225cb9c956ce41b993725610131df9eb0a9..696b0ead2cf000a5622a68fad2d4eae48adefdde 100644 (file)
@@ -130,6 +130,7 @@ target_link_libraries(${_lyx}
        frontend_qt
        graphics
        support
+       ${MYTHESLIB_LIBRARY}
        ${ICONV_LIBRARY}
        ${LYX_QTMAIN_LIBRARY}
        ${vld_dll})
index 1cb6c4aef3c743be8b8b00a53e8aa57ea11163a8..06920ad0f3a866ba503cb664b44fbce096e81dad 100644 (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")