build: fix static linking on MSYS2 CLANG64
Bring back setting the MSYS variable under MSYS2, it's still being used in a few places. Link the SDL2::SDL2-static target for static builds. Add -static-libgcc and -static-libstdc++ to the gcc/clang toolchain for static builds. Edit wxWidgets_LIBRARIES under MSYS2 to specify liblzma.a explicitly because for some reason it's not being linked statically by default for static builds. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
ce7cc4e223
commit
f57cad67c4
|
@ -93,6 +93,10 @@ if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug")
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Debug")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(NOT ENV{MSYSTEM_PREFIX} STREQUAL "")
|
||||||
|
set(MSYS ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
@ -216,7 +220,11 @@ if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
|
if(VBAM_STATIC)
|
||||||
|
set(VBAM_SDL2_LIBS SDL2::SDL2-static ${SDL2_LIBRARY_TEMP})
|
||||||
|
else()
|
||||||
|
set(VBAM_SDL2_LIBS SDL2::SDL2 ${SDL2_LIBRARY_TEMP})
|
||||||
|
endif()
|
||||||
|
|
||||||
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
|
set(VBAM_GENERATED_DIR ${CMAKE_BINARY_DIR}/generated)
|
||||||
|
|
||||||
|
|
|
@ -49,3 +49,7 @@ endif()
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||||
include_directories(/usr/local/include)
|
include_directories(/usr/local/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(VBAM_STATIC)
|
||||||
|
add_link_options("-static-libgcc" "-static-libstdc++")
|
||||||
|
endif()
|
||||||
|
|
|
@ -286,7 +286,7 @@ endif()
|
||||||
|
|
||||||
# OpenAL.
|
# OpenAL.
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
|
if(OPENAL_STATIC)
|
||||||
target_compile_definitions(visualboyadvance-m PRIVATE AL_LIBTYPE_STATIC)
|
target_compile_definitions(visualboyadvance-m PRIVATE AL_LIBTYPE_STATIC)
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(visualboyadvance-m PRIVATE ${OPENAL_INCLUDE_DIR})
|
target_include_directories(visualboyadvance-m PRIVATE ${OPENAL_INCLUDE_DIR})
|
||||||
|
@ -334,6 +334,20 @@ if(NOT wxWidgets_FOUND)
|
||||||
target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL)
|
target_compile_definitions(visualboyadvance-m PRIVATE NO_OGL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Workaround of static liblzma not being found on MSYS2.
|
||||||
|
if(VBAM_STATIC AND MSYS)
|
||||||
|
unset(cleaned_up_wx_libs)
|
||||||
|
foreach(lib ${wxWidgets_LIBRARIES})
|
||||||
|
if(lib STREQUAL "-llzma")
|
||||||
|
set(lib "liblzma.a")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND cleaned_up_wx_libs "${lib}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(wxWidgets_LIBRARIES "${cleaned_up_wx_libs}")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(visualboyadvance-m ${wxWidgets_LIBRARIES})
|
target_link_libraries(visualboyadvance-m ${wxWidgets_LIBRARIES})
|
||||||
target_include_directories(visualboyadvance-m PRIVATE ${wxWidgets_INCLUDE_DIRS})
|
target_include_directories(visualboyadvance-m PRIVATE ${wxWidgets_INCLUDE_DIRS})
|
||||||
target_compile_options(visualboyadvance-m PRIVATE ${wxWidgets_CXX_FLAGS})
|
target_compile_options(visualboyadvance-m PRIVATE ${wxWidgets_CXX_FLAGS})
|
||||||
|
|
Loading…
Reference in New Issue