CMake: Make MinGW support work

This commit is contained in:
Sebastian Pipping 2019-09-01 22:49:54 +02:00
parent 0e3db7fcff
commit d78357da50
4 changed files with 56 additions and 2 deletions

View 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)

View 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

View File

@ -55,6 +55,7 @@ pkgconfigdir = $(libdir)/pkgconfig
_EXTRA_DIST_CMAKE = \
cmake/expat-config.cmake.in \
cmake/mingw-toolchain.cmake \
\
CMakeLists.txt \
CMake.README \

View File

@ -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)