9 Commits

Author SHA1 Message Date
1e44655a66 fixes 2025-12-15 21:26:59 -05:00
KJ16609
e4953b64ff Merge pull request #2 from KJNeko/detached2
Fixes c++26 issues and cleans up feature messages
2025-11-23 03:31:10 -05:00
5ffd23050e Fixes c++26 issues and cleans up feature messages 2025-11-23 03:30:09 -05:00
6ab0444bd3 Merge remote-tracking branch 'origin/master' 2025-11-22 09:44:04 -05:00
9ade0feebd Fix incorrect cxx26 checking 2025-11-17 04:40:22 -05:00
e8bb87bb28 Adds missing include path to AddFGLLibrary 2025-07-07 08:10:08 -04:00
37280fb95c Remove debug messages from helper function 2025-07-01 00:17:27 -04:00
95aa4bc5d9 Add ${FGL_SHARED_FLAGS} to final flag configurations 2025-07-01 00:17:22 -04:00
4f09dda70a use CCache if it's present 2025-07-01 00:17:13 -04:00
5 changed files with 53 additions and 45 deletions

View File

@@ -3,6 +3,13 @@ include(compiler/features)
include(helpers) include(helpers)
include(git/commit) include(git/commit)
# If ccache is present, enable it for better compiletimes
find_program(CCACHE_FOUND ccache)
if (CCACHE_FOUND AND FGL_USE_CCACHE)
message("== CCACHE found, Using it")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif ()
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_PLATFORM_ID} STREQUAL "MinGW")) if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_PLATFORM_ID} STREQUAL "MinGW"))
include(compiler/gcc) include(compiler/gcc)
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")

View File

@@ -124,7 +124,7 @@
set(FGL_STATIC_ANALYSIS 0) set(FGL_STATIC_ANALYSIS 0)
endif () endif ()
if (FGL_STATIC_ANALYSIS EQUAL 1) if (DEFINED FGL_STATIC_ANALYSIS AND FGL_STATIC_ANALYSIS EQUAL 1)
list(APPEND FGL_CONFIG "-fanalyzer") list(APPEND FGL_CONFIG "-fanalyzer")
# list(APPEND FGL_CONFIG "-Wanalyzer-too-complex") # list(APPEND FGL_CONFIG "-Wanalyzer-too-complex")
# Breaks more often then it is helpful # Breaks more often then it is helpful
@@ -167,10 +167,10 @@
list(APPEND FGL_SHARED_DEBUG "-fvar-tracking-assignments") list(APPEND FGL_SHARED_DEBUG "-fvar-tracking-assignments")
# Optimization flags # Optimization flags
set(FGL_FINAL_FLAGS_RELEASE "-O2;-s;${FGL_GENERAL_OPTIMIZATION_FLAGS};${FGL_SHARED_OPTIMIZATION_FLAGS}") # System agonistc flags set(FGL_FINAL_FLAGS_RELEASE "-O2;-s;${FGL_GENERAL_OPTIMIZATION_FLAGS};${FGL_SHARED_OPTIMIZATION_FLAGS};${FGL_SHARED_FLAGS}") # System agonistc flags
set(FGL_FINAL_FLAGS_RELWITHDEBINFO "-O2;${FGL_GENERAL_OPTIMIZATION_FLAGS};${FGL_SHARED_OPTIMIZATION_FLAGS};${FGL_SHARED_DEBUG}") set(FGL_FINAL_FLAGS_RELWITHDEBINFO "-O2;${FGL_GENERAL_OPTIMIZATION_FLAGS};${FGL_SHARED_OPTIMIZATION_FLAGS};${FGL_SHARED_DEBUG};${FGL_SHARED_FLAGS}")
set(FGL_FINAL_FLAGS_DEBUG "-O0;-g;-fstrict-aliasing;-fno-omit-frame-pointer;-ftrapv;-fverbose-asm;-femit-class-debug-always;${FGL_SHARED_DEBUG}") # Debug flags set(FGL_FINAL_FLAGS_DEBUG "-O0;-g;-fstrict-aliasing;-fno-omit-frame-pointer;-ftrapv;-fverbose-asm;-femit-class-debug-always;${FGL_SHARED_DEBUG};${FGL_SHARED_FLAGS}") # Debug flags
set(FGL_FINAL_FLAGS_SYSTEM "-O2;-march=native;-fdeclone-ctor-dtor;-fgcse;-fgcse-las;-fgcse-sm;-ftree-loop-im;-fivopts;-ftree-loop-ivcanon;-fira-hoist-pressure;-fsched-pressure;-fsched-spec-load;-fipa-pta;-s;-ffat-lto-objects;-fno-enforce-eh-specs;-fstrict-enums;${FGL_SHARED_OPTIMIZATION_FLAGS}") # System specific flags. Probably not portable set(FGL_FINAL_FLAGS_SYSTEM "-O2;-march=native;-fdeclone-ctor-dtor;-fgcse;-fgcse-las;-fgcse-sm;-ftree-loop-im;-fivopts;-ftree-loop-ivcanon;-fira-hoist-pressure;-fsched-pressure;-fsched-spec-load;-fipa-pta;-s;-ffat-lto-objects;-fno-enforce-eh-specs;-fstrict-enums;${FGL_SHARED_OPTIMIZATION_FLAGS};${FGL_SHARED_FLAGS}") # System specific flags. Probably not portable
list(APPEND FGL_FLAGS ${FGL_CONFIG}) list(APPEND FGL_FLAGS ${FGL_CONFIG})
list(APPEND FGL_FLAGS ${FGL_FINAL_FLAGS_${UPPER_BUILD_TYPE}}) list(APPEND FGL_FLAGS ${FGL_FINAL_FLAGS_${UPPER_BUILD_TYPE}})

