CMake configuration rework!
This commit is contained in:
parent
e6ce91f264
commit
527cb1a9d1
|
|
@ -1,6 +1,34 @@
|
||||||
cmake_minimum_required(VERSION 3.28.3)
|
cmake_minimum_required(VERSION 3.28.3)
|
||||||
project(oneshot)
|
project(oneshot)
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(CheckCCompilerFlag)
|
||||||
|
message(STATUS "CXX compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
|
||||||
|
# Helper for checking if options supported
|
||||||
|
function(check_option var a)
|
||||||
|
set(all ${a})
|
||||||
|
set(var "")
|
||||||
|
list(APPEND all ${ARGN})
|
||||||
|
|
||||||
|
foreach(x IN LISTS all)
|
||||||
|
check_cxx_compiler_flag(${x} HAVE_OPTION)
|
||||||
|
if(HAVE_OPTION)
|
||||||
|
message(STATUS "${x} SUPPORTED")
|
||||||
|
list(APPEND var ${x})
|
||||||
|
else()
|
||||||
|
check_c_compiler_flag(${x} HAVE_OPTION_C)
|
||||||
|
if(HAVE_OPTION_C)
|
||||||
|
message(STATUS "${x} SUPPORTED")
|
||||||
|
list(APPEND var ${x})
|
||||||
|
else()
|
||||||
|
message(STATUS "${x} UNSUPPORTED")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
|
set(${var} "${var}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option(STEAM "Build for Steam" OFF)
|
option(STEAM "Build for Steam" OFF)
|
||||||
|
|
@ -14,20 +42,19 @@ option(DEVBUILD "Developoment build" OFF)
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD TRUE)
|
||||||
set(VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION "5.1.2600.0")
|
|
||||||
set(STEAMWORKS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/steamworks" CACHE PATH "Path to Steamworks folder")
|
set(STEAMWORKS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/steamworks" CACHE PATH "Path to Steamworks folder")
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
#disable niuse bullshit
|
|
||||||
add_compile_options(-Wno-unused-parameter)
|
add_compile_options(-Wno-unused-parameter)
|
||||||
|
|
||||||
|
# Make build more static
|
||||||
if(STATIC)
|
if(STATIC)
|
||||||
add_compile_options(-static-libgcc -static-libstdc++)
|
check_option(OPTIONS_STATIC -static-libgcc -static-libstdc++)
|
||||||
|
add_compile_options(${OPTIONS_STATIC})
|
||||||
set(ZLIB_USE_STATIC_LIBS ON)
|
set(ZLIB_USE_STATIC_LIBS ON)
|
||||||
set(OPENSSL_USE_STATIC_LIBS ON)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Use OpenGL ES2
|
||||||
if(USE_OPENGL_ES2)
|
if(USE_OPENGL_ES2)
|
||||||
add_definitions(-DGLES2_HEADER)
|
add_definitions(-DGLES2_HEADER)
|
||||||
endif()
|
endif()
|
||||||
|
|
@ -149,7 +176,7 @@ set(MAIN_SOURCE
|
||||||
src/sound/audiosource.cpp
|
src/sound/audiosource.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Platform specific bullshit
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
list(APPEND MAIN_SOURCE assets/resources.rc)
|
list(APPEND MAIN_SOURCE assets/resources.rc)
|
||||||
list(APPEND DEFINES UNICODE)
|
list(APPEND DEFINES UNICODE)
|
||||||
|
|
@ -182,7 +209,6 @@ elseif(APPLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS})
|
||||||
|
|
||||||
set(EMBEDDED_INPUT
|
set(EMBEDDED_INPUT
|
||||||
shader/common.h
|
shader/common.h
|
||||||
shader/transSimple.frag
|
shader/transSimple.frag
|
||||||
|
|
@ -297,23 +323,35 @@ set(BINDING_SOURCE
|
||||||
|
|
||||||
source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
|
source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
|
||||||
if(NATIVE)
|
if(NATIVE)
|
||||||
add_compile_options(-march=native
|
check_option(OPTIONS_NATIVE -march=native -mtune=native)
|
||||||
-mtune=native)
|
add_compile_options(${OPTIONS_NATIVE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Common arguments on specific CPU arch
|
||||||
|
if("${ARCH_COMMON}" STREQUAL "")
|
||||||
|
message(STATUS "ARCH_COMMON empty")
|
||||||
|
else()
|
||||||
|
check_option(ARCH_COMMON_OPTIONS ${ARCH_COMMON})
|
||||||
|
add_compile_options(${ARCH_COMMON_OPTIONS})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(SANITIZERS)
|
if(SANITIZERS)
|
||||||
# ASan + Ruby = SEGFAULT
|
# ASan + Ruby = SEGFAULT
|
||||||
set(SANITIZERS "undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare")
|
set(SANITIZERS "undefined,leak,shift,shift-base,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin,pointer-subtract,pointer-compare")
|
||||||
add_compile_options(-fsanitize=${SANITIZERS})
|
check_option(SANITIZERS_OPTIONS -fsanitize=${SANITIZERS})
|
||||||
add_link_options(-fsanitize=${SANITIZERS})
|
add_compile_options(${SANITIZERS_OPTIONS})
|
||||||
|
add_link_options(${SANITIZERS_OPTIONS})
|
||||||
endif()
|
endif()
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
add_compile_options(
|
check_option(OPTIONS_DEBUG
|
||||||
-g3
|
-g3
|
||||||
-fno-omit-frame-pointer
|
-fno-omit-frame-pointer
|
||||||
-Og)
|
-Og)
|
||||||
|
add_compile_options(${OPTIONS_DEBUG})
|
||||||
|
check_option(ARCH_DEBUG_OPTIONS ${ARCH_DEBUG})
|
||||||
|
add_compile_options(${ARCH_DEBUG_OPTIONS})
|
||||||
else()
|
else()
|
||||||
add_compile_options(
|
check_option(OPTIONS_RELEASE -O2
|
||||||
-O2
|
|
||||||
-ffast-math
|
-ffast-math
|
||||||
-fipa-pta
|
-fipa-pta
|
||||||
-ftree-vectorize
|
-ftree-vectorize
|
||||||
|
|
@ -323,6 +361,7 @@ else()
|
||||||
-ffunction-sections
|
-ffunction-sections
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
-fvisibility=hidden)
|
-fvisibility=hidden)
|
||||||
|
add_compile_options(${OPTIONS_RELEASE})
|
||||||
|
|
||||||
add_link_options(-Wl,-O2
|
add_link_options(-Wl,-O2
|
||||||
-Wl,--gc-sections
|
-Wl,--gc-sections
|
||||||
|
|
@ -331,13 +370,12 @@ else()
|
||||||
-Wl,--strip-all
|
-Wl,--strip-all
|
||||||
-Wl,--no-copy-dt-needed-entries)
|
-Wl,--no-copy-dt-needed-entries)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
add_compile_options(-flto)
|
check_option(OPTIONS_RELEASE_WIN32_FLTO -flto)
|
||||||
add_link_options(-flto)
|
add_compile_options(${OPTIONS_RELEASE_WIN32_FLTO})
|
||||||
endif()
|
add_link_options(${OPTIONS_RELEASE_WIN32_FLTO})
|
||||||
|
|
||||||
if(LINUX)
|
|
||||||
add_compile_options(-fno-plt)
|
|
||||||
endif()
|
endif()
|
||||||
|
check_option(ARCH_RELEASE_OPTIONS ${ARCH_RELEASE})
|
||||||
|
add_compile_options(${ARCH_RELEASE_OPTIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
|
|
||||||
20
README.md
20
README.md
|
|
@ -1,16 +1,10 @@
|
||||||
# mkxp-sunshine
|
# Sunshine Engine
|
||||||
This is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) designed for OneShot: Sunshine mod.
|
It is a specialized fork of [mkxp-oneshot](https://github.com/elizagamedev/mkxp-oneshot) developed for the OneShot: Sunshine mod, aimed at optimization, running on old and new hardware, support for multiple platforms, and mod download security.
|
||||||
Target of sunshine mod - improve original game.
|
|
||||||
|
|
||||||
## xScripts.rxdata
|
|
||||||
|
|
||||||
./rpgscript.rb scripts/ [GameDir]
|
|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
1. Install required packages
|
1. Install required packages
|
||||||
* Cmake
|
* Cmake
|
||||||
* C/C++ compiler, GCC 14+ or MinGW
|
* C/C++ compiler, GCC 14, MinGW, Clang and maybe MSVC
|
||||||
* xxd
|
* xxd
|
||||||
* Ruby 3.4+
|
* Ruby 3.4+
|
||||||
* Boost
|
* Boost
|
||||||
|
|
@ -28,9 +22,5 @@ Target of sunshine mod - improve original game.
|
||||||
(*NIX - Linux,FreeBSD and other UNIX and UNIX-like systems.)
|
(*NIX - Linux,FreeBSD and other UNIX and UNIX-like systems.)
|
||||||
|
|
||||||
2. build
|
2. build
|
||||||
* In project dir create build dir
|
Use build scripts.
|
||||||
* cmake . -B build -DDEBUG=(ON/OFF) -DCMAKE_TOOLCHAIN_FILE=toolchain/arch/(x86/arm64/ia-64).cmake
|
make-oneshot-(OS).sh -DCMAKE_TOOLCHAIN_FILE=toolchain/arch/(x86/arm/ia-64).cmake
|
||||||
* cd build
|
|
||||||
* make -jn (n - count of threads for compilation)
|
|
||||||
|
|
||||||
also you can use build scripts like make-oneshot-linux.sh
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
set(CUSTOM_FLAGS
|
set(ARCH_COMMON "")
|
||||||
|
set(ARCH_RELEASE
|
||||||
-mnoreturn-no-callee-saved-registers
|
-mnoreturn-no-callee-saved-registers
|
||||||
-mrelax-cmpxchg-loop
|
-mrelax-cmpxchg-loop
|
||||||
-momit-leaf-frame-pointer
|
-momit-leaf-frame-pointer)
|
||||||
)
|
set(ARCH_DEBUG "")
|
||||||
|
|
||||||
string(JOIN " " CUSTOM_FLAGS_STR ${CUSTOM_FLAGS})
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CUSTOM_FLAGS_STR}")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CUSTOM_FLAGS_STR}")
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue