add_library(${ENGINE_TARGET} STATIC src/IO/parser.cpp src/IO/file_manager.cpp src/window/window.cpp src/components/batch.cpp src/renderer/debug.cpp src/renderer/mesh.cpp src/renderer/shader.cpp src/renderer/texture.cpp src/renderer/wavefront.cpp src/renderer/engine.cpp src/renderer/renderer.cpp src/main.cpp ) set_target_properties(${ENGINE_TARGET} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES ) target_include_directories(${ENGINE_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/contrib ) target_link_libraries(${ENGINE_TARGET} PUBLIC SDL3::SDL3 OpenGL::GL GLEW::GLEW glm::glm EnTT::EnTT ) if (MSVC) target_compile_options(${ENGINE_TARGET} PRIVATE $<$:/Zi>) target_link_options(${ENGINE_TARGET} PRIVATE $<$:/DEBUG:FULL>) else() target_compile_options(${ENGINE_TARGET} PRIVATE $<$:-ggdb>) endif() # Release flags if (MSVC) # /O2: optimize speed, /GL: whole program opt (LTCG), /DNDEBUG: disable asserts target_compile_options(${ENGINE_TARGET} PRIVATE $<$:/O2> $<$:/DNDEBUG> $<$:/O2> ) # Link-time codegen & extra linker opts for smaller/faster binaries target_link_options(${ENGINE_TARGET} PRIVATE $<$:/LTCG /OPT:ICF /OPT:REF> $<$:/LTCG /OPT:ICF /OPT:REF> ) else() # GCC/Clang # -O3 for max opts, -ffast-math optional but can be risky; we keep it OFF by default. option(CODINGGAME_USE_MARCH_NATIVE "Enable -march=native on Release for this machine" ON) target_compile_options(${ENGINE_TARGET} PRIVATE $<$:-O3> $<$,$>:-march=native> $<$:-DNDEBUG> $<$:-O3 -g> ) # Linker: enable LTO when available; optionally strip symbols on non-Apple include(CheckIPOSupported) # IPO == LTO in CMake terms check_ipo_supported(RESULT ipo_supported OUTPUT ipo_msg) if(ipo_supported) set_property(TARGET ${ENGINE_TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE) set_property(TARGET ${ENGINE_TARGET} PROPERTY INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE) endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) # -s strips symbols at link stage (use only for pure Release) target_link_options(${ENGINE_TARGET} PRIVATE $<$:-s>) endif() endif() # ---------- Windows: copy runtime DLLs ---------- if (WIN32) add_custom_command(TARGET ${ENGINE_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ COMMAND_EXPAND_LISTS) endif()