mirror of https://github.com/PCSX2/pcsx2.git
cmake: Improve wxWidgets and SDL linkage check
If wxWidgets is linked to SDL, check what version it's actually linked against instead of assuming it's linked to SDL1.2 (which isn't true on Fedora 27).
This commit is contained in:
parent
c23241c5f4
commit
41c49faa81
|
@ -1,9 +1,14 @@
|
||||||
set(wx_sdl_c_code "
|
set(wx_sdl_c_code "
|
||||||
#include <wx/setup.h>
|
#include <wx/setup.h>
|
||||||
|
|
||||||
#if (wxUSE_LIBSDL != 0)
|
#if (wxUSE_LIBSDL == 0)
|
||||||
#error cmake_WX_SDL
|
#error cmake_WX_SDL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
")
|
")
|
||||||
|
|
||||||
set(gcc7_mmx_code "
|
set(gcc7_mmx_code "
|
||||||
|
@ -83,19 +88,29 @@ function(WX_vs_SDL)
|
||||||
file(WRITE "${CMAKE_BINARY_DIR}/wx_sdl.c" "${wx_sdl_c_code}")
|
file(WRITE "${CMAKE_BINARY_DIR}/wx_sdl.c" "${wx_sdl_c_code}")
|
||||||
enable_language(C)
|
enable_language(C)
|
||||||
|
|
||||||
try_run(
|
try_compile(
|
||||||
run_result_unused
|
wx_linked_to_sdl
|
||||||
compile_result_unused
|
"${CMAKE_BINARY_DIR}"
|
||||||
"${CMAKE_BINARY_DIR}"
|
"${CMAKE_BINARY_DIR}/wx_sdl.c"
|
||||||
"${CMAKE_BINARY_DIR}/wx_sdl.c"
|
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${wxWidgets_INCLUDE_DIRS}"
|
||||||
COMPILE_OUTPUT_VARIABLE OUT
|
LINK_LIBRARIES "${wxWidgets_LIBRARIES}"
|
||||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${wxWidgets_INCLUDE_DIRS}"
|
COPY_FILE "${CMAKE_BINARY_DIR}/wx_sdl"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${OUT} MATCHES "cmake_WX_SDL" AND SDL2_API)
|
if (NOT wx_linked_to_sdl)
|
||||||
message(FATAL_ERROR "WxWidget is linked to SDL (wxUSE_LIBSDL) and it is likely SDL1.2.
|
return()
|
||||||
Unfortunately you try to build PCSX2 with SDL2 support which is not compatible
|
endif()
|
||||||
Please use -DSDL2_API=FALSE")
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ldd "${CMAKE_BINARY_DIR}/wx_sdl"
|
||||||
|
COMMAND grep -c SDL2
|
||||||
|
OUTPUT_VARIABLE sdl2_count
|
||||||
|
)
|
||||||
|
|
||||||
|
if (SDL2_API AND sdl2_count STREQUAL "0")
|
||||||
|
message(FATAL_ERROR "wxWidgets is linked to SDL1.2. Please use -DSDL2_API=FALSE.")
|
||||||
|
elseif (NOT SDL2_API AND NOT sdl2_count STREQUAL "0")
|
||||||
|
message(FATAL_ERROR "wxWidgets is linked to SDL2. Please use -DSDL2_API=TRUE")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue