2020-01-01 21:29:24 +01:00
|
|
|
# CMake File for VVVVVV
|
|
|
|
# Written by Ethan "flibitijibibo" Lee
|
|
|
|
|
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
|
|
|
|
2020-01-11 01:58:33 +01:00
|
|
|
# CMake Options
|
|
|
|
OPTION(ENABLE_WARNINGS "Enable compilation warnings" ON)
|
|
|
|
OPTION(ENABLE_WERROR "Treat compilation warnings as errors" OFF)
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
# Architecture Flags
|
|
|
|
IF(APPLE)
|
|
|
|
# Wow, Apple is a huge jerk these days huh?
|
2020-01-11 01:49:42 +01:00
|
|
|
SET(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
|
2020-01-11 13:40:07 +01:00
|
|
|
IF(NOT CMAKE_OSX_SYSROOT)
|
|
|
|
IF(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
|
|
|
|
SET(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
|
|
|
|
ENDIF()
|
2020-01-11 01:49:42 +01:00
|
|
|
ENDIF()
|
2020-01-01 21:29:24 +01:00
|
|
|
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
|
|
|
|
LINK_DIRECTORIES(/usr/local/lib)
|
2020-01-10 23:12:51 +01:00
|
|
|
ADD_COMPILE_OPTIONS(-Werror=partial-availability)
|
2020-01-01 21:29:24 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2020-01-11 05:24:41 +01:00
|
|
|
PROJECT(VVVVVV)
|
|
|
|
|
2020-01-11 13:40:07 +01:00
|
|
|
IF(APPLE)
|
|
|
|
MESSAGE(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
|
|
|
|
ENDIF()
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
# Compiler Flags
|
|
|
|
ADD_DEFINITIONS(-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1)
|
|
|
|
|
2020-01-11 17:23:49 +01:00
|
|
|
# RPATH
|
|
|
|
IF(NOT WIN32)
|
|
|
|
IF(APPLE)
|
|
|
|
SET(BIN_LIBROOT "osx")
|
|
|
|
SET(BIN_RPATH "@executable_path/osx")
|
|
|
|
ELSEIF(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
|
|
|
SET(BIN_LIBROOT "lib64")
|
|
|
|
SET(BIN_RPATH "\$ORIGIN/lib64")
|
|
|
|
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)
|
2020-01-01 21:29:24 +01:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Include Directories
|
|
|
|
INCLUDE_DIRECTORIES(src tinyxml physfs lodepng)
|
|
|
|
|
|
|
|
# Source Lists
|
|
|
|
SET(VVV_SRC
|
|
|
|
src/BinaryBlob.cpp
|
|
|
|
src/BlockV.cpp
|
|
|
|
src/editor.cpp
|
|
|
|
src/Ent.cpp
|
|
|
|
src/Entity.cpp
|
|
|
|
src/FileSystemUtils.cpp
|
|
|
|
src/Finalclass.cpp
|
|
|
|
src/Game.cpp
|
|
|
|
src/Graphics.cpp
|
|
|
|
src/GraphicsResources.cpp
|
|
|
|
src/GraphicsUtil.cpp
|
|
|
|
src/Input.cpp
|
|
|
|
src/KeyPoll.cpp
|
|
|
|
src/Labclass.cpp
|
|
|
|
src/Logic.cpp
|
|
|
|
src/Map.cpp
|
|
|
|
src/Music.cpp
|
|
|
|
src/Otherlevel.cpp
|
|
|
|
src/preloader.cpp
|
|
|
|
src/Screen.cpp
|
|
|
|
src/Script.cpp
|
|
|
|
src/Scripts.cpp
|
|
|
|
src/SoundSystem.cpp
|
|
|
|
src/Spacestation2.cpp
|
|
|
|
src/TerminalScripts.cpp
|
|
|
|
src/Textbox.cpp
|
|
|
|
src/titlerender.cpp
|
|
|
|
src/Tower.cpp
|
|
|
|
src/UtilityClass.cpp
|
|
|
|
src/WarpClass.cpp
|
|
|
|
src/main.cpp
|
|
|
|
src/SteamNetwork.c
|
|
|
|
)
|
|
|
|
SET(XML_SRC
|
|
|
|
tinyxml/tinystr.cpp
|
|
|
|
tinyxml/tinyxml.cpp
|
|
|
|
tinyxml/tinyxmlerror.cpp
|
|
|
|
tinyxml/tinyxmlparser.cpp
|
|
|
|
)
|
|
|
|
SET(PFS_SRC
|
|
|
|
physfs/physfs.c
|
|
|
|
physfs/physfs_archiver_dir.c
|
|
|
|
physfs/physfs_archiver_unpacked.c
|
|
|
|
physfs/physfs_archiver_zip.c
|
|
|
|
physfs/physfs_byteorder.c
|
|
|
|
physfs/physfs_unicode.c
|
|
|
|
physfs/physfs_platform_posix.c
|
|
|
|
physfs/physfs_platform_unix.c
|
|
|
|
physfs/physfs_platform_windows.c
|
|
|
|
)
|
|
|
|
IF(APPLE)
|
|
|
|
# Are you noticing a pattern with this Apple crap yet?
|
|
|
|
SET(PFS_SRC ${PFS_SRC} physfs/physfs_platform_apple.m)
|
|
|
|
ENDIF()
|
|
|
|
SET(PNG_SRC lodepng/lodepng.c)
|
|
|
|
|
|
|
|
# Executable information
|
|
|
|
IF(WIN32)
|
2020-01-11 17:23:49 +01:00
|
|
|
ADD_EXECUTABLE(VVVVVV WIN32 ${VVV_SRC})
|
2020-01-01 21:29:24 +01:00
|
|
|
ELSE()
|
2020-01-11 17:23:49 +01:00
|
|
|
ADD_EXECUTABLE(VVVVVV ${VVV_SRC})
|
2020-01-01 21:29:24 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2020-01-11 01:58:33 +01:00
|
|
|
# Build options
|
|
|
|
IF(ENABLE_WARNINGS)
|
|
|
|
# The weird syntax is due to CMake generator expressions.
|
|
|
|
# Saves quite a few lines and boilerplate at the price of readability.
|
2020-01-11 17:23:49 +01:00
|
|
|
TARGET_COMPILE_OPTIONS(VVVVVV PRIVATE
|
2020-01-11 01:58:33 +01:00
|
|
|
$<$<OR:$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
|
|
|
|
-Wall $<$<BOOL:ENABLE_WERROR>:-Werror>>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
|
|
/W4 $<$<BOOL:ENABLE_WERROR>:/WX>>)
|
|
|
|
ENDIF()
|
|
|
|
|
2020-01-01 21:29:24 +01:00
|
|
|
# Library information
|
|
|
|
ADD_LIBRARY(tinyxml-static STATIC ${XML_SRC})
|
|
|
|
ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC})
|
|
|
|
ADD_LIBRARY(lodepng-static STATIC ${PNG_SRC})
|
|
|
|
|
|
|
|
# Static Dependencies
|
2020-01-11 17:23:49 +01:00
|
|
|
TARGET_LINK_LIBRARIES(VVVVVV physfs-static tinyxml-static lodepng-static)
|
2020-01-01 21:29:24 +01:00
|
|
|
|
|
|
|
# SDL2 Dependency (Detection pulled from FAudio)
|
|
|
|
if (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES)
|
|
|
|
message(STATUS "Using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES")
|
2020-01-11 17:23:49 +01:00
|
|
|
target_include_directories(VVVVVV PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
|
|
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES})
|
2020-01-01 21:29:24 +01:00
|
|
|
else()
|
|
|
|
# Only try to autodetect if both SDL2 variables aren't explicitly set
|
|
|
|
find_package(SDL2 CONFIG)
|
|
|
|
if (TARGET SDL2::SDL2)
|
|
|
|
message(STATUS "Using TARGET SDL2::SDL2")
|
2020-01-11 17:23:49 +01:00
|
|
|
target_link_libraries(VVVVVV SDL2::SDL2 SDL2_mixer)
|
2020-01-01 21:29:24 +01:00
|
|
|
elseif (TARGET SDL2)
|
|
|
|
message(STATUS "Using TARGET SDL2")
|
2020-01-11 17:23:49 +01:00
|
|
|
target_link_libraries(VVVVVV SDL2 SDL2_mixer)
|
2020-01-01 21:29:24 +01:00
|
|
|
else()
|
|
|
|
message(STATUS "No TARGET SDL2::SDL2, or SDL2, using variables")
|
2020-01-11 17:23:49 +01:00
|
|
|
target_include_directories(VVVVVV PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>")
|
|
|
|
target_link_libraries(VVVVVV ${SDL2_LIBRARIES} SDL2_mixer)
|
2020-01-01 21:29:24 +01:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Yes, more Apple Crap
|
|
|
|
IF(APPLE)
|
|
|
|
FIND_LIBRARY(FOUNDATION NAMES Foundation)
|
|
|
|
FIND_LIBRARY(IOKIT NAMES IOKit)
|
2020-01-11 17:23:49 +01:00
|
|
|
TARGET_LINK_LIBRARIES(VVVVVV objc ${IOKIT} ${FOUNDATION})
|
2020-01-01 21:29:24 +01:00
|
|
|
ENDIF()
|