build system: add ability to specifiy config file

This commit is contained in:
veclav talica 2022-06-23 08:31:05 +05:00
parent d7a0b46006
commit 6d323aa485
10 changed files with 51 additions and 22 deletions

View File

@ -26,6 +26,7 @@ endif()
option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF) option(INCLUDE_EVERYTHING "Include everything disabled by default (for CI usage" OFF)
set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option") set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \${OFF} to have it covered by this option")
set(EXTERNAL_CONFIG_FILE "" CACHE STRING "Change default config.h by config file at path")
# raylib modules included # raylib modules included
cmake_dependent_option(SUPPORT_MODULE_RSHAPES "Include module: rshapes" ON CUSTOMIZE_BUILD ON) cmake_dependent_option(SUPPORT_MODULE_RSHAPES "Include module: rshapes" ON CUSTOMIZE_BUILD ON)

View File

@ -9,6 +9,11 @@ function(define_if target variable)
endif () endif ()
endfunction() endfunction()
if (NOT ${EXTERNAL_CONFIG_FILE} STREQUAL "")
message(STATUS "Config file: ${EXTERNAL_CONFIG_FILE}")
target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FILE=<${EXTERNAL_CONFIG_FILE}>)
endif ()
if (${CUSTOMIZE_BUILD}) if (${CUSTOMIZE_BUILD})
target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS) target_compile_definitions("raylib" PUBLIC EXTERNAL_CONFIG_FLAGS)
define_if("raylib" USE_AUDIO) define_if("raylib" USE_AUDIO)

View File

@ -72,6 +72,10 @@ RAYLIB_RES_FILE ?= ./raylib.dll.rc.data
# if NONE, default config.h flags are used # if NONE, default config.h flags are used
RAYLIB_CONFIG_FLAGS ?= NONE RAYLIB_CONFIG_FLAGS ?= NONE
# Define external config file
# NOTE: Will load supplied fine instead of default ./config.h
RAYLIB_CONFIG_FILE ?= NONE
# To define additional cflags: Use make CUSTOM_CFLAGS="" # To define additional cflags: Use make CUSTOM_CFLAGS=""
# Include raylib modules on compilation # Include raylib modules on compilation
@ -312,7 +316,12 @@ endif
CFLAGS = -Wall -D_DEFAULT_SOURCE -D$(PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing $(CUSTOM_CFLAGS) CFLAGS = -Wall -D_DEFAULT_SOURCE -D$(PLATFORM) -D$(GRAPHICS) -Wno-missing-braces -Werror=pointer-arith -fno-strict-aliasing $(CUSTOM_CFLAGS)
ifneq ($(RAYLIB_CONFIG_FLAGS),NONE) ifneq ($(RAYLIB_CONFIG_FLAGS),NONE)
CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS) CFLAGS += -DEXTERNAL_CONFIG_FLAGS=$(RAYLIB_CONFIG_FLAGS)
endif
ifneq ($(RAYLIB_CONFIG_FILE),NONE)
$(warning $(RAYLIB_CONFIG_FILE))
CFLAGS += -DEXTERNAL_CONFIG_FILE="<$(RAYLIB_CONFIG_FILE)>"
endif endif
ifeq ($(PLATFORM),PLATFORM_WEB) ifeq ($(PLATFORM),PLATFORM_WEB)

View File

@ -75,8 +75,10 @@
#else #else
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#include "utils.h" // Required for: fopen() Android mapping #include "utils.h" // Required for: fopen() Android mapping
#endif #endif

View File

@ -115,8 +115,10 @@
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#include "utils.h" // Required for: TRACELOG() macros #include "utils.h" // Required for: TRACELOG() macros

View File

@ -43,8 +43,10 @@
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#if defined(SUPPORT_MODULE_RMODELS) #if defined(SUPPORT_MODULE_RMODELS)

View File

@ -48,8 +48,10 @@
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#if defined(SUPPORT_MODULE_RSHAPES) #if defined(SUPPORT_MODULE_RSHAPES)

View File

@ -52,8 +52,10 @@
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#if defined(SUPPORT_MODULE_RTEXT) #if defined(SUPPORT_MODULE_RTEXT)

View File

@ -64,8 +64,10 @@
#include "raylib.h" // Declares module functions #include "raylib.h" // Declares module functions
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#if defined(SUPPORT_MODULE_RTEXTURES) #if defined(SUPPORT_MODULE_RTEXTURES)

View File

@ -33,8 +33,10 @@
#include "raylib.h" // WARNING: Required for: LogType enum #include "raylib.h" // WARNING: Required for: LogType enum
// Check if config flags have been externally provided on compilation line // Check if config flags have been externally provided on compilation line
#if !defined(EXTERNAL_CONFIG_FLAGS) #if !defined(EXTERNAL_CONFIG_FLAGS) && !defined(EXTERNAL_CONFIG_FILE)
#include "config.h" // Defines module configuration flags #include "config.h" // Defines module configuration flags
#elif defined(EXTERNAL_CONFIG_FILE)
#include EXTERNAL_CONFIG_FILE // Defines module configuration flags in macro specified path
#endif #endif
#include "utils.h" #include "utils.h"