Compare commits

...

2 commits

Author SHA1 Message Date
155ced8410 Introduce PSEMEK_PLATFORM and PSEMEK_PLATFORM_XXX variables
All checks were successful
Run tests / Run tests (push) Successful in 7m38s
2026-07-05 14:01:41 +03:00
dd07244a40 Update auto-generated opengl loaders & use shader prelude in gfx effects 2026-07-05 13:36:59 +03:00
18 changed files with 142 additions and 114 deletions

View file

@ -8,6 +8,36 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
string(TOUPPER "${CMAKE_BUILD_TYPE}" PSEMEK_BUILD_TYPE)
set(_PSEMEK_ALL_PLATFORMS linux windows mac android web)
if(WIN32)
set(_PSEMEK_PLATFORM windows)
elseif(APPLE)
set(_PSEMEK_PLATFORM mac)
elseif(ANDROID)
set(_PSEMEK_PLATFORM android)
elseif(UNIX)
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(_PSEMEK_PLATFORM web)
else()
set(_PSEMEK_PLATFORM linux)
endif()
else()
message(WARNING "Failed to detect platform")
set(_PSEMEK_PLATFORM unknown)
endif()
set(PSEMEK_PLATFORM "${_PSEMEK_PLATFORM}" CACHE INTERNAL "Build platform (auto-detected)")
foreach(_PLATFORM IN LISTS _PSEMEK_ALL_PLATFORMS)
string(TOUPPER "${_PLATFORM}" _PLATFORM_UPPER)
set(_PLATFORM_ON OFF)
if("${_PLATFORM}" STREQUAL "${_PSEMEK_PLATFORM}")
set(_PLATFORM_ON ON)
endif()
set(PSEMEK_PLATFORM_${_PLATFORM_UPPER} "${_PLATFORM_ON}" CACHE INTERNAL "Build platform is ${_PLATFORM}")
endforeach()
set(PSEMEK_DEFINITIONS)
if(PSEMEK_BUILD_TYPE STREQUAL "DEBUG")
list(APPEND PSEMEK_DEFINITIONS "-DPSEMEK_DEBUG=1")

View file

@ -147,6 +147,10 @@ typedef unsigned short GLhalfNV;
typedef GLintptr GLvdpauSurfaceNV;
typedef void (GLVULKANPROCNV)(void);
#include <unordered_set>
#include <string>
#include <string_view>
namespace gl
{
@ -1865,14 +1869,13 @@ namespace gl
const char * api();
int major_version();
int minor_version();
std::unordered_set<std::string> const & extensions();
std::string_view shader_prelude();
bool has_extension(const char * name);
bool ext_ARB_compute_shader();
bool ext_ARB_shader_image_load_store();
bool ext_ARB_texture_filter_anisotropic();
const char * shader_prefix();
} // namespace sys
} // namespace gl

View file

@ -11,6 +11,8 @@
#include <stdio.h>
#elif defined(_WIN32)
#include <windows.h>
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
#include <EGL/egl.h>
#else
#include <GL/glx.h>
#endif
@ -77,6 +79,13 @@ namespace gl
return reinterpret_cast<void*>(GetProcAddress(image, reinterpret_cast<LPCSTR>(name)));
}
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
static void * get_proc_address(const char *func)
{
return reinterpret_cast<void *>(eglGetProcAddress(func));
}
#else // GLX
@ -1244,7 +1253,7 @@ namespace gl
return true;
}
static std::unordered_set<std::string> extensions;
static std::unordered_set<std::string> extensions_set;
bool initialize()
{
if (!load_core()) return false;
@ -1252,13 +1261,13 @@ namespace gl
GLint num_extensions;
internal::glGetIntegerv(0x821D, &num_extensions);
for (GLint i = 0; i < num_extensions; ++i)
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
if (extensions.count("GL_ARB_compute_shader") > 0)
if (extensions_set.count("GL_ARB_compute_shader") > 0)
ext_GL_ARB_compute_shader_loaded = load_ext_GL_ARB_compute_shader();
if (extensions.count("GL_ARB_shader_image_load_store") > 0)
if (extensions_set.count("GL_ARB_shader_image_load_store") > 0)
ext_GL_ARB_shader_image_load_store_loaded = load_ext_GL_ARB_shader_image_load_store();
if (extensions.count("GL_ARB_texture_filter_anisotropic") > 0)
if (extensions_set.count("GL_ARB_texture_filter_anisotropic") > 0)
ext_GL_ARB_texture_filter_anisotropic_loaded = load_ext_GL_ARB_texture_filter_anisotropic();
return true;
@ -1270,19 +1279,16 @@ namespace gl
int minor_version(){ return 3; }
bool has_extension(const char * name){ return extensions.contains(name); }
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
std::string_view shader_prelude(){ return R"(#version 330 core
)";
}
bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; }
bool ext_ARB_shader_image_load_store(){ return ext_GL_ARB_shader_image_load_store_loaded; }
bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; }
const char * shader_prefix()
{
return R"(#version 330 core
)";
}
} // namespace sys
} // namespace gl

