Skip to content

Commit

Permalink
Windows|Cygwin: Improved build configuration
Browse files Browse the repository at this point in the history
Clean user-provided SDL and FMOD SDK paths in Cygwin.
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent ff01fe9 commit 214ddbe
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doomsday/cmake/Directories.cmake
Expand Up @@ -28,7 +28,7 @@ else ()
set (DE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE})
endif ()

if (UNIX AND NOT APPLE)
if (UNIX AND NOT (APPLE OR CYGWIN))
set (UNIX_LINUX YES)
include (GNUInstallDirs)
endif()
Expand Down
5 changes: 4 additions & 1 deletion doomsday/cmake/FindFMOD.cmake
Expand Up @@ -2,8 +2,11 @@ set (FMOD_DIR "" CACHE PATH "Location of the FMOD Programmer's API SDK")

set (_oldPath ${FMOD_FMOD_H})

# We may need to clean up the provided path.
deng_clean_path (fmodRoot ${FMOD_DIR})

find_file (FMOD_FMOD_H api/lowlevel/inc/fmod.h
PATHS "${FMOD_DIR}"
PATHS "${fmodRoot}"
HINTS ENV DENG_DEPEND_PATH
PATH_SUFFIXES "FMOD" "FMOD Programmers API" "FMOD Studio API Windows"
NO_DEFAULT_PATH
Expand Down
32 changes: 22 additions & 10 deletions doomsday/cmake/FindSDL2Libs.cmake
Expand Up @@ -16,22 +16,30 @@ if (TARGET SDL2)
return ()
endif ()

if (PKG_CONFIG_FOUND AND (NOT IOS) AND (NOT CYGWIN))
if (PKG_CONFIG_FOUND AND (NOT CYGWIN OR IOS))
# The Unix Way: use pkg-config to find the SDL2 libs installed on system.
if (NOT TARGET SDL2)
add_pkgconfig_interface_library (SDL2 OPTIONAL sdl2)
add_pkgconfig_interface_library (SDL2_mixer OPTIONAL SDL2_mixer)
endif ()

elseif (WIN32 OR CYGWIN)
# Try to locate SDL2 from the local system (assuming Windows).
deng_clean_path (sdlRoot ${SDL2_DIR})
# This is Windows, so we'll use the Windows SDL2 libraries that the user has
# installed in FMOD_DIR. Note that Cygwin also uses the native SDL2 libraries
# and *not* the Cygwin ones, which would presumably have an X11 dependency.
set (_oldPath ${SDL2_LIBRARY})
if (CYGWIN)
# Assume it has been set manually.
set (SDL2_LIBRARY ${SDL2_DIR}/lib/${DE_ARCH}/SDL2.lib)
if (SDL2_DIR STREQUAL "")
message (FATAL_ERROR "SDL2_DIR must be set in Cygwin")
endif ()
# Assume it has been set manually.
set (SDL2_LIBRARY ${sdlRoot}/lib/${DE_ARCH}/SDL2.lib)
message (STATUS ${SDL2_LIBRARY})
else ()
file (GLOB _hints ${SDL2_DIR}/SDL2* $ENV{DENG_DEPEND_PATH}/SDL2*)
file (GLOB _hints ${sdlRoot}/SDL2* $ENV{DENG_DEPEND_PATH}/SDL2*)
find_library (SDL2_LIBRARY SDL2
PATHS ${SDL2_DIR}
PATHS ${sdlRoot}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
Expand All @@ -47,7 +55,7 @@ elseif (WIN32 OR CYGWIN)
# Define the target.
add_library (SDL2 INTERFACE)
if (CYGWIN)
target_link_libraries(SDL2 INTERFACE ${SDL2_DIR}/lib/${DE_ARCH}/SDL2main.lib)
target_link_libraries(SDL2 INTERFACE ${sdlRoot}/lib/${DE_ARCH}/SDL2main.lib)
endif ()
target_link_libraries (SDL2 INTERFACE ${SDL2_LIBRARY})

Expand All @@ -62,15 +70,19 @@ elseif (WIN32 OR CYGWIN)
deng_install_library (${_libDir}/SDL2.dll)

# Also attempt to locate SLD2_mixer.
deng_clean_path (sdlMixerDir ${SDL2_MIXER_DIR})
set (_oldPath ${SDL_MIXER_LIBRARY})
if (CYGWIN)
set (SDL2_MIXER_LIBRARY ${SDL2_MIXER_DIR}/lib/${DE_ARCH}/SDL2_mixer.lib)
if (SDL2_MIXER_DIR STREQUAL "")
message (FATAL_ERROR "SDL2_MIXER_DIR must be set in Cygwin")
endif ()
set (SDL2_MIXER_LIBRARY ${sdlMixerDir}/lib/${DE_ARCH}/SDL2_mixer.lib)
else ()
file (GLOB _hints ${SDL2_DIR}/SDL2_mixer* ${SDL2_MIXER_DIR}/SDL2_mixer*
file (GLOB _hints ${sdlRoot}/SDL2_mixer* ${sdlMixerDir}/SDL2_mixer*
$ENV{DENG_DEPEND_PATH}/SDL2_mixer*
)
find_library (SDL2_MIXER_LIBRARY SDL2_mixer
PATHS ${SDL2_DIR} ${SDL2_MIXER_DIR}
PATHS ${sdlRoot} ${sdlMixerDir}
HINTS ${_hints} ENV DENG_DEPEND_PATH
PATH_SUFFIXES lib/${DE_ARCH} lib
)
Expand Down
18 changes: 16 additions & 2 deletions doomsday/cmake/Macros.cmake
Expand Up @@ -440,7 +440,7 @@ macro (deng_deploy_library target name)
install (TARGETS ${target} EXPORT ${name}
RUNTIME DESTINATION bin COMPONENT libs
LIBRARY DESTINATION ${DE_INSTALL_LIB_DIR} COMPONENT libs
ARCHIVE DESTINATION lib COMPONENT sdk
ARCHIVE DESTINATION ${DE_INSTALL_LIB_DIR} COMPONENT sdk
)
install (EXPORT ${name} DESTINATION ${DE_INSTALL_CMAKE_DIR}/${name}
FILE ${name}-config.cmake
Expand All @@ -454,6 +454,7 @@ macro (deng_deploy_library target name)
if (NOT APPLE)
# When the SDK is disabled, only the runtime binary is installed.
install (TARGETS ${target}
RUNTIME DESTINATION bin COMPONENT libs
LIBRARY DESTINATION ${DE_INSTALL_LIB_DIR} COMPONENT libs
)
endif ()
Expand Down Expand Up @@ -774,7 +775,7 @@ endfunction (deng_install_tool)
# Not applicable to macOS because libraries are not installed but instead
# bundled with the applicatino.
macro (deng_install_library library)
if (UNIX_LINUX AND NOT CYGWIN)
if (UNIX_LINUX)
string (REGEX REPLACE "(.*)\\.so" "\\1-*.so" versioned ${library})
file (GLOB _links ${library}.* ${versioned})
install (FILES ${library} ${_links}
Expand Down Expand Up @@ -891,3 +892,16 @@ function (deng_link_libraries target visibility)
endforeach (name)
target_link_libraries (${target} ${visibility} ${libTargets})
endfunction (deng_link_libraries)

macro (deng_clean_path outvar)
if (${ARGC} GREATER 1)
set (${outvar} ${ARGV1})
if (CYGWIN)
execute_process (COMMAND cygpath -u ${ARGV1}
OUTPUT_VARIABLE ${outvar}
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif ()
else ()
set (${outVar} "")
endif ()
endmacro ()
8 changes: 3 additions & 5 deletions doomsday/cmake/PlatformCygwin.cmake
Expand Up @@ -3,11 +3,9 @@ include (PlatformGenericUnix)
set (DE_PLATFORM_SUFFIX windows)
set (DE_AMETHYST_PLATFORM WIN32)

# if (NOT CYGWIN)
# set (DE_INSTALL_DATA_DIR "data")
# set (DE_INSTALL_DOC_DIR "doc")
# set (DE_INSTALL_LIB_DIR "bin")
# endif ()
# set (DE_INSTALL_DATA_DIR "data")
set (DE_INSTALL_DOC_DIR "doc")
#set (DE_INSTALL_LIB_DIR "bin")

add_definitions (
-D__USE_BSD
Expand Down
7 changes: 4 additions & 3 deletions doomsday/libs/gamekit/libs/GameConfig.cmake
Expand Up @@ -105,9 +105,10 @@ macro (deng_add_gamelib target)

# if (NOT APPLE)
install (TARGETS ${target}
EXPORT ${target}
DESTINATION ${DE_INSTALL_LIB_DIR}
LIBRARY DESTINATION ${DE_INSTALL_LIB_DIR}
EXPORT ${target}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${DE_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${DE_INSTALL_LIB_DIR}
COMPONENT libs
)
install (EXPORT ${target}
Expand Down

0 comments on commit 214ddbe

Please sign in to comment.