]> git.lyx.org Git - features.git/commitdiff
build with mingw on Windows and Linux
authorPeter Kümmel <kuemmel@lyx.org>
Sat, 7 Jun 2014 05:59:52 +0000 (07:59 +0200)
committerPeter Kümmel <kuemmel@lyx.org>
Sat, 7 Jun 2014 06:06:13 +0000 (08:06 +0200)
CMakeLists.txt
development/cmake/LyxPackaging.cmake
development/cmake/modules/LyXMacros.cmake
src/CMakeLists.txt
src/frontends/qt4/CMakeLists.txt
src/tex2lyx/CMakeLists.txt

index 0ceebc96a4086ab151a7b9e4120f2a1331314c4b..48bf5400370403f0ed79039ba750f2eda7243fdf 100644 (file)
@@ -47,6 +47,19 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
 # Supress regeneration
 set(CMAKE_SUPPRESS_REGENERATION FALSE)
 
+if(LYX_XMINGW)
+    set(CMAKE_SYSTEM_NAME Windows)
+    set(TOOLNAME ${LYX_XMINGW})
+    set(TOOLCHAIN "${TOOLNAME}-")
+    set(CMAKE_C_COMPILER   "${TOOLCHAIN}gcc"     CACHE PATH "Mingw C compiler" FORCE)
+    set(CMAKE_CXX_COMPILER "${TOOLCHAIN}g++"     CACHE PATH "Mingw C++ compiler" FORCE)
+    set(CMAKE_RC_COMPILER  "${TOOLCHAIN}windres" CACHE PATH "Mingw rc compiler" FORCE)
+
+    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
+    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endif()
+
 if(NOT help AND NOT HELP)
        # 'project' triggers the searching for a compiler
        project(${LYX_PROJECT})
@@ -146,7 +159,7 @@ endif()
 
 if(LYX_INSTALL)
        set(LYX_NLS ON)
-       if (WIN32)
+        if(WIN32 AND NOT MINGW)
                set(LYX_HUNSPELL ON)
        endif()
        if(LYX_CONSOLE MATCHES "FORCE")
@@ -168,6 +181,7 @@ else()
        set(LYX_MERGE_REBUILD OFF)
 endif()
 
+
 if(LYX_DEPENDENCIES_DOWNLOAD)
        message(STATUS)
        set(LYX_DEPENDENCIES_DIR ${TOP_BINARY_DIR}/msvc2010-deps)
@@ -509,7 +523,12 @@ if(LYX_CXX_FLAGS_EXTRA)
        endforeach()
 endif()
 
-find_package(Qt5Core QUIET)
+if(LYX_XMINGW)
+    set(QT_MINGW_DIR ${LYX_QT4} CACHE PATH "Qt for Mingw" FORCE)
+    list(APPEND CMAKE_FIND_ROOT_PATH ${QT_MINGW_DIR} ${GNUWIN32_DIR})
+else()
+    find_package(Qt5Core QUIET)
+endif()
 if (Qt5Core_FOUND)
        find_package(Qt5Widgets REQUIRED)
         find_package(Qt5X11Extras)
@@ -578,6 +597,7 @@ if(LYX_NLS)
        endif()
 endif()
 
+
 find_package(ICONV REQUIRED)
 find_package(ZLIB REQUIRED)
 
@@ -791,7 +811,9 @@ if(LYX_INSTALL)
        if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
                message(STATUS "Python required to create doc!")
        else()
-               add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+               if(UNIX)
+                       add_subdirectory(${LYX_CMAKE_DIR}/man "${TOP_BINARY_DIR}/man")
+               endif()
                add_subdirectory(${LYX_CMAKE_DIR}/doc "${TOP_BINARY_DIR}/doc")
        endif()
        include(../Install)
index c64f3b7b1d7bbd5edec752d830fbb52933ad8bff..1ae425cc8e3c0515e84ba6a2a5ddce3b2f8ec33b 100644 (file)
@@ -37,7 +37,46 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${LYX_INSTALL_SUFFIX}")
 if (APPLE)
        # We don't need absolute paths
        set(CPACK_SET_DESTDIR "OFF")