View file

@ -147,6 +147,10 @@ typedef unsigned short GLhalfNV;
typedef GLintptr GLvdpauSurfaceNV;
typedef void (GLVULKANPROCNV)(void);
#include <unordered_set>
#include <string>
#include <string_view>
namespace gl
{
@ -1288,9 +1292,13 @@ namespace gl
// GL_EXT_texture_filter_anisotropic
constexpr GLenum TEXTURE_MAX_ANISOTROPY = 0x84FE;
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY = 0x84FF;
constexpr GLenum TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
// Manually added compatibility constants
constexpr GLenum TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT;
constexpr GLenum MAX_TEXTURE_MAX_ANISOTROPY = MAX_TEXTURE_MAX_ANISOTROPY_EXT;
namespace sys
{
@ -1299,12 +1307,11 @@ namespace gl
const char * api();
int major_version();
int minor_version();
std::unordered_set<std::string> const & extensions();
std::string_view shader_prelude();
bool has_extension(const char * name);
bool ext_EXT_texture_filter_anisotropic();
const char * shader_prefix();
} // namespace sys
} // namespace gl

View file

@ -11,9 +11,8 @@
#include <stdio.h>
#elif defined(_WIN32)
#include <windows.h>
#elif defined(__EMSCRIPTEN__)
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
#include <EGL/egl.h>
#include <GLES3/gl3.h>
#else
#include <GL/glx.h>
#endif
@ -80,14 +79,14 @@ namespace gl
return reinterpret_cast<void*>(GetProcAddress(image, reinterpret_cast<LPCSTR>(name)));
}
#elif defined(__EMSCRIPTEN__)
#elif defined(__ANDROID__) || defined(__EMSCRIPTEN__)
static void * get_proc_address(const char *func)
{
return reinterpret_cast<void *>(eglGetProcAddress(func));
}
#else // GLX
static void * get_proc_address(const char *func)
@ -868,7 +867,7 @@ namespace gl
return true;
}
static std::unordered_set<std::string> extensions;
static std::unordered_set<std::string> extensions_set;
bool initialize()
{
if (!load_core()) return false;
@ -876,9 +875,9 @@ namespace gl
GLint num_extensions;
internal::glGetIntegerv(0x821D, &num_extensions);
for (GLint i = 0; i < num_extensions; ++i)
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
if (extensions.count("GL_EXT_texture_filter_anisotropic") > 0)
if (extensions_set.count("GL_EXT_texture_filter_anisotropic") > 0)
ext_GL_EXT_texture_filter_anisotropic_loaded = load_ext_GL_EXT_texture_filter_anisotropic();
return true;
@ -890,22 +889,19 @@ namespace gl
int minor_version(){ return 0; }
bool has_extension(const char * name){ return extensions.contains(name); }
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
bool ext_EXT_texture_filter_anisotropic(){ return ext_GL_EXT_texture_filter_anisotropic_loaded; }
const char * shader_prefix()
{
return R"(#version 300 es
std::string_view shader_prelude(){ return R"(#version 300 es
precision highp int;
precision highp float;
precision highp sampler2D;
precision highp usampler2D;
)";
}
bool ext_EXT_texture_filter_anisotropic(){ return ext_GL_EXT_texture_filter_anisotropic_loaded; }
} // namespace sys
} // namespace gl

