diff --git a/.gitignore b/.gitignore index c5cdca9bf..9919d297a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ Quake/*.d Quake/*.res Quake/*.exe Quake/ironwail +build/ +/.vs +/out/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..9e261c6bc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,179 @@ +cmake_minimum_required(VERSION 3.7) +include(${CMAKE_CURRENT_SOURCE_DIR}/Misc/cmake/ExtractVersion.cmake) +project(ironwail VERSION ${IRONWAIL_VERSION}) + +cmake_policy(SET CMP0072 NEW) #OpenGL_GL_PREFERENCE to GLVND + +if (WIN32) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Windows/cmake-modules) +endif() + +find_package(SDL2 REQUIRED) +find_package(OpenGL REQUIRED) +find_package(CURL) + +find_package(PkgConfig) + +if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_MPG123 IMPORTED_TARGET libmpg123) + pkg_check_modules(PC_MAD IMPORTED_TARGET mad) + pkg_check_modules(PC_OPUSFILE IMPORTED_TARGET opusfile) + pkg_check_modules(PC_FLAC IMPORTED_TARGET flac) + pkg_check_modules(PC_VORBISFILE IMPORTED_TARGET vorbisfile) + pkg_check_modules(PC_TREMOR IMPORTED_TARGET vorbisidec) + pkg_check_modules(PC_MIKMOD IMPORTED_TARGET libmikmod) + pkg_check_modules(PC_MODPLUG IMPORTED_TARGET libmodplug) + pkg_check_modules(PC_XMP IMPORTED_TARGET libxmp) +endif() + +if (WIN32) + find_package(BundledCODECS) +endif() + +file(GLOB IWAIL_SRC CONFIGURE_DEPENDS "Quake/*.c" "Quake/*.h") + +list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/lodepng.h) +list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/lodepng.c) +list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/cd_null.c) + +if (UNIX) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/pl_win.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_wipx.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_wipx.h) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_wins.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_wins.h) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_win.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_win.h) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/sys_sdl_win.c) +elseif (WIN32) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/pl_linux.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_bsd.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_bsd.h) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_udp.c) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/net_udp.h) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/sys_sdl_unix.c) + list(APPEND IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Windows/QuakeSpasm.rc) +endif() + +if (PC_MPG123_FOUND) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/snd_mp3.c) +elseif (PC_MAD_FOUND) + list(REMOVE_ITEM IWAIL_SRC ${CMAKE_CURRENT_SOURCE_DIR}/Quake/snd_mpg123.c) +endif() + +add_executable(ironwail ${IWAIL_SRC}) +if (UNIX) + target_link_libraries(ironwail PRIVATE m) + set(ENABLE_USERDIRS TRUE CACHE STRING "Enable user directories") +elseif (WIN32) + target_link_libraries(ironwail PRIVATE ws2_32 Winmm) + if (MINGW) + #When the GNU linker is used together with SDL2_Main, + #it is very particular about the library ordering + #on the link command line + target_link_libraries(ironwail PRIVATE mingw32) + if (SDL2_MAIN_LIBRARY) + target_link_libraries(ironwail PRIVATE SDL2::main) + endif() + endif() +endif() +target_link_libraries(ironwail PRIVATE SDL2::SDL2) + +if (CURL_FOUND) + target_link_libraries(ironwail PRIVATE CURL::libcurl) +else() + target_compile_definitions(ironwail PRIVATE WITHOUT_CURL) +endif() + +if (OpenGL::OpenGL) + target_link_libraries(ironwail PRIVATE OpenGL::OpenGL) +else() + target_link_libraries(ironwail PRIVATE OpenGL::GL) +endif() + +target_compile_definitions(ironwail PRIVATE $<$:DEBUG=1> $<$>:NDEBUG=1> USE_SDL2 USE_CODEC_WAVE) +if (MSVC) + target_compile_definitions(ironwail PRIVATE _CRT_SECURE_NO_WARNINGS _WIN32) +endif() + +if (ENABLE_USERDIRS) + target_compile_definitions(ironwail PRIVATE DO_USERDIRS=1) +endif() + +if (PC_MPG123_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_MP3) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_MPG123) +elseif (PC_MAD_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_MP3) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_MAD) +endif() + +if (PC_OPUSFILE_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_OPUS) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_OPUSFILE) +endif() + +if (PC_FLAC_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_FLAC) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_FLAC) +endif() + +if (PC_VORBISFILE_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_VORBIS) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_VORBISFILE) +elseif (PC_TREMOR_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_VORBIS VORBIS_USE_TREMOR) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_TREMOR) +endif() + +if (PC_MIKMOD_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_MIKMOD) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_MIKMOD) +endif() + +if (PC_MODPLUG_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_MODPLUG) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_MODPLUG) +endif() + +if (PC_XMP_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_XMP) + target_link_libraries(ironwail PUBLIC PkgConfig::PC_XMP) +endif() + +if (PC_MIKMOD_FOUND OR PC_MODPLUG_FOUND OR PC_XMP_FOUND) + target_compile_definitions(ironwail PRIVATE USE_CODEC_UMX) +endif() + +if (WIN32) + #Copy DLL dependencies to output folder + add_custom_command(TARGET ironwail POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ + COMMAND_EXPAND_LISTS) + + #VORBISFILE and OPUSFILE both use the libogg-0.dll + if (OGG_DLL AND (PC_VORBISFILE_FOUND OR PC_OPUSFILE_FOUND)) + add_custom_command(TARGET ironwail POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OGG_DLL} $ + COMMAND_EXPAND_LISTS) + endif() + #libvorbisfile depends on libvorbis-0.dll + if (PC_VORBISFILE_FOUND AND VORBIS_DLL) + add_custom_command(TARGET ironwail POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VORBIS_DLL} $ + COMMAND_EXPAND_LISTS) + endif() + #libopusfile depends on libopus-0.dll + if (PC_OPUSFILE_FOUND AND OPUS_DLL) + add_custom_command(TARGET ironwail POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPUS_DLL} $ + COMMAND_EXPAND_LISTS) + endif() + #CURL wants zlib1.dll + if (CURL_FOUND AND ZLIB1_DLL) + add_custom_command(TARGET ironwail POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZLIB1_DLL} $ + COMMAND_EXPAND_LISTS) + endif() +endif() + diff --git a/Misc/cmake/ExtractVersion.cmake b/Misc/cmake/ExtractVersion.cmake new file mode 100644 index 000000000..660e8f5c1 --- /dev/null +++ b/Misc/cmake/ExtractVersion.cmake @@ -0,0 +1,15 @@ +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Quake/quakedef.h") + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/Quake/quakedef.h" IRONWAIL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+IRONWAIL_VER_MAJOR[ \t]+[0-9]+$") + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/Quake/quakedef.h" IRONWAIL_VERSION_MINOR_LINE REGEX "^#define[ \t]+IRONWAIL_VER_MINOR[ \t]+[0-9]+$") + file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/Quake/quakedef.h" IRONWAIL_VERSION_PATCH_LINE REGEX "^#define[ \t]+IRONWAIL_VER_PATCH[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+IRONWAIL_VER_MAJOR[ \t]+([0-9]+)$" "\\1" IRONWAIL_VERSION_MAJOR "${IRONWAIL_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+IRONWAIL_VER_MINOR[ \t]+([0-9]+)$" "\\1" IRONWAIL_VERSION_MINOR "${IRONWAIL_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+IRONWAIL_VER_PATCH[ \t]+([0-9]+)$" "\\1" IRONWAIL_VERSION_PATCH "${IRONWAIL_VERSION_PATCH_LINE}") + set(IRONWAIL_VERSION ${IRONWAIL_VERSION_MAJOR}.${IRONWAIL_VERSION_MINOR}.${IRONWAIL_VERSION_PATCH}) + unset(IRONWAIL_VERSION_MAJOR_LINE) + unset(IRONWAIL_VERSION_MINOR_LINE) + unset(IRONWAIL_VERSION_PATCH_LINE) + unset(IRONWAIL_VERSION_MAJOR) + unset(IRONWAIL_VERSION_MINOR) + unset(IRONWAIL_VERSION_PATCH) +endif() diff --git a/Windows/cmake-modules/FindBundledCODECS.cmake b/Windows/cmake-modules/FindBundledCODECS.cmake new file mode 100644 index 000000000..009d7ea73 --- /dev/null +++ b/Windows/cmake-modules/FindBundledCODECS.cmake @@ -0,0 +1,134 @@ +#This file is used for "faking" results from what would be PkgConfig on Linux +#and creating these library targets from the bundled codecs. +#I think there is some way to have PkgConfig on Windows also so we check each +#library before defining it and see if it's already found +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CODECS_LIB_PATH x64) +else() + set(CODECS_LIB_PATH x86) +endif() + +set(CODECS_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Windows/codecs) +set(CODECS_LIBRARY_DIR ${CODECS_BASE_DIR}/${CODECS_LIB_PATH}) + +find_file(OGG_DLL NAMES libogg-0.dll PATHS ${CODECS_LIBRARY_DIR}) +add_library(PC_OGG SHARED IMPORTED) +set_target_properties(PC_OGG PROPERTIES IMPORTED_LOCATION "${OGG_DLL}") + +if (NOT PC_MPG123_FOUND) + find_path(MPG123_INCLUDE_DIR mpg123.h PATH_SUFFIXES include PATHS ${CODECS_BASE_DIR}) + find_library(MPG123_LIBRARY NAMES libmpg123 libmpg123.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(MPG123_DLL NAMES libmpg123-0.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (MPG123_LIBRARY) + set(PC_MPG123_FOUND TRUE) + set(PC_MPG123_INCLUDE_DIRS ${MPG123_INCLUDE_DIR}) + set(PC_MPG123_LIBRARY_DIRS ${CODECS_LIBRARY_DIR}) + set(PC_MPG123_LIBRARIES ${MPG123_LIBRARY}) + + add_library(PkgConfig::PC_MPG123 SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_MPG123 PROPERTIES IMPORTED_IMPLIB "${MPG123_LIBRARY}" IMPORTED_LOCATION "${MPG123_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${MPG123_INCLUDE_DIR}") + endif() +endif() + +if (NOT PC_MAD_FOUND) + find_path(MAD_INCLUDE_DIR mad.h PATH_SUFFIXES include PATHS ${CODECS_BASE_DIR}) + find_library(MAD_LIBRARY NAMES libmad libmad.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(MAD_DLL NAMES libmad-0.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (MAD_LIBRARY) + set(PC_MAD_FOUND TRUE) + set(PC_MAD_INCLUDE_DIRS ${MAD_INCLUDE_DIR}) + set(PC_MAD_LIBRARY_DIRS ${CODECS_LIBRARY_DIR}) + set(PC_MAD_LIBRARIES ${MAD_LIBRARY}) + + add_library(PkgConfig::PC_MAD SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_MAD PROPERTIES IMPORTED_IMPLIB "${MAD_LIBRARY}" IMPORTED_LOCATION "${MAD_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${MAD_INCLUDE_DIR}") + endif() +endif() + +if (NOT PC_OPUSFILE_FOUND) + find_path(OPUSFILE_INCLUDE_DIR opusfile.h PATH_SUFFIXES include/opus PATHS ${CODECS_BASE_DIR}) + find_library(OPUSFILE_LIBRARY NAMES libopusfile libopusfile.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(OPUSFILE_DLL NAMES libopusfile-0.dll PATHS ${CODECS_LIBRARY_DIR}) + find_file(OPUS_DLL NAMES libopus-0.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (OPUSFILE_LIBRARY) + set(PC_OPUSFILE_FOUND TRUE) + set(PC_OPUSFILE_INCLUDE_DIRS ${OPUSFILE_INCLUDE_DIR}) + set(PC_OPUSFILE_LIBRARY_DIRS ${CODECS_LIBRARY_DIR}) + set(PC_OPUSFILE_LIBRARIES ${OPUSFILE_LIBRARY}) + + add_library(PkgConfig::PC_OPUSFILE SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_OPUSFILE PROPERTIES IMPORTED_IMPLIB "${OPUSFILE_LIBRARY}" IMPORTED_LOCATION "${OPUSFILE_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${OPUSFILE_INCLUDE_DIR}") + add_library(PC_OPUS SHARED IMPORTED) + set_target_properties(PC_OPUS PROPERTIES IMPORTED_LOCATION "${OPUS_DLL}") + endif() +endif() + +if (NOT PC_FLAC_FOUND) + find_path(FLAC_INCLUDE_DIR stream_decoder.h PATH_SUFFIXES include/FLAC PATHS ${CODECS_BASE_DIR}) + find_library(FLAC_LIBRARY NAMES libFLAC libFLAC.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(FLAC_DLL NAMES libflac-8.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (FLAC_LIBRARY) + set(PC_FLAC_FOUND TRUE) + set(PC_FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR}) + set(PC_FLAC_LIBRARY_DIRS ${FLAC_LIBRARY_DIR}) + set(PC_FLAC_LIBRARIES ${FLAC_LIBRARY}) + + add_library(PkgConfig::PC_FLAC SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_FLAC PROPERTIES IMPORTED_IMPLIB "${FLAC_LIBRARY}" IMPORTED_LOCATION "${FLAC_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}") + endif() +endif() + +if (NOT PC_VORBISFILE_FOUND) + find_path(VORBISFILE_INCLUDE_DIR vorbisfile.h PATH_SUFFIXES include/vorbis PATHS ${CODECS_BASE_DIR}) + find_library(VORBISFILE_LIBRARY NAMES libvorbisfile libvorbisfile.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(VORBISFILE_DLL NAMES libvorbisfile-3.dll PATHS ${CODECS_LIBRARY_DIR}) + find_file(VORBIS_DLL NAMES libvorbis-0.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (VORBISFILE_LIBRARY) + set(PC_VORBISFILE_FOUND TRUE) + set(PC_VORBISFILE_INCLUDE_DIRS ${VORBISFILE_INCLUDE_DIR}) + set(PC_VORBISFILE_LIBRARY_DIRS ${VORBISFILE_LIBRARY_DIR}) + set(PC_VORBISFILE_LIBRARIES ${VORBISFILE_LIBRARY}) + + add_library(PkgConfig::PC_VORBISFILE SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_VORBISFILE PROPERTIES IMPORTED_IMPLIB "${VORBISFILE_LIBRARY}" IMPORTED_LOCATION "${VORBISFILE_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${VORBISFILE_INCLUDE_DIR}") + add_library(PC_VORBIS SHARED IMPORTED) + set_target_properties(PC_VORBIS PROPERTIES IMPORTED_LOCATION "${VORBIS_DLL}") + endif() +endif() + +if (NOT PC_MIKMOD_FOUND) + find_path(MIKMOD_INCLUDE_DIR mikmod.h PATH_SUFFIXES include PATHS ${CODECS_BASE_DIR}) + find_library(MIKMOD_LIBRARY NAMES libmikmod libmikmod.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(MIKMOD_DLL NAMES libmikmod-3.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (MIKMOD_LIBRARY) + set(PC_MIKMOD_FOUND TRUE) + set(PC_MIKMOD_INCLUDE_DIRS ${MIKMOD_INCLUDE_DIR}) + set(PC_MIKMOD_LIBRARY_DIRS ${MIKMOD_LIBRARY_DIR}) + set(PC_MIKMOD_LIBRARIES ${MIKMOD_LIBRARY}) + + add_library(PkgConfig::PC_MIKMOD SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_MIKMOD PROPERTIES IMPORTED_IMPLIB "${MIKMOD_LIBRARY}" IMPORTED_LOCATION "${MIKMOD_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${MIKMOD_INCLUDE_DIR}") + endif() +endif() + +if (NOT PC_XMP_FOUND) + find_path(XMP_INCLUDE_DIR xmp.h PATH_SUFFIXES include PATHS ${CODECS_BASE_DIR}) + find_library(XMP_LIBRARY NAMES libxmp libxmp.dll PATH_SUFFIXES ${CODECS_LIB_PATH} PATHS ${CODECS_BASE_DIR}) + find_file(XMP_DLL NAMES libxmp.dll PATHS ${CODECS_LIBRARY_DIR}) + + if (XMP_LIBRARY) + set(PC_XMP_FOUND TRUE) + set(PC_XMP_INCLUDE_DIRS ${XMP_INCLUDE_DIR}) + set(PC_XMP_LIBRARY_DIRS ${XMP_LIBRARY_DIR}) + set(PC_XMP_LIBRARIES ${XMP_LIBRARY}) + + add_library(PkgConfig::PC_XMP SHARED IMPORTED GLOBAL) + set_target_properties(PkgConfig::PC_XMP PROPERTIES IMPORTED_IMPLIB "${XMP_LIBRARY}" IMPORTED_LOCATION "${XMP_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${XMP_INCLUDE_DIR}") + endif() +endif() \ No newline at end of file diff --git a/Windows/cmake-modules/FindCURL.cmake b/Windows/cmake-modules/FindCURL.cmake new file mode 100644 index 000000000..a5970c47a --- /dev/null +++ b/Windows/cmake-modules/FindCURL.cmake @@ -0,0 +1,55 @@ + +set(CURL_PATH "" CACHE STRING "CURL path") + +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CURL_LIB_PATH x64) +else() + set(CURL_LIB_PATH x86) +endif() + +find_path(CURL_INCLUDE_DIR curl/curl.h + PATH_SUFFIXES include + PATHS ${CURL_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/curl") + +set(CURL_INCLUDE_DIRS "${CURL_INCLUDE_DIR}") + +find_library(CURL_LIBRARY + NAMES curl curllib libcurl_imp curllib_static libcurl libcurl_a + PATH_SUFFIXES lib/${CURL_LIB_PATH} + PATHS "${CURL_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/Windows/curl") + +set(CURL_LIBRARIES "${CURL_LIBRARY}") + +find_file(CURL_DLL + NAMES libcurl.dll + PATH_SUFFIXES lib/${CURL_LIB_PATH} + PATHS ${SDL2_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/curl") + +find_file(ZLIB1_DLL names zlib1.dll PATHS ${CMAKE_CURRENT_SOURCE_DIR}/Windows/zlib PATH_SUFFIXES ${CURL_LIB_PATH}) + +if (CURL_INCLUDE_DIR AND EXISTS "${CURL_INCLUDE_DIR}/curl/curlver.h") + file(STRINGS "${CURL_INCLUDE_DIR}/curl/curlver.h" CURL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+LIBCURL_VERSION_MAJOR[ \t]+[0-9]+$") + file(STRINGS "${CURL_INCLUDE_DIR}/curl/curlver.h" CURL_VERSION_MINOR_LINE REGEX "^#define[ \t]+LIBCURL_VERSION_MINOR[ \t]+[0-9]+$") + file(STRINGS "${CURL_INCLUDE_DIR}/curl/curlver.h" CURL_VERSION_PATCH_LINE REGEX "^#define[ \t]+LIBCURL_VERSION_PATCH[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+LIBCURL_VERSION_MAJOR[ \t]+([0-9]+)$" "\\1" CURL_VERSION_MAJOR "${CURL_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+LIBCURL_VERSION_MINOR[ \t]+([0-9]+)$" "\\1" CURL_VERSION_MINOR "${CURL_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+LIBCURL_VERSION_PATCH[ \t]+([0-9]+)$" "\\1" CURL_VERSION_PATCH "${CURL_VERSION_PATCH_LINE}") + set(CURL_VERSION_STRING ${CURL_VERSION_MAJOR}.${CURL_VERSION_MINOR}.${CURL_VERSION_PATCH}) + unset(CURL_VERSION_MAJOR_LINE) + unset(CURL_VERSION_MINOR_LINE) + unset(CURL_VERSION_PATCH_LINE) + unset(CURL_VERSION_MAJOR) + unset(CURL_VERSION_MINOR) + unset(CURL_VERSION_PATCH) +endif() + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL REQUIRED_VARS CURL_LIBRARY CURL_INCLUDE_DIR VERSION_VAR CURL_VERSION_STRING) + +if (CURL_FOUND) + if (CURL_LIBRARY) + add_library(CURL::libcurl SHARED IMPORTED GLOBAL) + set_target_properties(CURL::libcurl PROPERTIES IMPORTED_IMPLIB "${CURL_LIBRARY}" IMPORTED_LOCATION "${CURL_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIR}") + endif() +endif() \ No newline at end of file diff --git a/Windows/cmake-modules/FindSDL2.cmake b/Windows/cmake-modules/FindSDL2.cmake new file mode 100644 index 000000000..17a70c289 --- /dev/null +++ b/Windows/cmake-modules/FindSDL2.cmake @@ -0,0 +1,66 @@ + +set(SDL2_PATH "" CACHE STRING "SDL2 path") + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SDL2_LIB_PATH lib64) +else() + set(SDL2_LIB_PATH lib) +endif() + +find_path(SDL2_INCLUDE_DIR SDL.h + PATH_SUFFIXES include + PATHS ${SDL2_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/SDL2") + +set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIR}") + +find_library(SDL2_LIBRARY + NAMES SDL2 + PATH_SUFFIXES ${SDL2_LIB_PATH} + PATHS ${SDL2_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/SDL2") + +find_library(SDL2_MAIN_LIBRARY + NAMES SDL2main + PATH_SUFFIXES ${SDL2_LIB_PATH} + PATHS ${SDL2_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/SDL2") + +find_file(SDL2_DLL + NAMES SDL2.dll + PATH_SUFFIXES ${SDL2_LIB_PATH} + PATHS ${SDL2_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/Windows/SDL2") + +set(SDL2_LIBRARIES "${SDL2_LIBRARY}" "${SDL2_MAIN_LIBRARY}") + +if (SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") + file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") + string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") + string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") + set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}) + unset(SDL2_VERSION_MAJOR_LINE) + unset(SDL2_VERSION_MINOR_LINE) + unset(SDL2_VERSION_PATCH_LINE) + unset(SDL2_VERSION_MAJOR) + unset(SDL2_VERSION_MINOR) + unset(SDL2_VERSION_PATCH) +endif() + +include(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR VERSION_VAR SDL2_VERSION_STRING) + +if (SDL2_FOUND) + if (SDL2_LIBRARY) + add_library(SDL2::SDL2 SHARED IMPORTED GLOBAL) + set_target_properties(SDL2::SDL2 PROPERTIES IMPORTED_IMPLIB "${SDL2_LIBRARY}" IMPORTED_LOCATION "${SDL2_DLL}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}") + + if (SDL2_MAIN_LIBRARY) + add_library(SDL2::main UNKNOWN IMPORTED) + set_target_properties(SDL2::main PROPERTIES IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}") + if (NOT MINGW) + set_property(TARGET SDL2::SDL2 APPEND PROPERTY INTERFACE_LINK_LIBRARIES SDL2::main) + endif() + endif() + endif() +endif() \ No newline at end of file