]> granicus.if.org Git - libexpat/commitdiff
CMake: Make MinGW support work
authorSebastian Pipping <sebastian@pipping.org>
Sun, 1 Sep 2019 20:49:54 +0000 (22:49 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Sun, 1 Sep 2019 22:45:23 +0000 (00:45 +0200)
expat/CMakeLists.txt
expat/Changes
expat/Makefile.am
expat/cmake/mingw-toolchain.cmake [new file with mode: 0644]

index b3ca160bba631b295221bbdbc86face8a02bfd53..2d80d836f09c004b1efef26ccfe51a8d8b311bd9 100644 (file)
@@ -328,15 +328,30 @@ if(EXPAT_BUILD_TESTS)
         tests/structdata.c
     )
 
+    if(NOT MSVC)
+        if(MINGW)
+            set(host whatever-mingw32)  # for nothing but run.sh
+        endif()
+        configure_file(${CMAKE_CURRENT_SOURCE_DIR}/run.sh.in run.sh @ONLY)
+    endif()
+
+    function(expat_add_test _name _file)
+        if(MSVC)
+            add_test(NAME ${_name} COMMAND ${_file})
+        else()
+            add_test(NAME ${_name} COMMAND bash run.sh ${_file})
+        endif()
+    endfunction()
+
     add_executable(runtests tests/runtests.c ${test_SRCS})
     set_property(TARGET runtests PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
     target_link_libraries(runtests expat)
-    add_test(runtests tests/runtests)
+    expat_add_test(runtests $<TARGET_FILE:runtests>)
 
     add_executable(runtestspp tests/runtestspp.cpp ${test_SRCS})
     set_property(TARGET runtestspp PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
     target_link_libraries(runtestspp expat)
-    add_test(runtestspp tests/runtestspp)
+    expat_add_test(runtestspp $<TARGET_FILE:runtestspp>)
 endif(EXPAT_BUILD_TESTS)
 
 if(EXPAT_BUILD_FUZZERS)
index cabf3aa0f6c28a425d5aa1e31e94468c9eac7461..4244c2bc165f62cb0fd651c8a2fd2d861ec9aa67 100644 (file)
@@ -56,6 +56,8 @@ Release x.x.x xxx xxx xx xxxx
                   CMake: Now produces a summary of applied configuration
                   CMake: Require C++ compiler only when tests are enabled
             #265  CMake: Fix linking with MinGW
+            #330  CMake: Add full support for MinGW; to enable, use
+                    -DCMAKE_TOOLCHAIN_FILE=[expat]/cmake/mingw-toolchain.cmake
             #316  CMake: Windows: Make binary postfix match MSVC
                     Old: expat[d].lib
                     New: expat[w][d][MD|MT].lib
index c3825e8410e046cd7c09a9d0180be148a2649c3a..b32d9bad2464de4661eab810edcad82a0c472bec 100644 (file)
@@ -55,6 +55,7 @@ pkgconfigdir = $(libdir)/pkgconfig
 
 _EXTRA_DIST_CMAKE = \
     cmake/expat-config.cmake.in \
+    cmake/mingw-toolchain.cmake \
     \
     CMakeLists.txt \
     CMake.README \
diff --git a/expat/cmake/mingw-toolchain.cmake b/expat/cmake/mingw-toolchain.cmake
new file mode 100644 (file)
index 0000000..31a238b
--- /dev/null
@@ -0,0 +1,36 @@
+#                          __  __            _
+#                       ___\ \/ /_ __   __ _| |_
+#                      / _ \\  /| '_ \ / _` | __|
+#                     |  __//  \| |_) | (_| | |_
+#                      \___/_/\_\ .__/ \__,_|\__|
+#                               |_| XML parser
+#
+# Copyright (c) 2019 Expat development team
+# Licensed under the MIT license:
+#
+# Permission is  hereby granted,  free of charge,  to any  person obtaining
+# a  copy  of  this  software   and  associated  documentation  files  (the
+# "Software"),  to  deal in  the  Software  without restriction,  including
+# without  limitation the  rights  to use,  copy,  modify, merge,  publish,
+# distribute, sublicense, and/or sell copies of the Software, and to permit
+# persons  to whom  the Software  is  furnished to  do so,  subject to  the
+# following conditions:
+#
+# The above copyright  notice and this permission notice  shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
+# EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+# NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+# USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+set(CMAKE_SYSTEM_NAME Windows)
+
+set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
+set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
+
+set(WIN32 ON)
+set(MINGW ON)