win9x.cmake: use target commands for SDL and SDL_mixer

Since libSDL.a and libSDL_mixer.a are compiled separately from this
project, some hacks had been used to get the build running. However,
this approach did not make proper use of target-level properties, which
are encouraged according to modern CMake standards over global-level
commands such as include_directories() or link_libraries().

OTOH, Win32 dependencies were being imported using link_libraries(), but
they in fact are SDL dependencies, so target_link_libraries() can be
used instead.
This commit is contained in:
Xavier Del Campo Romero 2022-06-08 00:11:14 +02:00
parent 706d299af4
commit 99bb23e194
1 changed files with 12 additions and 8 deletions

View File

@ -16,15 +16,19 @@ add_custom_command(OUTPUT ${cdroot}/${PROJECT_NAME}
VERBATIM)
add_custom_target(stripped-exe ALL DEPENDS ${cdroot}/${PROJECT_NAME})
target_link_directories(${PROJECT_NAME} PRIVATE $ENV{SDL_PATH}/lib
$ENV{SDL_TTF_PATH}/lib $ENV{FREETYPE_PATH}/lib
$ENV{SDL_MIXER_PATH}/lib)
include_directories($ENV{SDL_PATH}/include
$ENV{SDL_PATH}/include/SDL $ENV{SDL_TTF_PATH}/include
$ENV{FREETYPE_PATH}/include
$ENV{SDL_MIXER_PATH}/include)
add_library(SDL STATIC IMPORTED)
set_property(TARGET SDL PROPERTY IMPORTED_LOCATION $ENV{SDL_PATH}/lib/libSDL.a)
target_include_directories(SDL INTERFACE
$ENV{SDL_PATH}/include $ENV{SDL_PATH}/include/SDL)
target_link_libraries(SDL INTERFACE gdi32 user32 winmm dxguid freetype)
add_library(SDL_mixer STATIC IMPORTED)
set_property(TARGET SDL_mixer PROPERTY IMPORTED_LOCATION
$ENV{SDL_MIXER_PATH}/lib/libSDL_mixer.a)
target_include_directories(SDL_mixer INTERFACE $ENV{SDL_MIXER_PATH}/include)
target_link_libraries(SDL_mixer INTERFACE SDL)
add_compile_options(-march=i386)
link_libraries(gdi32 user32 winmm dxguid freetype)
set(SDL1_2_BUILD 1)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")