1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

Lowercase function calls in CMakeLists

Lowercase names are easier to type and are more distinguishable from the
capital letters that usually go inside the function calls as arguments.
This commit is contained in:
Misa 2021-04-16 16:30:51 -07:00 committed by Ethan Lee
parent d2951fb7f4
commit c41ec551f7

View file

@ -1,98 +1,98 @@
# CMake File for VVVVVV # CMake File for VVVVVV
# Written by Ethan "flibitijibibo" Lee # Written by Ethan "flibitijibibo" Lee
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
# CMake Options # CMake Options
OPTION(ENABLE_WARNINGS "Enable compilation warnings" ON) option(ENABLE_WARNINGS "Enable compilation warnings" ON)
OPTION(ENABLE_WERROR "Treat compilation warnings as errors" OFF) option(ENABLE_WERROR "Treat compilation warnings as errors" OFF)
SET(BUNDLE_DEPENDENCIES ON CACHE BOOL "Use bundled TinyXML-2, PhysicsFS, and UTF8-CPP (if disabled, TinyXML-2 and PhysicsFS will be dynamically linked, LodePNG and UTF8-CPP will still be statically linked)") set(BUNDLE_DEPENDENCIES ON CACHE BOOL "Use bundled TinyXML-2, PhysicsFS, and UTF8-CPP (if disabled, TinyXML-2 and PhysicsFS will be dynamically linked, LodePNG and UTF8-CPP will still be statically linked)")
SET(CUSTOM_LEVEL_SUPPORT ENABLED CACHE STRING "Optionally disable playing and/or editing of custom levels") set(CUSTOM_LEVEL_SUPPORT ENABLED CACHE STRING "Optionally disable playing and/or editing of custom levels")
SET_PROPERTY(CACHE CUSTOM_LEVEL_SUPPORT PROPERTY STRINGS ENABLED NO_EDITOR DISABLED) set_property(CACHE CUSTOM_LEVEL_SUPPORT PROPERTY STRINGS ENABLED NO_EDITOR DISABLED)
SET(STEAM OFF CACHE BOOL "Use the Steam API") set(STEAM OFF CACHE BOOL "Use the Steam API")
SET(GOG OFF CACHE BOOL "Use the GOG API") set(GOG OFF CACHE BOOL "Use the GOG API")
SET(OFFICIAL_BUILD OFF CACHE BOOL "Compile an official build of the game") set(OFFICIAL_BUILD OFF CACHE BOOL "Compile an official build of the game")
SET(MAKEANDPLAY OFF CACHE BOOL "Compile a version of the game without the main campaign (provided for convenience; consider modifying MakeAndPlay.h instead") set(MAKEANDPLAY OFF CACHE BOOL "Compile a version of the game without the main campaign (provided for convenience; consider modifying MakeAndPlay.h instead")
IF(OFFICIAL_BUILD AND NOT MAKEANDPLAY) if(OFFICIAL_BUILD AND NOT MAKEANDPLAY)
SET(STEAM ON) set(STEAM ON)
SET(GOG ON) set(GOG ON)
ENDIF() endif()
IF(MAKEANDPLAY) if(MAKEANDPLAY)
ADD_DEFINITIONS(-DMAKEANDPLAY) add_definitions(-DMAKEANDPLAY)
ENDIF() endif()
# Set standard to C++98/C++03 # Set C++ standard to C++98/C++03
SET(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD 98)
SET(CMAKE_CXX_EXTENSIONS OFF) # prevent mixing stdlib implementations (dangerous!) set(CMAKE_CXX_EXTENSIONS OFF) # prevent mixing stdlib implementations (dangerous!)
# Architecture Flags # Architecture Flags
IF(APPLE) if(APPLE)
# Wow, Apple is a huge jerk these days huh? # Wow, Apple is a huge jerk these days huh?
SET(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk) set(OSX_10_9_SDK_PATH /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk)
IF(NOT CMAKE_OSX_SYSROOT) if(NOT CMAKE_OSX_SYSROOT)
IF(IS_DIRECTORY ${OSX_10_9_SDK_PATH}) if(IS_DIRECTORY ${OSX_10_9_SDK_PATH})
SET(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH}) set(CMAKE_OSX_SYSROOT ${OSX_10_9_SDK_PATH})
ELSE() else()
MESSAGE(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.") message(WARNING "CMAKE_OSX_SYSROOT not set and macOS 10.9 SDK not found! Using default one.")
ENDIF() endif()
ENDIF() endif()
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.9) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
LINK_DIRECTORIES(/usr/local/lib) link_directories(/usr/local/lib)
ADD_COMPILE_OPTIONS(-Werror=partial-availability) add_compile_options(-Werror=partial-availability)
ENDIF() endif()
PROJECT(VVVVVV) project(VVVVVV)
IF(APPLE) if(APPLE)
MESSAGE(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}") message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
ENDIF() 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)
# RPATH # RPATH
IF(NOT WIN32) if(NOT WIN32)
IF(APPLE) if(APPLE)
SET(BIN_LIBROOT "osx") set(BIN_LIBROOT "osx")
SET(BIN_RPATH "@executable_path/osx") set(BIN_RPATH "@executable_path/osx")
ELSEIF(CMAKE_SIZEOF_VOID_P MATCHES "8") elseif(CMAKE_SIZEOF_VOID_P MATCHES "8")
SET(BIN_LIBROOT "lib64") set(BIN_LIBROOT "lib64")
SET(BIN_RPATH "\$ORIGIN/lib64") set(BIN_RPATH "\$ORIGIN/lib64")
ELSE() else()
SET(BIN_LIBROOT "lib") set(BIN_LIBROOT "lib")
SET(BIN_RPATH "\$ORIGIN/lib") set(BIN_RPATH "\$ORIGIN/lib")
ENDIF() endif()
SET(CMAKE_SKIP_BUILD_RPATH TRUE) set(CMAKE_SKIP_BUILD_RPATH TRUE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH ${BIN_RPATH}) set(CMAKE_INSTALL_RPATH ${BIN_RPATH})
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
ENDIF() endif()
# Include Directories # Include Directories
IF(BUNDLE_DEPENDENCIES) if(BUNDLE_DEPENDENCIES)
INCLUDE_DIRECTORIES( include_directories(
src src
../third_party/tinyxml2 ../third_party/tinyxml2
../third_party/physfs ../third_party/physfs
../third_party/lodepng ../third_party/lodepng
../third_party/utfcpp/source ../third_party/utfcpp/source
) )
ELSE() else()
INCLUDE_DIRECTORIES( include_directories(
src src
../third_party/lodepng ../third_party/lodepng
) )
ENDIF() endif()
# Source Lists # Source Lists
SET(VVV_SRC set(VVV_SRC
src/BinaryBlob.cpp src/BinaryBlob.cpp
src/BlockV.cpp src/BlockV.cpp
src/Ent.cpp src/Ent.cpp
@ -129,22 +129,22 @@ SET(VVV_SRC
src/Network.c src/Network.c
src/ThirdPartyDeps.c src/ThirdPartyDeps.c
) )
IF(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED") if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
LIST(APPEND VVV_SRC src/editor.cpp) list(APPEND VVV_SRC src/editor.cpp)
ENDIF() endif()
IF(STEAM) if(STEAM)
LIST(APPEND VVV_SRC src/SteamNetwork.c) list(APPEND VVV_SRC src/SteamNetwork.c)
ADD_DEFINITIONS(-DSTEAM_NETWORK) add_definitions(-DSTEAM_NETWORK)
ENDIF() endif()
IF(GOG) if(GOG)
LIST(APPEND VVV_SRC src/GOGNetwork.c) list(APPEND VVV_SRC src/GOGNetwork.c)
ADD_DEFINITIONS(-DGOG_NETWORK) add_definitions(-DGOG_NETWORK)
ENDIF() endif()
SET(XML2_SRC set(XML2_SRC
../third_party/tinyxml2/tinyxml2.cpp ../third_party/tinyxml2/tinyxml2.cpp
) )
SET(PFS_SRC set(PFS_SRC
../third_party/physfs/physfs.c ../third_party/physfs/physfs.c
../third_party/physfs/physfs_archiver_dir.c ../third_party/physfs/physfs_archiver_dir.c
../third_party/physfs/physfs_archiver_unpacked.c ../third_party/physfs/physfs_archiver_unpacked.c
@ -156,32 +156,32 @@ SET(PFS_SRC
../third_party/physfs/physfs_platform_windows.c ../third_party/physfs/physfs_platform_windows.c
../third_party/physfs/physfs_platform_haiku.cpp ../third_party/physfs/physfs_platform_haiku.cpp
) )
IF(APPLE) if(APPLE)
# Are you noticing a pattern with this Apple crap yet? # Are you noticing a pattern with this Apple crap yet?
SET(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m) set(PFS_SRC ${PFS_SRC} ../third_party/physfs/physfs_platform_apple.m)
ENDIF() endif()
SET(PNG_SRC ../third_party/lodepng/lodepng.c) set(PNG_SRC ../third_party/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()
IF(NOT OFFICIAL_BUILD) if(NOT OFFICIAL_BUILD)
# Add interim commit hash and its date to the build # Add interim commit hash and its date to the build
# FIND_PACKAGE sets GIT_FOUND and GIT_EXECUTABLE # find_package sets GIT_FOUND and GIT_EXECUTABLE
FIND_PACKAGE(Git) find_package(Git)
IF(GIT_FOUND) if(GIT_FOUND)
# These filenames have to be qualified, because when we run # These filenames have to be qualified, because when we run
# the CMake script, its work dir gets set to the build folder # the CMake script, its work dir gets set to the build folder
SET(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in) set(VERSION_INPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.in)
SET(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out) set(VERSION_OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/Version.h.out)
ADD_CUSTOM_TARGET( add_custom_target(
GenerateVersion ALL GenerateVersion ALL
# This BYPRODUCTS line is required for this to be ran every time # This BYPRODUCTS line is required for this to be ran every time
BYPRODUCTS ${VERSION_OUTPUT_FILE} BYPRODUCTS ${VERSION_OUTPUT_FILE}
@ -194,87 +194,87 @@ IF(NOT OFFICIAL_BUILD)
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
) )
ADD_DEPENDENCIES(VVVVVV GenerateVersion) add_dependencies(VVVVVV GenerateVersion)
# This lets Version.h know that Version.h.out exists # This lets Version.h know that Version.h.out exists
ADD_DEFINITIONS(-DVERSION_H_OUT_EXISTS) add_definitions(-DVERSION_H_OUT_EXISTS)
ENDIF() endif()
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 -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>> -Wall -Wpedantic $<$<BOOL:${ENABLE_WERROR}>:-Werror>>
$<$<CXX_COMPILER_ID:MSVC>: $<$<CXX_COMPILER_ID:MSVC>:
/W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>) /W4 $<$<BOOL:${ENABLE_WERROR}>:/WX>>)
ENDIF() endif()
IF(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR") if(CUSTOM_LEVEL_SUPPORT STREQUAL "NO_EDITOR")
ADD_DEFINITIONS(-DNO_EDITOR) add_definitions(-DNO_EDITOR)
ELSEIF(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED") elseif(CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
ADD_DEFINITIONS(-DNO_CUSTOM_LEVELS -DNO_EDITOR) add_definitions(-DNO_CUSTOM_LEVELS -DNO_EDITOR)
ENDIF() endif()
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(SUPPORTS_IMPLICIT_FALLTHROUGH 1) set(SUPPORTS_IMPLICIT_FALLTHROUGH 1)
ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
IF(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
SET(SUPPORTS_IMPLICIT_FALLTHROUGH 1) set(SUPPORTS_IMPLICIT_FALLTHROUGH 1)
ELSE() else()
SET(SUPPORTS_IMPLICIT_FALLTHROUGH 0) set(SUPPORTS_IMPLICIT_FALLTHROUGH 0)
ENDIF() endif()
ELSE() else()
SET(SUPPORTS_IMPLICIT_FALLTHROUGH 0) set(SUPPORTS_IMPLICIT_FALLTHROUGH 0)
ENDIF() endif()
IF(SUPPORTS_IMPLICIT_FALLTHROUGH) if(SUPPORTS_IMPLICIT_FALLTHROUGH)
TARGET_COMPILE_OPTIONS(VVVVVV PRIVATE -Werror=implicit-fallthrough) target_compile_options(VVVVVV PRIVATE -Werror=implicit-fallthrough)
ENDIF() endif()
IF(MSVC) if(MSVC)
# Disable MSVC warnings about implicit conversion # Disable MSVC warnings about implicit conversion
TARGET_COMPILE_OPTIONS(VVVVVV PRIVATE /wd4244) target_compile_options(VVVVVV PRIVATE /wd4244)
ENDIF() endif()
SET_PROPERTY(TARGET VVVVVV PROPERTY CXX_STANDARD 98) set_property(TARGET VVVVVV PROPERTY CXX_STANDARD 98)
SET_PROPERTY(TARGET VVVVVV PROPERTY CXX_EXTENSIONS FALSE) set_property(TARGET VVVVVV PROPERTY CXX_EXTENSIONS FALSE)
# Unfortunately, it doesn't seem like distros package LodePNG # Unfortunately, it doesn't seem like distros package LodePNG
ADD_LIBRARY(lodepng-static STATIC ${PNG_SRC}) add_library(lodepng-static STATIC ${PNG_SRC})
TARGET_COMPILE_DEFINITIONS(lodepng-static PRIVATE target_compile_definitions(lodepng-static PRIVATE
-DLODEPNG_NO_COMPILE_ALLOCATORS -DLODEPNG_NO_COMPILE_ALLOCATORS
-DLODEPNG_NO_COMPILE_DISK -DLODEPNG_NO_COMPILE_DISK
-DLODEPNG_NO_COMPILE_ENCODER -DLODEPNG_NO_COMPILE_ENCODER
) )
IF(BUNDLE_DEPENDENCIES) if(BUNDLE_DEPENDENCIES)
ADD_LIBRARY(tinyxml2-static STATIC ${XML2_SRC}) add_library(tinyxml2-static STATIC ${XML2_SRC})
ADD_LIBRARY(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC}) add_library(physfs-static STATIC ${PFS_SRC} ${PFSP_SRC})
TARGET_LINK_LIBRARIES(VVVVVV physfs-static tinyxml2-static lodepng-static) target_link_libraries(VVVVVV physfs-static tinyxml2-static lodepng-static)
ELSE() else()
FIND_PACKAGE(utf8cpp CONFIG) find_package(utf8cpp CONFIG)
TARGET_LINK_LIBRARIES(VVVVVV physfs tinyxml2 utf8cpp lodepng-static) target_link_libraries(VVVVVV physfs tinyxml2 utf8cpp lodepng-static)
ENDIF() endif()
# 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 SYSTEM PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS}>") target_include_directories(VVVVVV SYSTEM 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()
@ -286,14 +286,14 @@ else()
endif() endif()
# Yes, more Apple Crap # Yes, more Apple Crap
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()
# But hey, also some Haiku crap # But hey, also some Haiku crap
IF(HAIKU) if(HAIKU)
FIND_LIBRARY(BE_LIBRARY be) find_library(BE_LIBRARY be)
FIND_LIBRARY(ROOT_LIBRARY root) find_library(ROOT_LIBRARY root)
TARGET_LINK_LIBRARIES(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY}) target_link_libraries(VVVVVV ${BE_LIBRARY} ${ROOT_LIBRARY})
ENDIF() endif()