View file

@ -147,6 +147,10 @@ typedef unsigned short GLhalfNV;
typedef GLintptr GLvdpauSurfaceNV;
typedef void (GLVULKANPROCNV)(void);
#include <unordered_set>
#include <string>
#include <string_view>
namespace gl
{
@ -1949,17 +1953,14 @@ namespace gl
const char * api();
int major_version();
int minor_version();
std::unordered_set<std::string> const & extensions();
std::string_view shader_prelude();
bool has_extension(const char * name);
bool ext_ARB_compute_shader();
bool ext_ARB_shader_image_load_store();
bool ext_ARB_texture_filter_anisotropic();
const char * shader_prefix();
} // namespace sys
} // namespace gl
#define PSEMEK_GLES 1

View file

@ -1235,7 +1235,7 @@ namespace gl
return true;
}
static std::unordered_set<std::string> extensions;
static std::unordered_set<std::string> extensions_set;
bool initialize()
{
if (!load_core()) return false;
@ -1243,13 +1243,13 @@ namespace gl
GLint num_extensions;
internal::glGetIntegerv(0x821D, &num_extensions);
for (GLint i = 0; i < num_extensions; ++i)
extensions.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
extensions_set.insert(reinterpret_cast<const char *>(internal::glGetStringi(0x1F03, i)));
if (extensions.count("GL_ARB_compute_shader") > 0)
if (extensions_set.count("GL_ARB_compute_shader") > 0)
ext_GL_ARB_compute_shader_loaded = load_ext_GL_ARB_compute_shader();
if (extensions.count("GL_ARB_shader_image_load_store") > 0)
if (extensions_set.count("GL_ARB_shader_image_load_store") > 0)
ext_GL_ARB_shader_image_load_store_loaded = load_ext_GL_ARB_shader_image_load_store();
if (extensions.count("GL_ARB_texture_filter_anisotropic") > 0)
if (extensions_set.count("GL_ARB_texture_filter_anisotropic") > 0)
ext_GL_ARB_texture_filter_anisotropic_loaded = load_ext_GL_ARB_texture_filter_anisotropic();
return true;
@ -1261,24 +1261,21 @@ namespace gl
int minor_version(){ return 2; }
bool has_extension(const char * name){ return extensions.contains(name); }
std::unordered_set<std::string> const & extensions(){ return extensions_set; }
bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; }
bool ext_ARB_shader_image_load_store(){ return ext_GL_ARB_shader_image_load_store_loaded; }
bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; }
const char * shader_prefix()
{
return R"(#version 320 es
std::string_view shader_prelude(){ return R"(#version 320 es
precision highp int;
precision highp float;
precision highp sampler2D;
precision highp usampler2D;
)";
}
bool ext_ARB_compute_shader(){ return ext_GL_ARB_compute_shader_loaded; }
bool ext_ARB_shader_image_load_store(){ return ext_GL_ARB_shader_image_load_store_loaded; }
bool ext_ARB_texture_filter_anisotropic(){ return ext_GL_ARB_texture_filter_anisotropic_loaded; }
} // namespace sys
} // namespace gl

View file

@ -13,9 +13,10 @@
"loader_namespace": "sys",
"internal_namespace": "internal",
"internal_prefix": "",
"shader_prelude": true,
"undef": 4,
"strip": true,
"out_header": "gl.hpp",
"out_source": "gl.cpp",
"out_header": "api/gl33/include/psemek/gfx/gl.hpp",
"out_source": "api/gl33/source/gl.cpp",
"include": "<psemek/gfx/gl.hpp>"
}

View file

