From 5ffd23050e51a152bffe56c407dbee0c66acb625 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Sun, 23 Nov 2025 03:30:09 -0500 Subject: [PATCH] Fixes c++26 issues and cleans up feature messages --- modules/features/c++26.cmake | 10 +++++++--- modules/features/reflection.cmake | 4 ++-- modules/helpers.cmake | 32 +++++++++++++++---------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/modules/features/c++26.cmake b/modules/features/c++26.cmake index e7bf61c..660bc88 100644 --- a/modules/features/c++26.cmake +++ b/modules/features/c++26.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.26) - include(CheckCXXSourceCompiles) # Test actual compilation of C++26 code @@ -10,4 +8,10 @@ struct A { }; int main() { A a,b; return (a <=> b) == 0 ? 0 : 1; } " HAS_CXX26) -set(CMAKE_REQUIRED_FLAGS "") # reset \ No newline at end of file +set(CMAKE_REQUIRED_FLAGS "") # reset + +if (HAS_CXX26) + message("-- C++26: ON") +else () + message("-- C++26: OFF") +endif () \ No newline at end of file diff --git a/modules/features/reflection.cmake b/modules/features/reflection.cmake index ed0b3a9..d9b93f1 100644 --- a/modules/features/reflection.cmake +++ b/modules/features/reflection.cmake @@ -8,7 +8,7 @@ try_compile(HAS_CPP_REFLECTION ) if (HAS_CPP_REFLECTION) - message(STATUS "Compiler supports C++ reflection") + message(STATUS "C++26 Reflection: ON") else () - message(STATUS "Compiler does NOT support C++ reflection") + message(STATUS "C++26 Reflection: OFF") endif () \ No newline at end of file diff --git a/modules/helpers.cmake b/modules/helpers.cmake index 16ec247..4407072 100644 --- a/modules/helpers.cmake +++ b/modules/helpers.cmake @@ -23,9 +23,11 @@ function(ConfigureFGLTarget NAME SRC_DIR INCLUDE_DIR) target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1") endif () - if (HAS_CXX26) + if (CMAKE_CXX_STANDARD STREQUAL 26) + message("Setting target ${NAME} to c++26") target_compile_features(${NAME} PUBLIC cxx_std_26) else () + message("Setting target ${NAME} to c++23") target_compile_features(${NAME} PUBLIC cxx_std_23) endif () endfunction() @@ -42,16 +44,13 @@ function(SplitDebugSymbols NAME) endfunction() function(AddFGLExecutable NAME SRC_SOURCES_LOCATION) - file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS - ${SRC_SOURCES_LOCATION}/**.cpp - ${SRC_SOURCES_LOCATION}/**.hpp - ) + file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp) + file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp) - file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS - ${SRC_SOURCES_LOCATION}/**.ui) + file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.ui) - add_executable(${NAME} ${SOURCES}) - target_sources(${NAME} PUBLIC ${SOURCES}) + add_executable(${NAME}) + target_sources(${NAME} PRIVATE ${CPP_SOURCES}) ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} "") @@ -67,16 +66,13 @@ function(AddFGLExecutable NAME SRC_SOURCES_LOCATION) endfunction() function(AddFGLLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION) - - file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS - ${SRC_SOURCES_LOCATION}/**.cpp - ${SRC_SOURCES_LOCATION}/**.hpp - ) + file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp) + file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp) file(GLOB_RECURSE INCLUDE_HPP_SOURCES CONFIGURE_DEPENDS ${INCLUDE_SOURCES_LOCATION}/**.hpp) add_library(${NAME} ${MODE}) - target_sources(${NAME} PRIVATE ${SOURCES}) + target_sources(${NAME} PRIVATE ${CPP_SOURCES} ${HPP_SOURCES}) ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} ${INCLUDE_SOURCES_LOCATION}) @@ -98,12 +94,14 @@ function(AddFGLModule NAME SRC_SOURCES_LOCATION) AddGitInfo(${NAME}) target_compile_definitions(${NAME} PRIVATE FGL_BUILD_TYPE="${CMAKE_BUILD_TYPE}") + ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} "") + SplitDebugSymbols(${NAME}) endfunction() function(AddFGLChildLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION) - file(GLOB_RECURSE CPP_SOURCES ${SRC_SOURCES_LOCATION}/**.cpp) - file(GLOB_RECURSE HPP_SOURCES ${SRC_SOURCES_LOCATION}/**.hpp) + file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp) + file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp) file(GLOB_RECURSE INCLUDE_HPP_SOURCES ${INCLUDE_SOURCES_LOCATION}/**.hpp) add_library(${NAME} ${MODE} ${CPP_SOURCES} ${HPP_SOURCES} ${INCLUDE_SOURCES_LOCATION}) target_include_directories(${NAME} PUBLIC ${INCLUDE_SOURCES_LOCATION})