Windows update
This commit is contained in:
@@ -20,8 +20,33 @@ message(STATUS "Target platform: ${TARGET_PLATFORM}")
|
|||||||
|
|
||||||
# Detect build type and configure SDL2 paths accordingly
|
# Detect build type and configure SDL2 paths accordingly
|
||||||
if (TARGET_PLATFORM STREQUAL "windows")
|
if (TARGET_PLATFORM STREQUAL "windows")
|
||||||
include_directories(${SDL2_INCLUDE_DIR})
|
find_package(SDL2 REQUIRED)
|
||||||
|
find_package(SDL2_ttf REQUIRED)
|
||||||
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
|
link_directories(${SDL2_LIBRARY_DIRS})
|
||||||
|
add_definitions(${SDL2_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
elseif (TARGET_PLATFORM STREQUAL "windows-static")
|
||||||
|
# Cross-compile static Windows build using MinGW
|
||||||
|
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||||
|
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||||
|
set(CMAKE_FIND_ROOT_PATH /usr/local/x86_64-w64-mingw32)
|
||||||
|
|
||||||
|
# Ensure static linking
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ -mwindows")
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
/usr/local/x86_64-w64-mingw32/include
|
||||||
|
/usr/local/x86_64-w64-mingw32/include/SDL2
|
||||||
|
)
|
||||||
|
link_directories(
|
||||||
|
/usr/local/x86_64-w64-mingw32/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
add_definitions(-DSDL_MAIN_HANDLED)
|
||||||
|
|
||||||
elseif (TARGET_PLATFORM STREQUAL "mingw")
|
elseif (TARGET_PLATFORM STREQUAL "mingw")
|
||||||
|
# Cross-compile dynamically linked Windows build
|
||||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
||||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
||||||
find_package(SDL2 REQUIRED)
|
find_package(SDL2 REQUIRED)
|
||||||
@@ -29,11 +54,13 @@ elseif (TARGET_PLATFORM STREQUAL "mingw")
|
|||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
link_directories(${SDL2_LIBRARY_DIRS})
|
link_directories(${SDL2_LIBRARY_DIRS})
|
||||||
add_definitions(${SDL2_CFLAGS_OTHER})
|
add_definitions(${SDL2_CFLAGS_OTHER})
|
||||||
|
|
||||||
elseif (TARGET_PLATFORM STREQUAL "linux")
|
elseif (TARGET_PLATFORM STREQUAL "linux")
|
||||||
pkg_check_modules(SDL2 REQUIRED sdl2)
|
pkg_check_modules(SDL2 REQUIRED sdl2)
|
||||||
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
|
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf)
|
||||||
include_directories(${SDL2_INCLUDE_DIRS})
|
include_directories(${SDL2_INCLUDE_DIRS})
|
||||||
add_definitions(${SDL2_CFLAGS_OTHER})
|
add_definitions(${SDL2_CFLAGS_OTHER})
|
||||||
|
|
||||||
else ()
|
else ()
|
||||||
message(FATAL_ERROR "Unsupported TARGET_PLATFORM: ${TARGET_PLATFORM}")
|
message(FATAL_ERROR "Unsupported TARGET_PLATFORM: ${TARGET_PLATFORM}")
|
||||||
endif ()
|
endif ()
|
||||||
@@ -60,14 +87,18 @@ set(SOURCE_FILES
|
|||||||
|
|
||||||
# Build the target executable
|
# Build the target executable
|
||||||
add_executable(RISCB ${SOURCE_FILES})
|
add_executable(RISCB ${SOURCE_FILES})
|
||||||
target_link_libraries(RISCB SDL2 SDL2_ttf m)
|
|
||||||
|
# Link libraries
|
||||||
|
if (TARGET_PLATFORM STREQUAL "windows-static")
|
||||||
|
target_link_libraries(RISCB mingw32 SDL2main SDL2 SDL2_ttf freetype -static)
|
||||||
|
else ()
|
||||||
|
target_link_libraries(RISCB SDL2 SDL2_ttf m)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Cross-compile Windows executable on Unix
|
# Cross-compile Windows executable on Unix
|
||||||
if (UNIX AND TARGET_PLATFORM STREQUAL "mingw")
|
if (UNIX AND TARGET_PLATFORM STREQUAL "windows-static")
|
||||||
add_executable(RISCB_WIN32 ${SOURCE_FILES})
|
add_executable(RISCB_WIN32 ${SOURCE_FILES})
|
||||||
set_target_properties(RISCB_WIN32 PROPERTIES COMPILE_FLAGS "-mwindows")
|
set_target_properties(RISCB_WIN32 PROPERTIES COMPILE_FLAGS "-mwindows")
|
||||||
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
|
|
||||||
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
|
|
||||||
add_definitions(-DSDL_MAIN_HANDLED)
|
add_definitions(-DSDL_MAIN_HANDLED)
|
||||||
target_link_libraries(RISCB_WIN32 mingw32 SDL2main SDL2 SDL2_ttf -static-libgcc -static-libstdc++)
|
target_link_libraries(RISCB mingw32 /usr/local/x86_64-w64-mingw32/lib/libSDL2main.a /usr/local/x86_64-w64-mingw32/lib/libSDL2.a /usr/local/x86_64-w64-mingw32/lib/libSDL2_ttf.dll.a /usr/local/x86_64-w64-mingw32/lib/libfreetype.a /usr/local/x86_64-w64-mingw32/lib/libSDL2_test.a -static setupapi rpcrt4 imm32 oleaut32 version ole32 winmm )
|
||||||
endif ()
|
endif ()
|
Reference in New Issue
Block a user