Skip to content

Commit

Permalink
Allow linking against system libraries for almost everything (stepman…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsh authored and shakesoda committed Feb 16, 2019
1 parent 021d494 commit b8a79cd
Show file tree
Hide file tree
Showing 78 changed files with 4,889 additions and 4,795 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,4 @@ BuildLog.htm
*.swp
*.pc
*.d
.vscode/
76 changes: 46 additions & 30 deletions CMake/CMakeMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ endfunction()

function(sm_append_simple_target_property target property str)
get_target_property(current_property ${target} ${property})
if (current_property)
if(current_property)
list(APPEND current_property ${str})
set_target_properties(${target} PROPERTIES ${property} "${current_property}")
set_target_properties(${target}
PROPERTIES ${property} "${current_property}")
else()
set_target_properties(${target} PROPERTIES ${property} ${str})
endif()
endfunction()

# Borrowed from http://stackoverflow.com/a/7172941/445373
# TODO: Upgrade to cmake 3.x so that this function is not needed.
# Borrowed from http://stackoverflow.com/a/7172941/445373 TODO: Upgrade to cmake
# 3.x so that this function is not needed.
function(sm_join values glue output)
string(REPLACE ";" "${glue}" _TMP_STR "${values}")
string(REPLACE ";"
"${glue}"
_TMP_STR
"${values}")
set(${output} "${_TMP_STR}" PARENT_SCOPE)
endfunction()

Expand All @@ -28,20 +32,22 @@ endfunction()

function(sm_add_compile_flag target flag)
get_target_property(current_property ${target} COMPILE_FLAGS)
if (current_property)
if(current_property)
set(current_property "${current_property} ${flag}")
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${current_property}")
set_target_properties(${target}
PROPERTIES COMPILE_FLAGS "${current_property}")
else()
set_target_properties(${target} PROPERTIES COMPILE_FLAGS ${flag})
endif()
endfunction()

function(sm_add_link_flag target flag)
if (MSVC)
if(MSVC)
# Use a modified form of sm_append_simple_target_property.
get_target_property(current_property ${target} LINK_FLAGS)
if (current_property)
set_target_properties(${target} PROPERTIES LINK_FLAGS "${current_property} ${flag}")
if(current_property)
set_target_properties(${target}
PROPERTIES LINK_FLAGS "${current_property} ${flag}")
else()
set_target_properties(${target} PROPERTIES LINK_FLAGS ${flag})
endif()
Expand All @@ -51,25 +57,32 @@ function(sm_add_link_flag target flag)
endfunction()

function(disable_project_warnings projectName)
if (NOT WITH_EXTERNAL_WARNINGS)
if (MSVC)
if(NOT WITH_EXTERNAL_WARNINGS)
if(MSVC)
sm_add_compile_flag(${projectName} "/W0")
elseif(APPLE)
set_target_properties(${projectName} PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_INHIBIT_ALL_WARNINGS "YES")
set_target_properties(
${projectName}
PROPERTIES XCODE_ATTRIBUTE_GCC_WARN_INHIBIT_ALL_WARNINGS "YES")
else()
set_target_properties(${projectName} PROPERTIES COMPILE_FLAGS "-w")
endif()
endif()
endfunction()

macro(check_compile_features BIN_DIR SOURCE_FILE GREETER GREET_SUCCESS GREET_FAILURE TARGET_VAR ON_SUCCESS)
macro(check_compile_features
BIN_DIR
SOURCE_FILE
GREETER
GREET_SUCCESS
GREET_FAILURE
TARGET_VAR
ON_SUCCESS)
if(NOT DEFINED "${TARGET_VAR}")
message(STATUS "${GREETER}")
try_compile(${TARGET_VAR} "${BIN_DIR}"
SOURCES "${SOURCE_FILE}"
)
try_compile(${TARGET_VAR} "${BIN_DIR}" SOURCES "${SOURCE_FILE}")
if(${TARGET_VAR})
if (${ON_SUCCESS})
if(${ON_SUCCESS})
message(STATUS "${GREETER} - ${GREET_SUCCESS}")
set(${TARGET_VAR} 1 CACHE INTERNAL "${GREETER}")
else()
Expand All @@ -93,25 +106,28 @@ macro(configure_msvc_runtime)
if(MSVC)
# Get the compiler options generally used.
list(APPEND COMPILER_VARIABLES
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
)
if (WITH_STATIC_LINKING)
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(WITH_STATIC_LINKING)
set(TO_REPLACE "/MD")
set(REPLACE_WITH "/MT")
else()
set(TO_REPLACE "/MT")
set(REPLACE_WITH "/MD")
endif()
foreach(COMPILER_VARIABLE ${COMPILER_VARIABLES})
if (${COMPILER_VARIABLE} MATCHES "${TO_REPLACE}")
string(REGEX REPLACE "${TO_REPLACE}" "${REPLACE_WITH}" ${COMPILER_VARIABLE} "${${COMPILER_VARIABLE}}")
if(${COMPILER_VARIABLE} MATCHES "${TO_REPLACE}")
string(REGEX
REPLACE "${TO_REPLACE}"
"${REPLACE_WITH}"
${COMPILER_VARIABLE}
"${${COMPILER_VARIABLE}}")
endif()
endforeach()
endif()
Expand Down
31 changes: 19 additions & 12 deletions CMake/CPackSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,41 @@ set(CPACK_NSIS_URL_INFO_ABOUT "http://www.stepmania.com/")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
set(CPACK_RESOURCE_FILE_README "${SM_ROOT_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${SM_CMAKE_DIR}/license_install.txt")
set(CPACK_PACKAGE_EXECUTABLES
"${SM_EXE_NAME}" "StepMania ${SM_VERSION_MAJOR}"
)
set(CPACK_PACKAGE_EXECUTABLES "${SM_EXE_NAME}" "StepMania ${SM_VERSION_MAJOR}")
set(CPACK_NSIS_MUI_ICON "${SM_INSTALLER_DIR}/install.ico")
set(CPACK_NSIS_MUI_UNIICON "${SM_INSTALLER_DIR}/uninstall.ico")
set(CPACK_NSIS_COMPRESSOR "/SOLID lzma")

# Custom items for nsis go here.
set(CPACK_SM_NSIS_REPOSITORY "https://github.com/stepmania/stepmania")
set(CPACK_SM_NSIS_ROOT_DIR "${SM_ROOT_DIR}")
set(CPACK_SM_NSIS_PRODUCT_ID "StepMania ${SM_VERSION_MAJOR}.${SM_VERSION_MINOR}")
set(CPACK_SM_NSIS_PRODUCT_ID
"StepMania ${SM_VERSION_MAJOR}.${SM_VERSION_MINOR}")
set(CPACK_SM_NSIS_PRODUCT_VERSION "${SM_VERSION_TRADITIONAL}.0")
set(CPACK_SM_NSIS_HEADER_BITMAP "${SM_INSTALLER_DIR}/header-sm5.bmp")
set(CPACK_SM_NSIS_WELCOME_BITMAP "${SM_INSTALLER_DIR}/welcome-sm5.bmp")
set(CPACK_SM_NSIS_GIT_VERSION "${SM_VERSION_GIT}")

if(WIN32)
# The header and welcome bitmaps require backslashes.
string(REGEX REPLACE "/" "\\\\\\\\" CPACK_SM_NSIS_HEADER_BITMAP "${CPACK_SM_NSIS_HEADER_BITMAP}")
string(REGEX REPLACE "/" "\\\\\\\\" CPACK_SM_NSIS_WELCOME_BITMAP "${CPACK_SM_NSIS_WELCOME_BITMAP}")
string(REGEX
REPLACE "/"
"\\\\\\\\"
CPACK_SM_NSIS_HEADER_BITMAP
"${CPACK_SM_NSIS_HEADER_BITMAP}")
string(REGEX
REPLACE "/"
"\\\\\\\\"
CPACK_SM_NSIS_WELCOME_BITMAP
"${CPACK_SM_NSIS_WELCOME_BITMAP}")

set(CPACK_PACKAGE_FILE_NAME "${SM_EXE_NAME}-${NSIS_VERSION_FINAL}-win32")
# By setting these install keys manually,
# The default directory of "StepMania major.minor.patch" is lost.
# This is currently done to maintain backwards compatibility.
# However, removing these two will allow for multiple versions of StepMania
# to be installed relatively cleanly.
set(CPACK_PACKAGE_INSTALL_DIRECTORY "StepMania ${SM_VERSION_MAJOR}.${SM_VERSION_MINOR}")
# By setting these install keys manually, The default directory of "StepMania
# major.minor.patch" is lost. This is currently done to maintain backwards
# compatibility. However, removing these two will allow for multiple versions
# of StepMania to be installed relatively cleanly.
set(CPACK_PACKAGE_INSTALL_DIRECTORY
"StepMania ${SM_VERSION_MAJOR}.${SM_VERSION_MINOR}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "StepMania ${SM_VERSION_MAJOR}")
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "Program")
set(CPACK_NSIS_INSTALL_ROOT "C:\\\\Games")
Expand Down
88 changes: 63 additions & 25 deletions CMake/DefineOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,41 @@
option(WITH_NETWORKING "Build with networking support." ON)

# This option quiets warnings that are a part of external projects.
option(WITH_EXTERNAL_WARNINGS "Build with warnings for all components, not just StepMania." OFF)
option(WITH_EXTERNAL_WARNINGS
"Build with warnings for all components, not just StepMania." OFF)

# This option is not yet working, but will likely default to ON in the future.
option(WITH_LTO "Build with Link Time Optimization (LTO)/Whole Program Optimization." OFF)
option(WITH_LTO
"Build with Link Time Optimization (LTO)/Whole Program Optimization."
OFF)

# This option handles if we use SSE2 processing.
option(WITH_SSE2 "Build with SSE2 Optimizations." ON)

# This option may go away in the future: if it does, JPEG will always be required.
# This option may go away in the future: if it does, JPEG will always be
# required.
option(WITH_JPEG "Build with JPEG Image Support." ON)

# Turn this on to set this to a specific release mode.
option(WITH_FULL_RELEASE "Build as a proper, full release." OFF)

# Turn this on to compile tomcrypt with no assembly data. This is a portable mode.
option(WITH_PORTABLE_TOMCRYPT "Build with assembly/free tomcrypt, making it portable." ON)
# Turn this on to compile tomcrypt with no assembly data. This is a portable
# mode.
option(WITH_PORTABLE_TOMCRYPT
"Build with assembly/free tomcrypt, making it portable." ON)

# Turn this on to not use the ROLC assembly featurs of tomcrypt.
# If WITH_PORTABLE_TOMCRYPT is ON, this will automatically have no effect.
option(WITH_NO_ROLC_TOMCRYPT "Build without the ROLC assembly instructions for tomcrypt. (Ignored by Apple builds)" OFF)
# Turn this on to not use the ROLC assembly featurs of tomcrypt. If
# WITH_PORTABLE_TOMCRYPT is ON, this will automatically have no effect.
option(
WITH_NO_ROLC_TOMCRYPT
"Build without the ROLC assembly instructions for tomcrypt."
OFF)

# Turn this option off to not use the GPL exclusive components.
option(WITH_GPL_LIBS "Build with GPL libraries." ON)

# Turn this option off to disable using WAV files with the game.
# Note that it is recommended to keep this on.
# Turn this option off to disable using WAV files with the game. Note that it is
# recommended to keep this on.
option(WITH_WAV "Build with WAV Support." ON)

# Turn this option off to disable using MP3 files with the game.
Expand All @@ -39,34 +48,63 @@ option(WITH_MP3 "Build with MP3 Support." ON)
option(WITH_OGG "Build with OGG/Vorbis Support." ON)

# Turn this option on to log every segment added or removed.
option(WITH_LOGGING_TIMING_DATA "Build with logging all Add and Erase Segment calls." OFF)
option(WITH_LOGGING_TIMING_DATA
"Build with logging all Add and Erase Segment calls." OFF)

option(WITH_SYSTEM_PNG "Build with system PNG library (may not work on 1.6+)"
OFF)
option(WITH_SYSTEM_OGG "Build with system OGG libraries" OFF)
option(WITH_SYSTEM_GLEW "Build with system GLEW library" OFF)
option(WITH_SYSTEM_TOMMATH "Build with system libtommath" OFF)
option(WITH_SYSTEM_TOMCRYPT "Build with system libtomcrypt" OFF)
option(WITH_SYSTEM_MAD "Build with system libmad" OFF)
option(WITH_SYSTEM_JSONCPP "Build with system jsoncpp" OFF)
option(WITH_SYSTEM_JPEG "Build with system jpeglib" OFF)
option(WITH_SYSTEM_PCRE "Build with system PCRE" OFF)
option(WITH_SYSTEM_ZLIB "Build against system zlib" OFF)

option(WITH_SDL "Build with SDL" OFF)

if(NOT MSVC)
# Turn this option off to disable using FFMEPG.
option(WITH_FFMPEG "Build with FFMPEG." ON)
# Change this number to utilize a different number of jobs for building FFMPEG.
# Change this number to utilize a different number of jobs for building
# FFMPEG.
option(WITH_FFMPEG_JOBS "Build FFMPEG with this many jobs." 2)
else()
# Turn this option on to enable using the Texture Font Generator.
option(WITH_TEXTURE_GENERATOR "Build with the Texture Font Generator. Ensure the MFC library is installed." OFF)
option(
WITH_TEXTURE_GENERATOR
"Build with the Texture Font Generator. Ensure the MFC library is installed."
OFF)
# Turn this option off to use dynamic linking instead of static linking.
option(WITH_STATIC_LINKING "Build StepMania with static linking." ON)
endif()

if(WIN32)
option(WITH_MINIMAID "Build with Minimaid Lights Support." OFF)
# Developer only option: connect to IRC to report the result. Only use with build servers.
# Developer only option: connect to IRC to report the result. Only use with
# build servers.
option(WITH_IRC_POST_HOOK "Report via IRC of the success afterwards." OFF)
elseif(LINUX)
# Builder beware: later versions of ffmpeg may break!
option(WITH_SYSTEM_FFMPEG "Build with the system's FFMPEG, disabled build with bundled's FFMPEG" OFF)
option(WITH_CRYSTALHD_DISABLED "Build FFMPEG without Crystal HD support." OFF)
option(WITH_MINIMAID "Build with Minimaid Lights Support." OFF)
option(WITH_TTY "Build with Linux TTY Input Support." OFF)
option(WITH_PROFILING "Build with Profiling Support." OFF)
option(WITH_GLES2 "Build with OpenGL ES 2.0 Support." ON)
option(WITH_GTK2 "Build with GTK2 Support." ON)
option(WITH_PARALLEL_PORT "Build with Parallel Lights I/O Support." OFF)
option(WITH_CRASH_HANDLER "Build with Crash Handler Support." ON)
option(WITH_XINERAMA "Build using libXinerama to query for monitor numbers (if available)." ON)
# Builder beware: later versions of ffmpeg may break!
option(WITH_SYSTEM_FFMPEG
"Build with the system's FFMPEG, disabled build with bundled's FFMPEG"
OFF)
option(WITH_CRYSTALHD_DISABLED "Build FFMPEG without Crystal HD support." OFF)
option(WITH_MINIMAID "Build with Minimaid Lights Support." OFF)
option(WITH_TTY "Build with Linux TTY Input Support." OFF)
option(WITH_PROFILING "Build with Profiling Support." OFF)
option(WITH_GLES2 "Build with OpenGL ES 2.0 Support." ON)
option(WITH_GTK2 "Build with GTK2 Support." ON)
option(WITH_PARALLEL_PORT "Build with Parallel Lights I/O Support." OFF)
option(WITH_CRASH_HANDLER "Build with Crash Handler Support." ON)
option(WITH_XINERAMA
"Build using libXinerama to query for monitor numbers (if available)."
ON)
option(WITH_ALSA "Build with ALSA support" ON)
option(WITH_PULSEAUDIO "Build with PulseAudio support" OFF)
option(WITH_JACK "Build with JACK support" OFF)
option(WITH_XRANDR "Build with Xrandr support" ON)
option(WITH_X11 "Build with X11 support" ON)
endif()
39 changes: 18 additions & 21 deletions CMake/Modules/FindDirectX.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# From the CMake wiki, get the DirectX version needed.
# This assumes default directories.
# From the CMake wiki, get the DirectX version needed. This assumes default
# directories.

# Once loaded, the following are defined:
# DIRECTX_FOUND
# DIRECTX_INCLUDE_DIR
# DIRECTX_LIBRARIES
# Once loaded, the following are defined: DIRECTX_FOUND DIRECTX_INCLUDE_DIR
# DIRECTX_LIBRARIES

if(NOT WIN32)
return()
Expand All @@ -15,29 +13,28 @@ if(NOT EXISTS "$ENV{DXSDK_DIR}")
endif()

set(DIRECTX_INCLUDE_SEARCH_PATHS
# TODO: Do not be limited to x86 in the future.
"$ENV{DXSDK_DIR}/Include"
)
# TODO: Do not be limited to x86 in the future.
"$ENV{DXSDK_DIR}/Include")