-elseif (NOT WIN32)
+elseif(WIN32)
+    set(CPACK_GENERATOR ZIP)
+    set(CPACK_BINARY_ZIP 1)
+    if(MINGW)
+        get_filename_component(MINGW_BIN_PATH ${CMAKE_CXX_COMPILER} PATH)
+        if(LYX_XMINGW)
+                get_filename_component(mingw_name ${LYX_XMINGW} NAME)
+                set(MINGW_BIN_PATH ${MINGW_BIN_PATH}/../${mingw_name}/lib)
+        endif()
+        if(EXISTS ${MINGW_BIN_PATH}/libgcc_s_sjlj-1.dll)
+            list(APPEND runtime ${MINGW_BIN_PATH}/libgcc_s_sjlj-1.dll)
+        elseif(EXISTS ${MINGW_BIN_PATH}/libgcc_s_seh-1.dll)
+            list(APPEND runtime ${MINGW_BIN_PATH}/libgcc_s_seh-1.dll)
+        elseif(EXISTS ${MINGW_BIN_PATH}/libgcc_s_dw2-1.dll)
+            list(APPEND runtime ${MINGW_BIN_PATH}/libgcc_s_dw2-1.dll)
+        endif()
+        if(EXISTS ${MINGW_BIN_PATH}/libstdc++-6.dll)
+            list(APPEND runtime ${MINGW_BIN_PATH}/libstdc++-6.dll)
+        endif()
+        if(EXISTS ${MINGW_BIN_PATH}/libwinpthread-1.dll)
+            list(APPEND runtime ${MINGW_BIN_PATH}/libwinpthread-1.dll)
+        endif()
+        if(NOT runtime)
+                message(FATAL_ERROR "No mingw runtime found in ${MINGW_BIN_PATH}")
+        endif()
+
+        install(FILES
+                    ${runtime}
+                    ${QT_BINARY_DIR}/QtCore4.dll
+                    ${QT_BINARY_DIR}/QtGui4.dll
+                    ${QT_BINARY_DIR}/QtNetwork4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qgif4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qico4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qmng4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qsvg4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qtga4.dll
+                    ${QT_PLUGINS_DIR}/imageformats/qtiff4.dll
+                DESTINATION bin CONFIGURATIONS Release)
+    endif()
+else()
        # needed by rpm
        set(CPACK_SET_DESTDIR "ON")
 endif()
index 48e29d8031f5ffc195276f37b3d05117a6d98f6d..2ef578900b668d9ec231df87d80277dfacedab20 100644 (file)
@@ -41,9 +41,9 @@ endmacro(lyx_add_path _out _prefix)
 #create the implementation files from the ui files and add them
 #to the list of sources
 #usage: LYX_ADD_QT4_UI_FILES(foo_SRCS ${ui_files})
-macro(LYX_ADD_UI_FILES _sources _ui)
+macro(LYX_ADD_UI_FILES _sources _ui_files)
+       set(uifiles})
        foreach (_current_FILE ${ARGN})
-
                get_filename_component(_tmp_FILE ${_current_FILE} ABSOLUTE)
                get_filename_component(_basename ${_tmp_FILE} NAME_WE)
                set(_header ${CMAKE_CURRENT_BINARY_DIR}/ui_${_basename}.h)
@@ -54,8 +54,9 @@ macro(LYX_ADD_UI_FILES _sources _ui)
                # Latest test showed on linux and windows show no bad consequeces,
                # so we removed the call to LyXuic.cmake
                qt_wrap_uifiles(${_header} ${_tmp_FILE} OPTIONS -tr lyx::qt_)
-               set(${_ui} ${${_ui}} ${_header})
-       endforeach (_current_FILE)
+               list(APPEND uifiles ${_header})
+       endforeach()
+       set(${_ui_files} ${uifiles})
 endmacro(LYX_ADD_UI_FILES)
 
 
index 526f37a556daad3b757160629cb0db558e2ca845..2fa3291c2d9ae695bb294bf15b14d2d9d4261695 100644 (file)
@@ -89,7 +89,7 @@ if (LYX_VLD)
        lyx_add_info_files(VLD ${vld_files})
 endif()
 
-if(WIN32)
+if(WIN32 AND NOT MINGW)
        set(FILE_RC ${TOP_CMAKE_PATH}/lyx.rc)
        message(STATUS "Using icon defined in resource file: ${FILE_RC}")
 endif()
index f0675e203c929aedf1a2a8cb058c35371d9bae0b..bc7e2127cc2dff68f17b218d85cd40a82b90f79f 100644 (file)
@@ -68,7 +68,7 @@ target_link_libraries(frontend_qt4
 lyx_add_gcc_pch(frontend_qt4)
 
 if(WIN32)
-       target_link_libraries(frontend_qt4 Gdi32)
+       target_link_libraries(frontend_qt4 gdi32)
 endif()
 
 project_source_group("${GROUP_CODE}" frontends_qt4_sources frontends_qt4_headers)
index f3bbcf717d363c9f5b9a3c0bcc0d07b223db0d62..c7ec504106bdda284a1a269df1a125444e96a3b9 100644 (file)
@@ -29,7 +29,7 @@ include_directories(BEFORE
        ${TOP_SRC_DIR}/src/support/minizip
        ${ZLIB_INCLUDE_DIR})
 
-if(WIN32)
+if(WIN32 AND NOT MINGW)
        set(FILE_RC ${TOP_CMAKE_PATH}/lyx.rc)
        message(STATUS "Using icon defined in resource file: ${FILE_RC}")
 endif()