build: replace FindPkgConfig hack with BUILD_STATIC variable set by CI toolchain file

This commit is contained in:
Matthias Schiffer 2021-12-21 23:35:00 +01:00
parent 7c13d850b7
commit 056cee8585
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
3 changed files with 10 additions and 11 deletions

View file

@ -1,6 +1,6 @@
set(TARGET x86_64-w64-mingw32)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.github/toolchains/${TARGET})
set(BUILD_STATIC ON)
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSROOT /usr/${TARGET})
@ -16,7 +16,3 @@ set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_SYSROOT}/lib/pkgconfig:${CMAKE_SYSROOT}/share
set(ENV{PKG_CONFIG_PATH} $ENV{PKG_CONFIG_LIBDIR})
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
set(CMAKE_EXE_LINKER_FLAGS "-static")

View file

@ -1,5 +0,0 @@
# Hack: The toolchain file is evaluated too early to set the library suffixes, so we use a wrapper
# around FindPkgConfig set it right before we search for libraries.
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
include(${CMAKE_ROOT}/Modules/FindPkgConfig.cmake)

View file

@ -1,6 +1,14 @@
cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.13)
project(MINEDMAP CXX)
# May not work with all toolchains, added for the Windows CI build
option(BUILD_STATIC "Create a statically linked MinedMap executable")
if(BUILD_STATIC)
list(REMOVE_ITEM CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".dll.a")
add_link_options("-static")
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZLIB REQUIRED IMPORTED_TARGET zlib)