mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Use RPATH for lib folder, use PHYSFS_getBaseDir on all platforms.
The next official VVVVVV build removes 32-bit Linux (like all my other games), and I need to get rid of the shell script on macOS at some point, so this basically brings it up to what my other games are doing. Plus, this probably fixes a bug where someone tries to run their executable away from the root...
This commit is contained in:
parent
1312c10d11
commit
a977f49725
2 changed files with 27 additions and 24 deletions
|
@ -32,15 +32,22 @@ ENDIF()
|
||||||
# Compiler Flags
|
# Compiler Flags
|
||||||
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1)
|
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1)
|
||||||
|
|
||||||
# Executable Suffix
|
# RPATH
|
||||||
IF(APPLE)
|
IF(NOT WIN32)
|
||||||
SET(CMAKE_EXECUTABLE_SUFFIX ".osx")
|
IF(APPLE)
|
||||||
ELSEIF(WIN32)
|
SET(BIN_LIBROOT "osx")
|
||||||
# Nothing!
|
SET(BIN_RPATH "@executable_path/osx")
|
||||||
ELSEIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
ELSEIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
||||||
SET(CMAKE_EXECUTABLE_SUFFIX ".x86_64")
|
SET(BIN_LIBROOT "lib64")
|
||||||
ELSE()
|
SET(BIN_RPATH "\$ORIGIN/lib64")
|
||||||
SET(CMAKE_EXECUTABLE_SUFFIX ".x86")
|
ELSE()
|
||||||
|
SET(BIN_LIBROOT "lib")
|
||||||
|
SET(BIN_RPATH "\$ORIGIN/lib")
|
||||||
|
ENDIF()
|
||||||
|
SET(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
|
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
SET(CMAKE_INSTALL_RPATH ${BIN_RPATH})
|
||||||
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Include Directories
|
# Include Directories
|
||||||
|
@ -106,16 +113,16 @@ SET(PNG_SRC lodepng/lodepng.c)
|
||||||
|
|
||||||
# Executable information
|
# Executable information
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
ADD_EXECUTABLE(vvvvvv WIN32 ${VVV_SRC})
|
ADD_EXECUTABLE(VVVVVV WIN32 ${VVV_SRC})
|
||||||
ELSE()
|
ELSE()
|
||||||
ADD_EXECUTABLE(vvvvvv ${VVV_SRC})
|
ADD_EXECUTABLE(VVVVVV ${VVV_SRC})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Build options
|
# Build options
|
||||||
IF(ENABLE_WARNINGS)
|
IF(ENABLE_WARNINGS)
|
||||||
# The weird syntax is due to CMake generator expressions.
|
# The weird syntax is due to CMake generator expressions.
|
||||||
# Saves quite a few lines and boilerplate at the price of readability.
|
# Saves quite a few lines and boilerplate at the price of readability.
|
||||||
TARGET_COMPILE_OPTIONS(vvvvvv PRIVATE
|
TARGET_COMPILE_OPTIONS(VVVVVV PRIVATE
|
||||||
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
||||||
-Wall $<$<BOOL:ENABLE_WERROR>:-Werror>>
|
-Wall $<$<BOOL:ENABLE_WERROR>:-Werror>>
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:
|
$<$<CXX_COMPILER_ID:MSVC>:
|
||||||
|
@ -128,26 +135,26 @@ ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC})
|
||||||
ADD_LIBRARY(lodepng-static STATIC ${PNG_SRC})
|
ADD_LIBRARY(lodepng-static STATIC ${PNG_SRC})
|
||||||
|
|
||||||
# Static Dependencies
|
# Static Dependencies
|
||||||
TARGET_LINK_LIBRARIES(vvvvvv physfs-static tinyxml-static lodepng-static)
|
TARGET_LINK_LIBRARIES(VVVVVV physfs-static tinyxml-static lodepng-static)
|
||||||
|
|
||||||
# SDL2 Dependency (Detection pulled from FAudio)
|
# SDL2 Dependency (Detection pulled from FAudio)
|
||||||
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
||||||
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
||||||
target_include_directories(vvvvvv PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
target_include_directories(VVVVVV PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
||||||
target_link_libraries(vvvvvv ${SDL2_LIBRARIES})
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
|
||||||
else()
|
else()
|
||||||
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
||||||
find_package(SDL2 CONFIG)
|
find_package(SDL2 CONFIG)
|
||||||
if (TARGET SDL2::SDL2)
|
if (TARGET SDL2::SDL2)
|
||||||
message(STATUS "Using TARGET SDL2::SDL2")
|
message(STATUS "Using TARGET SDL2::SDL2")
|
||||||
target_link_libraries(vvvvvv SDL2::SDL2 SDL2_mixer)
|
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
|
||||||
elseif (TARGET SDL2)
|
elseif (TARGET SDL2)
|
||||||
message(STATUS "Using TARGET SDL2")
|
message(STATUS "Using TARGET SDL2")
|
||||||
target_link_libraries(vvvvvv SDL2 SDL2_mixer)
|
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
|
||||||
else()
|
else()
|
||||||
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
|
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
|
||||||
target_include_directories(vvvvvv PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
target_include_directories(VVVVVV PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
||||||
target_link_libraries(vvvvvv ${SDL2_LIBRARIES} SDL2_mixer)
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -155,5 +162,5 @@ endif()
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
FIND_LIBRARY(FOUNDATION NAMES Foundation)
|
FIND_LIBRARY(FOUNDATION NAMES Foundation)
|
||||||
FIND_LIBRARY(IOKIT NAMES IOKit)
|
FIND_LIBRARY(IOKIT NAMES IOKit)
|
||||||
TARGET_LINK_LIBRARIES(vvvvvv objc ${IOKIT} ${FOUNDATION})
|
TARGET_LINK_LIBRARIES(VVVVVV objc ${IOKIT} ${FOUNDATION})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
|
@ -70,12 +70,8 @@ int FILESYSTEM_init(char *argvZero)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mount the stock content last */
|
/* Mount the stock content last */
|
||||||
#ifdef _WIN32
|
|
||||||
strcpy(output, PHYSFS_getBaseDir());
|
strcpy(output, PHYSFS_getBaseDir());
|
||||||
strcat(output, "data.zip");
|
strcat(output, "data.zip");
|
||||||
#else
|
|
||||||
strcpy(output, "data.zip");
|
|
||||||
#endif
|
|
||||||
if (!PHYSFS_mount(output, NULL, 1))
|
if (!PHYSFS_mount(output, NULL, 1))
|
||||||
{
|
{
|
||||||
puts("Error: data.zip missing!");
|
puts("Error: data.zip missing!");
|
||||||
|
|
Loading…
Reference in a new issue