View File

@@ -1,16 +1,17 @@
cmake_minimum_required(VERSION 3.26) include(CheckCXXSourceCompiles)
project(TestCXX)
# Default to C++23 # Test actual compilation of C++26 code
set(STD_VERSION 23) set(CMAKE_REQUIRED_FLAGS "-std=c++26")
check_cxx_source_compiles("
struct A {
auto operator<=>(const A&) const = default; // C++20/26 feature
};
int main() { A a,b; return (a <=> b) == 0 ? 0 : 1; }
" HAS_CXX26)
set(CMAKE_REQUIRED_FLAGS "") # reset
# Check if the compiler supports C++26 if (HAS_CXX26)
include(CheckCXXCompilerFlag) message("-- C++26: ON")
check_cxx_compiler_flag("-std=c++26" COMPILER_SUPPORTS_CXX26) else ()
message("-- C++26: OFF")
if(COMPILER_SUPPORTS_CXX26)
set(STD_VERSION 26)
endif () endif ()
add_executable(${PROJECT_NAME} main.cpp)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${STD_VERSION})

View File

@@ -8,7 +8,7 @@ try_compile(HAS_CPP_REFLECTION
) )
if (HAS_CPP_REFLECTION) if (HAS_CPP_REFLECTION)
message(STATUS "Compiler supports C++ reflection") message(STATUS "C++26 Reflection: ON")
else () else ()
message(STATUS "Compiler does NOT support C++ reflection") message(STATUS "C++26 Reflection: OFF")
endif () endif ()

View File