set(DIRECTX_LIBRARY_SEARCH_PATHS
# TODO: Do not be limited to x86 in the future.
"$ENV{DXSDK_DIR}/Lib/x86"
)
# TODO: Do not be limited to x86 in the future.
"$ENV{DXSDK_DIR}/Lib/x86")

find_path(DIRECTX_INCLUDE_DIR
NAMES "DxErr.h"
PATHS ${DIRECTX_INCLUDE_SEARCH_PATHS}
DOC "Where can DxErr.h be found?"
)
NAMES "DxErr.h"
PATHS ${DIRECTX_INCLUDE_SEARCH_PATHS}
DOC "Where can DxErr.h be found?")

find_library(DIRECTX_LIBRARIES
NAMES "DxErr.lib" "d3dx9.lib"
PATHS ${DIRECTX_LIBRARY_SEARCH_PATHS}
DOC "Where can the DX libraries be found?"
)
NAMES "DxErr.lib" "d3dx9.lib"
PATHS ${DIRECTX_LIBRARY_SEARCH_PATHS}
DOC "Where can the DX libraries be found?")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DIRECTX DEFAULT_MSG DIRECTX_INCLUDE_DIR DIRECTX_LIBRARIES)
find_package_handle_standard_args(DIRECTX
DEFAULT_MSG
DIRECTX_INCLUDE_DIR
DIRECTX_LIBRARIES)

if(DIRECTX_FOUND)
mark_as_advanced(DIRECTX_INCLUDE_DIR DIRECTX_LIBRARIES)
Expand Down
Loading

0 comments on commit b8a79cd

Please sign in to comment.