rts/cmake/win9x.cmake
Xavier Del Campo Romero 99bb23e194 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.
2022-06-08 00:36:26 +02:00

42 lines
1.5 KiB
CMake

file(MAKE_DIRECTORY ${cdroot})
if("$ENV{SDL_PATH}" STREQUAL "")
message(FATAL_ERROR "please define env variable SDL_PATH")
elseif("$ENV{SDL_TTF_PATH}" STREQUAL "")
message(FATAL_ERROR "please define env variable SDL_TTF_PATH")
elseif("$ENV{FREETYPE_PATH}" STREQUAL "")
message(FATAL_ERROR "please define env variable FREETYPE_PATH")
elseif("$ENV{SDL_MIXER_PATH}" STREQUAL "")
message(FATAL_ERROR "please define env variable SDL_MIXER_PATH")
endif()
add_custom_command(OUTPUT ${cdroot}/${PROJECT_NAME}
COMMAND i386-mingw32-strip ${PROJECT_NAME} -o ${cdroot}/${PROJECT_NAME}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS ${PROJECT_NAME}
VERBATIM)
add_custom_target(stripped-exe ALL DEPENDS ${cdroot}/${PROJECT_NAME})
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)
set(SDL1_2_BUILD 1)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# i386-mingw32-gcc 3.4.5 does not support -Og.
set(cflags ${cflags} -O0)
else()
set(cflags ${cflags} -O2)
endif()
add_subdirectory(libfixmath)