@ -1,6 +1,6 @@
{
"spec_file": "gl.xml",
"api": "gles2",
"api": "gles3",
"version": "3.0",
"profile": "core",
"extensions": [
@ -11,9 +11,10 @@
"loader_namespace": "sys",
"internal_namespace": "internal",
"internal_prefix": "",
"shader_prelude": true,
"undef": 4,
"strip": true,
"out_header": "gl.hpp",
"out_source": "gl.cpp",
"out_header": "api/gles30-emscripten/include/psemek/gfx/gl.hpp",
"out_source": "api/gles30-emscripten/source/gl.cpp",
"include": "<psemek/gfx/gl.hpp>"
}

View file

@ -1,6 +1,6 @@
{
"spec_file": "gl.xml",
"api": "gles2",
"api": "gles3",
"version": "3.2",
"profile": "core",
"extensions": [
@ -13,9 +13,10 @@
"loader_namespace": "sys",
"internal_namespace": "internal",
"internal_prefix": "",
"shader_prelude": true,
"undef": 4,
"strip": true,
"out_header": "gl.hpp",
"out_source": "gl.cpp",
"out_header": "api/gles32/include/psemek/gfx/gl.hpp",
"out_source": "api/gles32/source/gl.cpp",
"include": "<psemek/gfx/gl.hpp>"
}

View file

@ -60,8 +60,11 @@ namespace psemek::gfx
, part(part)
{}
#ifndef PSEMEK_GLES
using texture_view_1d = basic_texture_view<1, gl::TEXTURE_1D>;
using texture_view_1d_array = basic_texture_view<2, gl::TEXTURE_1D_ARRAY>;
#endif
using texture_view_2d = basic_texture_view<2, gl::TEXTURE_2D>;
using texture_view_2d_array = basic_texture_view<3, gl::TEXTURE_2D_ARRAY>;
using texture_view_3d = basic_texture_view<3, gl::TEXTURE_3D>;

View file

@ -1,6 +1,7 @@
#include <psemek/gfx/effect/blur.hpp>
#include <psemek/gfx/program.hpp>
#include <psemek/gfx/array.hpp>
#include <psemek/gfx/gl.hpp>
#include <psemek/util/to_string.hpp>
@ -12,8 +13,7 @@ namespace psemek::gfx
{
static char const blur_vs[] =
R"(#version 330
R"(
const vec4 vertices[6] = vec4[6](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4( 1.0, -1.0, 0.0, 1.0),
@ -34,8 +34,7 @@ void main()
)";
static char const blur_fs_template[] =
R"(#version 330
R"(
#define BLUR_SIZE @BLUR_SIZE@
#define BLUR_COEFFS_COUNT 2 * BLUR_SIZE + 1
@ -118,7 +117,7 @@ void main()
gfx::array array;
blur_impl(int size, float sigma, float gamma, bool horizontal)
: program(blur_vs, generate_blur_fs_source(size, sigma, horizontal))
: program(std::string(gl::sys::shader_prelude()) + blur_vs, std::string(gl::sys::shader_prelude()) + generate_blur_fs_source(size, sigma, horizontal))
{
program.bind();
program["u_texture"] = 0;

View file

@ -2,13 +2,13 @@
#include <psemek/gfx/program.hpp>
#include <psemek/gfx/array.hpp>
#include <psemek/gfx/error.hpp>
#include <psemek/gfx/gl.hpp>
namespace psemek::gfx
{
static char const fxaa_vs[] =
R"(#version 330
R"(
const vec4 vertices[6] = vec4[6](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4( 1.0, -1.0, 0.0, 1.0),
@ -34,8 +34,7 @@ void main()
// TODO: refactor
static char const fxaa_fs[] =
R"(#version 330
R"(
uniform sampler2D u_input;
uniform vec2 u_d;
@ -207,7 +206,7 @@ void main()
struct fxaa::impl
{
gfx::program program{fxaa_vs, fxaa_fs};
gfx::program program{std::string(gl::sys::shader_prelude()) + fxaa_vs, std::string(gl::sys::shader_prelude()) + fxaa_fs};
gfx::array array;
};

View file

@ -2,13 +2,13 @@
#include <psemek/gfx/program.hpp>
#include <psemek/gfx/array.hpp>
#include <psemek/gfx/error.hpp>
#include <psemek/gfx/gl.hpp>
namespace psemek::gfx
{
static char const gamma_vs[] =
R"(#version 330
R"(
const vec4 vertices[6] = vec4[6](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4( 1.0, -1.0, 0.0, 1.0),
@ -30,8 +30,7 @@ void main()
)";
static char const gamma_fs[] =
R"(#version 330
R"(
uniform float u_gamma;
uniform sampler2D u_input;
@ -49,7 +48,7 @@ void main()
struct gamma_correction::impl
{
gfx::program program{gamma_vs, gamma_fs};
gfx::program program{std::string(gl::sys::shader_prelude()) + gamma_vs, std::string(gl::sys::shader_prelude()) + gamma_fs};
gfx::array array;
};

View file

@ -1,6 +1,7 @@
#include <psemek/gfx/effect/overlay.hpp>
#include <psemek/gfx/program.hpp>
#include <psemek/gfx/array.hpp>
#include <psemek/gfx/gl.hpp>
#include <psemek/util/pimpl.hpp>
@ -8,8 +9,7 @@ namespace psemek::gfx
{
static char const overlay_vs[] =
R"(#version 330
R"(
const vec4 vertices[6] = vec4[6](
vec4(-1.0, -1.0, 0.0, 1.0),
vec4( 1.0, -1.0, 0.0, 1.0),
@ -30,8 +30,7 @@ void main()
)";
static char const overlay_fs[] =
R"(#version 330
R"(
uniform sampler2D u_texture;
in vec2 texcoord;
@ -46,7 +45,7 @@ void main()
struct overlay::impl
{
gfx::program program{overlay_vs, overlay_fs};
gfx::program program{std::string(gl::sys::shader_prelude()) + overlay_vs, std::string(gl::sys::shader_prelude()) + overlay_fs};
gfx::array array;
};

View file

@ -6,8 +6,8 @@ namespace psemek::gfx
std::optional<std::size_t> available_memory()
{
static bool const nvx = gl::sys::has_extension("GL_NVX_gpu_memory_info");
static bool const ati = gl::sys::has_extension("GL_ATI_meminfo");
static bool const nvx = gl::sys::extensions().contains("GL_NVX_gpu_memory_info");
static bool const ati = gl::sys::extensions().contains("GL_ATI_meminfo");
if (nvx)
{

View file

@ -107,7 +107,7 @@ void main()
namespace psemek::gfx
{
static std::string shader_prefix = gl::sys::shader_prefix();
static std::string shader_prefix = std::string{gl::sys::shader_prelude()};
struct painter::impl
{

View file

@ -3,26 +3,11 @@ set(PSEMEK_PACKAGE_OUTPUT_PATH "" CACHE STRING "Packaging output path")
set(PSEMEK_PACKAGE_VERSION_SUFFIX "" CACHE STRING "Packaging version suffix")
if(PSEMEK_PACKAGE_MODE)
if(WIN32)
set(PSEMEK_PACKAGE_SUFFIX_RAW windows)
elseif(APPLE)
set(PSEMEK_PACKAGE_SUFFIX_RAW mac)
elseif(ANDROID)
set(PSEMEK_PACKAGE_SUFFIX_RAW android)
elseif(UNIX)
if (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
set(PSEMEK_PACKAGE_SUFFIX_RAW web)
else()
set(PSEMEK_PACKAGE_SUFFIX_RAW linux)
endif()
else()
message(FATAL "Uknown system for packaging")
endif()
set(PSEMEK_PACKAGE_SUFFIX ${PSEMEK_PACKAGE_SUFFIX_RAW} CACHE INTERNAL "Packaging suffix" FORCE)
set(PSEMEK_PACKAGE_SUFFIX ${PSEMEK_PLATFORM} CACHE INTERNAL "Packaging suffix" FORCE)
set(PSEMEK_PACKAGE_LINK_FLAGS_RAW)
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
if(PSEMEK_PLATFORM_WEB)
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-sMIN_WEBGL_VERSION=2" "-sNO_DISABLE_EXCEPTION_CATCHING" "-sFULL_ES3")
list(APPEND PSEMEK_PACKAGE_LINK_FLAGS_RAW "-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$autoResumeAudioContext','$dynCall'")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
@ -41,7 +26,7 @@ function(psemek_package_output_path target outvar)
message(FATAL "psemek_package_output_path must only be called during packaging")
endif()
if(ANDROID)
if(PSEMEK_PLATFORM_ANDROID)
set(_PACKAGE_EXTENSION apk)
else()
set(_PACKAGE_EXTENSION zip)
@ -60,7 +45,7 @@ function(psemek_add_executable_impl target is_application)
target_link_libraries(${target} PUBLIC psemek)
if(${is_application})
if(ANDROID)
if(PSEMEK_PLATFORM_ANDROID)
target_link_libraries(${target} PUBLIC
"-Wl,--whole-archive $<TARGET_FILE:${PSEMEK_BACKEND_LIBRARY}> -Wl,--no-whole-archive"
${PSEMEK_BACKEND_LIBRARY})
@ -68,7 +53,7 @@ function(psemek_add_executable_impl target is_application)
target_link_libraries(${target} PUBLIC ${PSEMEK_BACKEND_LIBRARY})
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
if(PSEMEK_PLATFORM_WEB)
target_link_options(${target} PRIVATE
"--shell-file=${CMAKE_CURRENT_FUNCTION_LIST_DIR}/web/template.html"
)
@ -83,13 +68,13 @@ function(psemek_add_executable_impl target is_application)
target_compile_definitions(${target} PUBLIC "-DPSEMEK_PACKAGE_MODE")
if(UNIX AND (NOT APPLE))
if(PSEMEK_PLATFORM_LINUX)
set_target_properties(${target} PROPERTIES
BUILD_RPATH "."
)
endif()
if(UNIX AND (NOT APPLE) AND (NOT ANDROID) AND (NOT (CMAKE_SYSTEM_NAME STREQUAL Emscripten)))
if(PSEMEK_PLATFORM_LINUX)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND chrpath -r . $<TARGET_FILE:${target}>
)
@ -97,13 +82,13 @@ function(psemek_add_executable_impl target is_application)
psemek_package_output_path(${target} _OUTPUT_PATH)
if(NOT ANDROID)
if(NOT PSEMEK_PLATFORM_ANDROID)
get_filename_component(_OUTPUT_DIRECTORY "${_OUTPUT_PATH}" DIRECTORY)
set(_TARGET_FILE $<TARGET_FILE:${target}>)
set(_TARGET_RUNTIME)
if(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
if(PSEMEK_PLATFORM_WEB)
set(_TARGET_PARENT $<PATH:GET_PARENT_PATH,${_TARGET_FILE}>)
set(_TARGET_STEM $<PATH:GET_STEM,${_TARGET_FILE}>)
set(_TARGET_NOEXT "${_TARGET_PARENT}/${_TARGET_STEM}")
@ -126,6 +111,7 @@ function(psemek_add_executable_impl target is_application)
add_custom_command(TARGET ${target} POST_BUILD
COMMAND echo Packaging target ${target} into ${_OUTPUT_PATH}
COMMAND mkdir -pv "${_OUTPUT_DIRECTORY}"
COMMAND rm -f "${_OUTPUT_PATH}"
COMMAND zip -v "${_OUTPUT_PATH}" -j ${_COPY_FILES}
COMMAND echo Packaged target ${target} into ${_OUTPUT_PATH}
)
@ -204,7 +190,7 @@ function(psemek_add_library target)
endfunction()
function(psemek_add_winrc target path)
if(WIN32 AND (TARGET ${target}))
if(PSEMEK_PLATFORM_WINDOWS AND (TARGET ${target}))
get_target_property(OUT_DIR ${target} BINARY_DIR)
set(_IN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${path}")
@ -224,12 +210,12 @@ endfunction()
function(psemek_package_files target)
if(PSEMEK_PACKAGE_MODE)
if(PSEMEK_PACKAGE_TARGET)
if(ANDROID)
if(PSEMEK_PLATFORM_ANDROID)
add_custom_command(TARGET ${target} POST_BUILD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
COMMAND ${PSEMEK_COPY_FILES} ${ARGN}
)
elseif(CMAKE_SYSTEM_NAME STREQUAL Emscripten)
elseif(PSEMEK_PLATFORM_WEB)
foreach(_FILE IN LISTS ARGN)
target_link_options(${target} PRIVATE
"--preload-file=${CMAKE_CURRENT_LIST_DIR}/${_FILE}@/${_FILE}"