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

Don't pollute global includes/defines namespace

A function like add_definitions() adds definitions to ALL targets, not
just VVVVVV. This kind of namespace pollution is messy, and could result
in bugs if you pollute with the right kind of pollutant.

So instead of using add_definitions(), use target_compile_definitions().
And instead of using include_directories(), use
target_include_directories().
This commit is contained in:
Misa 2021-04-16 19:09:59 -07:00 committed by Ethan Lee
parent 78aa3ca715
commit afae945930

View file

@ -24,10 +24,6 @@ if(OFFICIAL_BUILD AND NOT MAKEANDPLAY)
set(GOG ON) set(GOG ON)
endif() endif()
if(MAKEANDPLAY)
add_definitions(-DMAKEANDPLAY)
endif()
if(${CMAKE_VERSION} VERSION_LESS "3.1.3") if(${CMAKE_VERSION} VERSION_LESS "3.1.3")
message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!") message(WARNING "Your CMake version is too old; set -std=c90 -std=c++98 yourself!")
else() else()
@ -60,9 +56,6 @@ if(APPLE)
message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}") message(STATUS "Using macOS SDK at ${CMAKE_OSX_SYSROOT}")
endif() endif()
# Compiler Flags
add_definitions(-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1)
# RPATH # RPATH
if(NOT WIN32) if(NOT WIN32)
if(APPLE) if(APPLE)
@ -81,22 +74,6 @@ if(NOT WIN32)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif() endif()
# Include Directories
if(BUNDLE_DEPENDENCIES)
include_directories(
src
../third_party/tinyxml2
../third_party/physfs
../third_party/lodepng
../third_party/utfcpp/source
)
else()
include_directories(
src
../third_party/lodepng
)
endif()
# Source Lists # Source Lists
set(VVV_SRC set(VVV_SRC
src/BinaryBlob.cpp src/BinaryBlob.cpp
@ -140,11 +117,45 @@ if(NOT CUSTOM_LEVEL_SUPPORT STREQUAL "DISABLED")
endif() endif()
if(STEAM) if(STEAM)
list(APPEND VVV_SRC src/SteamNetwork.c) list(APPEND VVV_SRC src/SteamNetwork.c)
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) endif()
# Executable information
if(WIN32)
add_executable(VVVVVV WIN32 ${VVV_SRC})
else()
add_executable(VVVVVV ${VVV_SRC})
endif()
# Include Directories
if(BUNDLE_DEPENDENCIES)
target_include_directories(
VVVVVV PRIVATE
src
../third_party/tinyxml2
../third_party/physfs
../third_party/lodepng
../third_party/utfcpp/source
)
else()
target_include_directories(
VVVVVV PRIVATE
src
../third_party/lodepng
)
endif()
if(MAKEANDPLAY)
target_compile_definitions(VVVVVV PRIVATE -DMAKEANDPLAY)
endif()
if(STEAM)
target_compile_definitions(VVVVVV PRIVATE -DSTEAM_NETWORK)
endif()
if(GOG)
target_compile_definitions(VVVVVV PRIVATE -DGOG_NETWORK)
endif() endif()
set(XML2_SRC set(XML2_SRC
@ -168,13 +179,6 @@ if(APPLE)
endif() endif()
set(PNG_SRC ../third_party/lodepng/lodepng.c) set(PNG_SRC ../third_party/lodepng/lodepng.c)
# Executable information
if(WIN32)
add_executable(VVVVVV WIN32 ${VVV_SRC})
else()
add_executable(VVVVVV ${VVV_SRC})
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
@ -258,6 +262,9 @@ target_compile_definitions(lodepng-static PRIVATE
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_compile_definitions(physfs-static PRIVATE
-DPHYSFS_SUPPORTS_DEFAULT=0 -DPHYSFS_SUPPORTS_ZIP=1
)
# PhysFS needs some extensions... # PhysFS needs some extensions...
if(${CMAKE_VERSION} VERSION_GREATER "3.1.3" if(${CMAKE_VERSION} VERSION_GREATER "3.1.3"