2026-02-20 16:18:16 +08:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
|
|
|
|
|
|
|
|
|
project(EzUI)
|
|
|
|
|
|
|
|
|
|
# Set C++ standard
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
|
|
# Set available configurations
|
|
|
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
|
|
|
|
|
|
|
|
|
|
# Output directory for libraries - directly to lib/
|
|
|
|
|
# Use per-configuration output directories for Visual Studio generators
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/lib)
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/lib)
|
|
|
|
|
|
|
|
|
|
# Include directories - sources use #include "Control.h" style
|
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/include/EzUI)
|
|
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
|
file(GLOB SOURCES
|
|
|
|
|
${CMAKE_SOURCE_DIR}/sources/*.cpp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Create static library
|
|
|
|
|
add_library(EzUI STATIC ${SOURCES})
|
|
|
|
|
|
|
|
|
|
# Preprocessor definition for static library
|
|
|
|
|
target_compile_definitions(EzUI PRIVATE EZUI_STATIC)
|
|
|
|
|
|
|
|
|
|
# Additional system libraries required
|
|
|
|
|
target_link_libraries(EzUI PRIVATE
|
|
|
|
|
gdiplus.lib
|
|
|
|
|
dwrite.lib
|
|
|
|
|
d2d1.lib
|
|
|
|
|
Windowscodecs.lib
|
|
|
|
|
shlwapi.lib
|
|
|
|
|
imm32.lib
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Windows-specific settings
|
|
|
|
|
add_definitions(-D_UNICODE)
|
|
|
|
|
add_definitions(-DUNICODE)
|
|
|
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
|
|
|
|
|
2026-02-20 16:29:32 +08:00
|
|
|
# Force UTF-8 encoding for source files to avoid encoding issues
|
|
|
|
|
# when editing in VSCode and building in VS2022
|
|
|
|
|
add_compile_options(/utf-8)
|
|
|
|
|
|
2026-02-20 16:18:16 +08:00
|
|
|
# Set runtime library: MTD for Debug, MT for Release
|
|
|
|
|
# This ensures static linking to the C/C++ runtime
|
|
|
|
|
set_target_properties(EzUI PROPERTIES
|
|
|
|
|
# Debug: MultiThreadedDebug (MTD)
|
|
|
|
|
# Release: MultiThreaded (MT)
|
|
|
|
|
DEBUG_POSTFIX ""
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Set output name based on configuration and platform
|
|
|
|
|
# Debug|Win32 -> EzUI_Debug_Win32.lib
|
|
|
|
|
# Debug|x64 -> EzUI_Debug_x64.lib
|
|
|
|
|
# Release|Win32 -> EzUI_Release_Win32.lib
|
|
|
|
|
# Release|x64 -> EzUI_Release_x64.lib
|
|
|
|
|
set_target_properties(EzUI PROPERTIES
|
|
|
|
|
OUTPUT_NAME_DEBUG "EzUI_Debug_$(Platform)"
|
|
|
|
|
OUTPUT_NAME_RELEASE "EzUI_Release_$(Platform)"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Explicitly set runtime library per configuration
|
|
|
|
|
# Debug: MTD (MultiThreadedDebug) - static
|
|
|
|
|
# Release: MT (MultiThreaded) - static
|
|
|
|
|
target_compile_options(EzUI PRIVATE
|
|
|
|
|
$<$<CONFIG:Debug>:/MTd>
|
|
|
|
|
$<$<CONFIG:Release>:/MT>
|
|
|
|
|
)
|