@@ -23,14 +23,17 @@ function(ConfigureFGLTarget NAME SRC_DIR INCLUDE_DIR)
target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1") target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1")
endif () endif ()
if (COMPILER_SUPPORTS_CXX26) if (CMAKE_CXX_STANDARD STREQUAL 26)
message("Setting target ${NAME} to c++26")
target_compile_features(${NAME} PUBLIC cxx_std_26) target_compile_features(${NAME} PUBLIC cxx_std_26)
else () else ()
message("Setting target ${NAME} to c++23")
target_compile_features(${NAME} PUBLIC cxx_std_23) target_compile_features(${NAME} PUBLIC cxx_std_23)
endif () endif ()
endfunction() endfunction()
function(SplitDebugSymbols NAME) function(SplitDebugSymbols NAME)
if (DEFINED FGL_STRIP_DEBUG AND FGL_STRIP_DEBUG)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_custom_command(TARGET ${NAME} POST_BUILD add_custom_command(TARGET ${NAME} POST_BUILD
COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${NAME}> $<TARGET_FILE:${NAME}>.debug COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${NAME}> $<TARGET_FILE:${NAME}>.debug
@@ -39,19 +42,17 @@ function(SplitDebugSymbols NAME)
COMMENT "Stripping symbols and creating ${NAME}.debug" COMMENT "Stripping symbols and creating ${NAME}.debug"
) )
endif () endif ()
endif ()
endfunction() endfunction()
function(AddFGLExecutable NAME SRC_SOURCES_LOCATION) function(AddFGLExecutable NAME SRC_SOURCES_LOCATION)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp)
${SRC_SOURCES_LOCATION}/**.cpp file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp)
${SRC_SOURCES_LOCATION}/**.hpp
)
file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.ui)
${SRC_SOURCES_LOCATION}/**.ui)
add_executable(${NAME} ${SOURCES}) add_executable(${NAME})
target_sources(${NAME} PUBLIC ${SOURCES}) target_sources(${NAME} PRIVATE ${CPP_SOURCES})
ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} "") ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} "")
@@ -67,16 +68,13 @@ function(AddFGLExecutable NAME SRC_SOURCES_LOCATION)
endfunction() endfunction()
function(AddFGLLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION) function(AddFGLLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION)
file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp)
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp)
${SRC_SOURCES_LOCATION}/**.cpp
${SRC_SOURCES_LOCATION}/**.hpp
)
file(GLOB_RECURSE INCLUDE_HPP_SOURCES CONFIGURE_DEPENDS ${INCLUDE_SOURCES_LOCATION}/**.hpp) file(GLOB_RECURSE INCLUDE_HPP_SOURCES CONFIGURE_DEPENDS ${INCLUDE_SOURCES_LOCATION}/**.hpp)
add_library(${NAME} ${MODE}) 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}) ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} ${INCLUDE_SOURCES_LOCATION})
@@ -98,12 +96,14 @@ function(AddFGLModule NAME SRC_SOURCES_LOCATION)
AddGitInfo(${NAME}) AddGitInfo(${NAME})
target_compile_definitions(${NAME} PRIVATE FGL_BUILD_TYPE="${CMAKE_BUILD_TYPE}") target_compile_definitions(${NAME} PRIVATE FGL_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
ConfigureFGLTarget(${NAME} ${SRC_SOURCES_LOCATION} "")
SplitDebugSymbols(${NAME}) SplitDebugSymbols(${NAME})
endfunction() endfunction()
function(AddFGLChildLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION) function(AddFGLChildLibrary NAME MODE SRC_SOURCES_LOCATION INCLUDE_SOURCES_LOCATION)
file(GLOB_RECURSE CPP_SOURCES ${SRC_SOURCES_LOCATION}/**.cpp) file(GLOB_RECURSE CPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.cpp)
file(GLOB_RECURSE HPP_SOURCES ${SRC_SOURCES_LOCATION}/**.hpp) file(GLOB_RECURSE HPP_SOURCES CONFIGURE_DEPENDS ${SRC_SOURCES_LOCATION}/**.hpp)
file(GLOB_RECURSE INCLUDE_HPP_SOURCES ${INCLUDE_SOURCES_LOCATION}/**.hpp) file(GLOB_RECURSE INCLUDE_HPP_SOURCES ${INCLUDE_SOURCES_LOCATION}/**.hpp)
add_library(${NAME} ${MODE} ${CPP_SOURCES} ${HPP_SOURCES} ${INCLUDE_SOURCES_LOCATION}) add_library(${NAME} ${MODE} ${CPP_SOURCES} ${HPP_SOURCES} ${INCLUDE_SOURCES_LOCATION})
target_include_directories(${NAME} PUBLIC ${INCLUDE_SOURCES_LOCATION}) target_include_directories(${NAME} PUBLIC ${INCLUDE_SOURCES_LOCATION})