Some compiling cleanup

This commit is contained in:
2025-01-18 15:29:02 -05:00
parent 66c270d3c6
commit d33379850c
26 changed files with 52 additions and 508 deletions

3
.gitmodules vendored
View File

@@ -52,3 +52,6 @@
[submodule "dependencies/glslang"]
path = dependencies/glslang
url = https://github.com/KhronosGroup/glslang.git
[submodule "fgl_cmake_modules"]
path = fgl_cmake_modules
url = git@github.com:KJNeko/fgl_cmake_modules.git

View File

@@ -8,21 +8,20 @@ if (CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif ()
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(fgl_cmake_modules)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MESSAGE_LOG_LEVEL DEBUG CACHE STRING "CMake messaging level")
PreSetup()
PostSetup()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/data)
#Enable cmake_modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
include(common)
message("-- CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE)
@@ -41,10 +40,4 @@ include(dependencies/shaderc)
add_subdirectory(src)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/compile_commands.json
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/compile_commands.json
COMMENT "Copying build commands to src dir")
SetVersionInfo()
CompilerPostSetup()
CompilerPostSetup()

View File

@@ -1,11 +0,0 @@
# /cmake_modules/apple.cmake
if (APPLE)
set(which_program "which")
set(os_path_separator "/")
function(PlatformPreSetup)
endfunction()
function(PlatformPostSetup)
endfunction()
endif ()

View File

@@ -1,23 +0,0 @@
function(CompilerPreSetup)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
#These two flags added with older gcc versions and Qt causes a compiler segfault -Wmismatched-tags -Wredundant-tags
# STL has some warnings that prevent -Werror level compilation "-Wnull-dereference"
set(FGL_WARNINGS "-Wall -Wundef -Wextra -Wpessimizing-move -Wpedantic -Weffc++ -pedantic-errors -Wuninitialized -Wunused -Wunused-parameter -Winit-self -Wconversion -Wextra-semi -Wsuggest-override -Wno-format-zero-length -Wmissing-include-dirs -Wshift-overflow -Walloca -Wsign-promo -Wconversion -Wpacked -Wredundant-decls -Wctor-dtor-privacy -Wdeprecated-copy-dtor -Wold-style-cast -Woverloaded-virtual -Wzero-as-null-pointer-constant -Wwrite-strings -Wunused-const-variable -Wdouble-promotion -Wpointer-arith -Wcast-qual -Wconversion -Wsign-conversion -Wimplicit-fallthrough -Wmisleading-indentation -Wdangling-else -Wdate-time -Wformat=2 -Wswitch-default")
set(FGL_CONFIG "-std=c++20")
set(FGL_DEBUG "-Og -g -fstrict-aliasing -fno-omit-frame-pointer -fstack-check -ftrapv -fverbose-asm")
#Generates system specific stuff (IE requires AVX)
set(FGL_SYSTEM_SPECIFIC "-march=native -fgcse -fgcse-las -fgcse-sm -fdeclone-ctor-dtor -fdevirtualize-speculatively -ftree-loop-im -fivopts -ftree-loop-ivcanon -fira-hoist-pressure -fsched-pressure -fsched-spec-load -fipa-pta -flto=auto -s -ffat-lto-objects -fno-enforce-eh-specs -fstrict-enums -funroll-loops")
#Generates safe optimization flags
set(FGL_SYSTEM_SAFE "-O3 -fdevirtualize-at-ltrans -s")
set(FGL_FLAGS_DEBUG "${FGL_WARNINGS} ${FGL_CONFIG} ${FGL_DEBUG}")
set(FGL_FLAGS_SYSTEM "${FLG_CONFIG} -DNDEBUG ${FGL_SYSTEM_SAFE} ${FGL_SYSTEM_SPECIFIC}")
set(FGL_FLAGS_RELEASE "${FGL_CONFIG} -DNDEBUG -s ${FGL_SYSTEM_SAFE} ${FGL_WARNINGS} -Werror")
set(FGL_FLAGS_RELWITHDEBINFO "${FGL_CONFIG} -DNDEBUG -g ${FGL_SYSTEM_SAFE} ${FGL_SYSTEM_SPECIFIC}")
set(FGL_FLAGS "${FGL_FLAGS_${UPPER_BUILD_TYPE}}" PARENT_SCOPE) # PARENT_SCOPE sends the variable up one level.
endif ()
endfunction()
function(CompilerPostSetup)
endfunction()

View File

@@ -1,46 +0,0 @@
# /cmake_modules/common.cmake
message(DEBUG "Entering ${CMAKE_CURRENT_LIST_FILE}")
message(DEBUG "Platform: ${CMAKE_CXX_PLATFORM_ID}")
message(DEBUG "Compiler: ${CMAKE_CXX_COMPILER_ID}")
message(DEBUG "Compiler: ${CMAKE_CXX_COMPILER}")
set(BINARY_FOLDER "${CMAKE_BINARY_DIR}/bin")
include(utils)
include(qt)
if ((${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU") OR (${CMAKE_CXX_PLATFORM_ID} STREQUAL "MinGW"))
include(gcc)
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
include(clang)
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
include(msvc)
else ()
message(WARNING "Unknown Compiler")
#Define dummy PreCompilerSetup for unknown compilers. Later on, this will be replaced by a proper error message
function(PreCompilerSetup)
message(WARNING "Unknown Compiler! Dummy PreCompilerSetup")
endfunction()
function(PostCompilerSetup)
message(WARNING "Unknown Compiler! Dummy PostCompilerSetup")
endfunction()
endif ()
if ((WIN32))
message(DEBUG "Compiling for Windows")
include(win32)
elseif (APPLE)
message(DEBUG "Compiling for Apple")
elseif (UNIX)
message(DEBUG "Compiling for Unix")
include(linux)
else ()
message(DEBUG "Unknown Platform")
endif ()
include(feature_checks)
include(versioninfo)
include(profiling)
include(docs)
message(DEBUG "Leaving ${CMAKE_CURRENT_LIST_FILE}")
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_UPPER_BUILD_TYPE)

View File

@@ -1,22 +0,0 @@
option(BUILD_DOC "Build documentation" ON)
if (DEFINED BUILD_DOCS AND BUILD_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/Doxyfile)
set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
add_custom_target(doc_doxygen ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
else ()
message("Doxygen need to be installed to generate the doxygen documentation")
endif ()
endif ()

View File

@@ -1,6 +0,0 @@
include(CheckCXXSourceCompiles)
include(feature_checks/check_format)
include(feature_checks/check_backtrace)

View File

@@ -1,6 +0,0 @@
check_cxx_source_compiles(
"#include <backtrace>\nint main(void){ std::basic_stacktrace thing { std::basic_stacktrace::current() }; return 0;}"
HAVE_STD_BACKTRACE
)

View File

@@ -1,8 +0,0 @@
check_cxx_source_compiles(
"#include <format>\nint main(void){ std::format(\"{}\", 1);return 0;}"
HAVE_STD_FORMAT
)

View File

@@ -1,137 +0,0 @@
function(AppendFlag FLAG_TEXT)
set(FGL_WARNINGS "${FGL_WARNINGS} ${FLAG_TEXT}" PARENT_SCOPE)
endfunction()
function(CompilerPreSetup)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
#These two flags added with older gcc versions and Qt causes a compiler segfault -Wmismatched-tags -Wredundant-tags
# STL has some warnings that prevent -Werror level compilation "-Wnull-dereference"
# Generic warnings.
set(FGL_WARNINGS "-Wall -Wundef -Wextra -Wpedantic")
#AppendFlag("-Wno-changes-meaning") # Prevents accidently changing the type of things. Cannot define 1 things as another later
AppendFlag("-Wdouble-promotion") #Prevents issue where you can do math as a double which might not be intended.
AppendFlag("-Wnonnull") #Prevents passing null as an argument marked as nonnull attribute
AppendFlag("-Wnull-dereference") #Warns about a possible null dereference. Compiler checks all possible paths
# Can't selectively disable this for certian things.
#AppendFlag("-Wnrvo") #Compiler checks for return value optimization invalidations
AppendFlag("-Winfinite-recursion") #Warns about infinite recursive calls
AppendFlag("-Winit-self") #Yells at you if you init something with itself
AppendFlag("-Wimplicit-fallthrough=4") # Warns about switch statements having a implicit fallthrough. must be marked with [[fallthrough]]
AppendFlag("-Wignored-qualifiers") #Warns if qualifiers are used in return types. Which are ignored.
AppendFlag("-Wno-ignored-attributes") #Warns if the compiler ignored an attribute and is unknown to the compiler
AppendFlag("-Wmain") #Warns if the main function looks odd. (Wrong return type, ect)
AppendFlag("-Wmisleading-indentation")#Warns if the indentation around an if/conditional could be misleading
AppendFlag("-Wmissing-attributes") #Warns about missing attributes that are defined with a related function (attributes in the prototype but missing in the definition) (-Wall enabled)
AppendFlag("-Wmissing-braces") #Warns when initalizing and missing braces during a aggregate or union initalization. (-Wall enabled)
AppendFlag("-Wmissing-include-dirs") #Warns when missing a include dir that was supplied to the compiler
AppendFlag("-Wmultistatement-macros") #Warns about odd behaviours with macros being used with conditionals that appear guarded by them
AppendFlag("-Wparentheses") #Warns about unnecessary parentheses or other weird cases. (Also warns of a case x<=y<=z being seen as (<=y ? 1 : 0) <= z
AppendFlag("-Wno-self-move") # Prevents moving a value into itself. Which has no effect
AppendFlag("-Wsequence-point") # Prevents some really weird shit like a = a++. Since due to the order of operations this results in undefined behaviour
AppendFlag("-Wreturn-type") #Warns when a return type defaults to int.
AppendFlag("-Wno-shift-count-negative") #Warns when a bitshift count is negative
AppendFlag("-Wno-shift-count-overflow") #Warns when bitshifting will overflow the width
AppendFlag("-Wswitch") #Warns when a switch lacks a case for it's given type.
AppendFlag("-Wswitch-enum") #Warn when a switch misses an enum type in it's case list
AppendFlag("-Wno-switch-outside-range") #Prevents a case outside of a switch's range.
AppendFlag("-Wno-switch-unreachable") #Warns when a case value can possible not be reached
AppendFlag("-Wunused") #Enables a bunch of warnings that relate to things stated but never used.
AppendFlag("-Wuninitialized") #Warns about values being uninitalized. Where accessing them might be UB in some situations
AppendFlag("-Wmaybe-uninitialized") #Warns when a value MIGHT not be initalized upon access.
AppendFlag("-Wunknown-pragmas") #Self explanitory
AppendFlag("-Wno-prio-ctor-dtor") #Yells about the developer setting priority to compiler reserved values for ctor/dtors
AppendFlag("-Wstrict-aliasing=3") #Included in -Wall. Prevents aliasing rule breaking
AppendFlag("-Wstrict-overflow=2") #Trys to hint at using values that won't overflow or will have the smallest chance of overflowing. Example. x+2 > y -> x+1 >= y
AppendFlag("-Wbool-operation") #Warn against weird operations on the boolean type. Such as bitwise operations ON the bool
AppendFlag("-Wduplicated-branches") #Warns about branches that appear to do the same thing
AppendFlag("-Wduplicated-cond") #Warns about a conditional branch having a matching condition for both sides
AppendFlag("-Wtautological-compare") #Warns when comparing something to itself
AppendFlag("-Wshadow") #Warns about shadowing any variables
AppendFlag("-Wfree-nonheap-object") #Warns about freeing a object not on the heap.
AppendFlag("-Wpointer-arith") #Warns about missuse of 'sizeof' on types with no size. (Such as void)
AppendFlag("-Wtype-limits") #Warn about comparisons that might be always true/false due to the limitations of a types' ability to display large or small values
AppendFlag("-Wundef") #Warns about undefined behaviour when evaluating undefined defines
AppendFlag("-Wcast-qual") #Warns when a cast removes a const attribute from a pointer.
AppendFlag("-Wcast-align") #Warns when casting can shift a byte boundary for the pointer
AppendFlag("-Wcast-function-type") #Warns when a function pointer is cast to a incompatable function pointer.
AppendFlag("-Wwrite-strings") #Warns about string literals to char* conversions
AppendFlag("-Wclobbered") #Warns about variables that are changed by longjmp or vfork
AppendFlag("-Wconversion") #Warns about conversions between real and integer numbers and conversions between signed/unsigned numbers
AppendFlag("-Wdangling-else") #Warns about confusing else statements
AppendFlag("-Wdangling-pointer=2") #Warns about use of pointers with automatic lifetime
AppendFlag("-Wempty-body") #Warns about empty conditional bodies
AppendFlag("-Wfloat-conversion") #Warns about reduction of precision from double -> float conversions
AppendFlag("-Waddress") #Prevents off uses of addresses
AppendFlag("-Wlogical-op") #Warns about strange uses of logical operations in expressions
#TODO: Enable this again when I have time to properly clean it all up. Hiding the functions in a namespace is plenty.
#AppendFlag("-Wmissing-declarations") #Warns about global functions without any previous declaration
AppendFlag("-Wmissing-field-initializers") #Warns about a structure missing some fields in it's initalizer
#Note: padded is for masochists. That's coming from me. Only really enable this if your ready for a fun time.
#AppendFlag("-Wpadded")
AppendFlag("-Wredundant-decls") #Warns about declarations that happen more then once.
#AppendFlag("-Wctor-dtor-privacy") #Warns if a class appears unusable due to private ctor/dtors
AppendFlag("-Wdelete-non-virtual-dtor") #Warns about using `delete` on a class that has virtual functions without a virtual dtor
AppendFlag("-Winvalid-constexpr") #Warns that a function marked as constexpr can't possibly produce a constexpr expression
# Disabled due to spdlog
#AppendFlag("-Wnoexcept") #Warns when a noexcept expression is false due to throwing
AppendFlag("-Wnoexcept-type")
AppendFlag("-Wclass-memaccess") #Warns about accessing memory of a class. Which is likely invalid
AppendFlag("-Wregister") #Warns of use for `register` keyword. Which has been depreicated
AppendFlag("-Wreorder") # Warns about initlization order being wrong in a class' init list
AppendFlag("-Wno-pessimizing-move") #Warns about copy elision being prevented my std::move
AppendFlag("-Wno-redundant-move") #Warns about a std::move being redundant
AppendFlag("-Wredundant-tags") #Warns about a class-key and enum-key being redundant
AppendFlag("-Weffc++") #THEEE warning. Forces you to follow c++ guidelines for effective C++
AppendFlag("-Wold-style-cast") #Warns about using old style C casts
AppendFlag("-Woverloaded-virtual") #Warns when a function does not overload
AppendFlag("-Wsign-promo") #Warns about signed promotion without being explicit
AppendFlag("-Wmismatched-new-delete") #Warns about using new and free instead of new and delete
AppendFlag("-Wmismatched-tags") #Warns about mismatched tags for an object.
#AppendFlag("-Wmultiple-inheritance") #Warns about multiple inheritance (Leading to the diamond inheritance model)
AppendFlag("-Wzero-as-null-pointer-constant") #Warns about using literal zero as a null pointer comparison. Zero might not be nullptr on some machines.
AppendFlag("-Wcatch-value=3") #Warns about catches not catching by reference.
AppendFlag("-Wsuggest-final-types") #Self explanatory
AppendFlag("-Wsuggest-final-methods")# ^
AppendFlag("-Wsuggest-override")# ^
AppendFlag("-Wuse-after-free") #Warns about accessing a value after calling 'free' on it
AppendFlag("-Wuseless-cast") #Warns about a cast that is useless.
# Starting other weird flags
AppendFlag("-fdiagnostics-show-template-tree") # Shows the template diagnostic info as a tree instead.
AppendFlag("-fdiagnostics-path-format=inline-events")
set(FGL_CONFIG "-std=c++23 -fmax-errors=3 -fconcepts-diagnostics-depth=8 -ftree-vectorize")
if (DEFINED USE_WERROR)
set(FGL_CONFIG "${FGL_CONFIG} -Werror")
endif ()
# Safe for debug
set(FGL_SHARED_OPTIMIZATION_FLAGS "-fno-rtti")
set(FGL_GENERAL_OPTIMIZATION_FLAGS "-fdevirtualize-at-ltrans -fdevirtualize-speculatively -funroll-loops -floop-nest-optimize -floop-parallelize-all -fsplit-paths -fstrict-aliasing -ftree-vectorize")
set(FGL_SHARED_DEBUG "-gdwarf-4 -fvar-tracking-assignments")
# Optimization flags
set(FGL_OPTIMIZATION_FLAGS_RELEASE "-O2 -s ${FGL_GENERAL_OPTIMIZATION_FLAGS} ${FGL_SHARED_OPTIMIZATION_FLAGS}") # System agonistc flags
set(FGL_OPTIMIZATION_FLAGS_RELWITHDEBINFO "-O2 ${FGL_GENERAL_OPTIMIZATION_FLAGS} ${FGL_SHARED_OPTIMIZATION_FLAGS} ${FGL_SHARED_DEBUG}")
set(FGL_OPTIMIZATION_FLAGS_DEBUG "-O0 -g -fstrict-aliasing -fno-omit-frame-pointer -ftrapv -fverbose-asm -femit-class-debug-always ${FGL_SHARED_DEBUG}") # Debug flags
set(FGL_OPTIMIZATION_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
# Final sets
set(FGL_FLAGS "${FGL_CONFIG} ${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}} ${FGL_WARNINGS}" PARENT_SCOPE) # Flags for our shit
#set(FGL_FLAGS "${FGL_OPTIMIZATION_FLAGS_${UPPER_BUILD_TYPE}}" PARENT_SCOPE)
set(FGL_CHILD_FLAGS "${FGL_OPTIMIZATION_FLAGS_RELEASE}" PARENT_SCOPE) # Child flags for adding optimization to anything we build ourselves but doesn't follow our standard
# We use release flags since we really don't need to be using debug flags for anything not ours
#set(CMAKE_CXX_FLAGS "${FGL_CHILD_FLAGS}")
endif ()
endfunction()
function(CompilerPostSetup)
endfunction()

View File

@@ -1,11 +0,0 @@
# /cmake_modules/linux.cmake
if (UNIX AND (NOT APPLE))
set(which_program "which")
set(os_path_separator "/")
function(PlatformPreSetup)
endfunction()
function(PlatformPostSetup)
endfunction()
endif () # if(UNIX AND (NOT APPLE))

View File

@@ -1,23 +0,0 @@
function(CompilerPreSetup)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
#These two flags added with older gcc versions and Qt causes a compiler segfault -Wmismatched-tags -Wredundant-tags
# STL has some warnings that prevent -Werror level compilation "-Wnull-dereference"
set(FGL_WARNINGS "-Wall -Wundef -Wextra -Wpessimizing-move -Wpedantic -Weffc++ -pedantic-errors -Wnoexcept -Wuninitialized -Wunused -Wunused-parameter -Winit-self -Wconversion -Wuseless-cast -Wextra-semi -Wsuggest-final-types -Wsuggest-final-methods -Wsuggest-override -Wformat-signedness -Wno-format-zero-length -Wmissing-include-dirs -Wshift-overflow=2 -Walloc-zero -Walloca -Wsign-promo -Wconversion -Wduplicated-branches -Wduplicated-cond -Wshadow -Wshadow=local -Wvirtual-inheritance -Wno-virtual-move-assign -Wunsafe-loop-optimizations -Wnormalized -Wpacked -Wredundant-decls -Wctor-dtor-privacy -Wdeprecated-copy-dtor -Wstrict-null-sentinel -Wold-style-cast -Woverloaded-virtual -Wzero-as-null-pointer-constant -Wconditionally-supported -Wwrite-strings -Wunused-const-variable=2 -Wdouble-promotion -Wpointer-arith -Wcast-align=strict -Wcast-qual -Wconversion -Wsign-conversion -Wimplicit-fallthrough=1 -Wmisleading-indentation -Wdangling-else -Wdate-time -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation=2 -Wswitch-default -Wstringop-overflow=4 -Warray-bounds=2 -Wattribute-alias=2 -Wcatch-value=2 -Wplacement-new=2 -Wtrampolines -Winvalid-imported-macros -Winvalid-imported-macros")
set(FGL_CONFIG "-std=c++20 -fmax-errors=3 -fconcepts-diagnostics-depth=4")
set(FGL_DEBUG "-Og -g -fstrict-aliasing -fno-omit-frame-pointer -fstack-check -ftrapv -fverbose-asm")
#Generates system specific stuff (IE requires AVX)
set(FGL_SYSTEM_SPECIFIC "-march=native -fgcse -fgcse-las -fgcse-sm -fdeclone-ctor-dtor -fdevirtualize-speculatively -ftree-loop-im -fivopts -ftree-loop-ivcanon -fira-hoist-pressure -fsched-pressure -fsched-spec-load -fipa-pta -flto=auto -s -ffat-lto-objects -fno-enforce-eh-specs -fstrict-enums -funroll-loops")
#Generates safe optimization flags
set(FGL_SYSTEM_SAFE "-O3 -fdevirtualize-at-ltrans -s")
set(FGL_FLAGS_DEBUG "${FGL_WARNINGS} ${FGL_CONFIG} ${FGL_DEBUG}")
set(FGL_FLAGS_SYSTEM "${FLG_CONFIG} -DNDEBUG ${FGL_SYSTEM_SAFE} ${FGL_SYSTEM_SPECIFIC}")
set(FGL_FLAGS_RELEASE "${FGL_CONFIG} -DNDEBUG -s ${FGL_SYSTEM_SAFE} ${FGL_WARNINGS} -Werror")
set(FGL_FLAGS_RELWITHDEBINFO "${FGL_CONFIG} -DNDEBUG -g ${FGL_SYSTEM_SAFE} ${FGL_SYSTEM_SPECIFIC}")
set(FGL_FLAGS "${FGL_FLAGS_${UPPER_BUILD_TYPE}}" PARENT_SCOPE) # PARENT_SCOPE sends the variable up one level.
endif ()
endfunction()
function(CompilerPostSetup)
endfunction()

View File

@@ -1,23 +0,0 @@
SET(COPY_MSYS2_BINARIES OFF CACHE BOOL "Whether to copy the DLLs from the corresponding MSYS2 prefix")
IF (${COPY_MSYS2_BINARIES})
GET_PARENT_PATH(${CMAKE_C_COMPILER} "/" compiler_folder)
MESSAGE(DEBUG "compiler_folder: ${compiler_folder}")
MESSAGE(DEBUG "BINARY FOLDER: ${BINARY_FOLDER}")
SET(msys2_prefix_bin ${compiler_folder})
FOREACH (
DLL
libsqlite3-0.dll
libgcc_s_seh-1.dll
libgcc_s_dw2-1.dll
libstdc++-6.dll
libwinpthread-1.dll
)
SET(file2copy "${msys2_prefix_bin}/${DLL}")
IF (EXISTS ${file2copy})
MESSAGE(DEBUG "COPYING: ${file2copy}")
CONFIGURE_FILE(${file2copy} "${BINARY_FOLDER}/${DLL}" COPYONLY)
endif () # EXISTS ${file2copy}
ENDFOREACH ()
ENDIF ()

View File

@@ -1,11 +0,0 @@
option(ATLAS_PROFILE_ENABLE "" OFF)
if (${ATLAS_PROFILE_ENABLE} STREQUAL "ON")
option(TRACY_ENABLE "" ON)
option(TRACY_ON_DEMAND "" ON) #Reduces memory usage if profile isn't attached and makes memory profiling possible.
option(TRACY_NO_BROADCAST "" ON)
option(TRACY_NO_VSYNC_CAPTURE "" ON)
option(TRACY_NO_FRAME_IMAGE "" ON)
else ()
option(TRACY_ENABLE "" OFF)
endif ()

View File

@@ -1,4 +0,0 @@
# /cmake_modules/qt.cmake
set(QT_VERSION "6.4.3" CACHE STRING "Version of Qt being used.")
set(QT_PATH "C:/Qt/${QT_VERSION}/mingw_64" CACHE PATH "Prefix in which to find Qt.")

View File

@@ -1,24 +0,0 @@
# /cmake_modules/utils.cmake
set(os_path_separator "")
FUNCTION(GET_PARENT_PATH absolute_path path_separator return_var)
message(DEBUG "absolute_path: ${absolute_path}")
string(REPLACE ${path_separator} ";" absolute_path_list ${absolute_path}) # Converts Compiler path to ';' seperated list
message(DEBUG "absolute_path_list: ${absolute_path_list}")
LIST(POP_BACK absolute_path_list)
message(DEBUG "absolute_path_list: ${absolute_path_list}")
LIST(JOIN absolute_path_list "/" parent_path) # Converts ';' seperated list to path
message(DEBUG "parent_path: ${parent_path}")
SET(${return_var} ${parent_path} PARENT_SCOPE)
RETURN(${return_var})
ENDFUNCTION()
set(which_program "") # To be filled in by win32, linux, or apple modules.
FUNCTION(WHICH program2find)
EXECUTE_PROCESS(
COMMAND ${which_program} ${program2find}
RESULT_VARIABLE exit_code
OUTPUT_VARIABLE return_value
)
ENDFUNCTION()

View File

@@ -1,72 +0,0 @@
# /cmake_modules/versioninfo.cmake
function(SetVersionInfo)
endfunction()
# find_package(Git)
# if (NOT Git_FOUND AND NOT DEFINED BYPASS_GIT_REQUIREMENT)
# message(FATAL_ERROR
# "HEY YOU! YEAH YOU! READ ME WITH YOUR EYES. Git was not found!
# DO **NOT** **EXPECT** **SUPPORT** if your sending us log
# information without filling these in manually or letting cmake find git.
# Go read the docs to figure out how to do this. Or fix your git install for cmake")
# endif ()
#
# if (DEFINED ATLAS_GIT_BRANCH)
# message("-- Set git branch string to ${ATLAS_GIT_BRANCH}")
# else ()
# #Get the git branch us currently
# execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ATLAS_GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
# message("-- Set git branch string to: ${ATLAS_GIT_BRANCH}")
# endif ()
#
# if (DEFINED ATLAS_GIT_REVISION)
# message("-- Set git revision to: ${ATLAS_GIT_REVISION}")
# else ()
# execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%H WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ATLAS_GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)
# message("-- Set git revision to ${ATLAS_GIT_REVISION}")
# endif ()
#
# if (DEFINED ATLAS_GIT_TAG)
# message("-- Git tag set to: ${ATLAS_GIT_TAG}")
# else ()
# execute_process(COMMAND ${GIT_EXECUTABLE} ls-remote --tags --sort=-v:refname https://github.com/KJNeko/Atlas.git v*.*.?
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ATLAS_REMOTE_V_TAGS OUTPUT_STRIP_TRAILING_WHITESPACE)
# string(REPLACE "\n" ";" ATLAS_REMOTE_V_TAGS_LIST ${ATLAS_REMOTE_V_TAGS})
# list(LENGTH ATLAS_REMOTE_V_TAGS_LIST ATLAS_REMOTE_TAGS_COUNT)
# message("-- Tag count: ${ATLAS_REMOTE_TAGS_COUNT}")
# list(GET ATLAS_REMOTE_V_TAGS_LIST 0 ATLAS_LATEST_TAG)
# message("-- Latest tag: ${ATLAS_LATEST_TAG}")
# string(REPLACE "/" ";" ATLAS_TAG_SPLIT ${ATLAS_LATEST_TAG})
# list(GET ATLAS_TAG_SPLIT 2 ATLAS_PURE_TAG)
# message("-- Pure tag: ${ATLAS_PURE_TAG}")
# if (ATLAS_PURE_TAG STREQUAL "")
# message(FATAL_ERROR "Was unable to pull latest tag from git. Please define it manually via -DATLAS_GIT_TAG.")
# endif ()
# set(ATLAS_GIT_TAG ${ATLAS_PURE_TAG})
# message("-- Git tag set to: ${ATLAS_GIT_TAG}")
# endif ()
#
# if (DEFINED ATLAS_GIT_REVISION_BRIEF)
# message("-- Set git revision to: ${ATLAS_GIT_REVISION_BRIEF}")
# else ()
# execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%h WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE ATLAS_GIT_REVISION_BRIEF OUTPUT_STRIP_TRAILING_WHITESPACE)
# message("-- Set git revision to ${ATLAS_GIT_REVISION_BRIEF}")
# endif ()
#
# if (DEFINED ATLAS_GIT_CREATED_TIME)
# message("-- Set git created time to: ${ATLAS_GIT_CREATED_TIME}")
# else ()
# string(TIMESTAMP ATLAS_GIT_CREATED_TIME)
# message("-- Set git created time to ${ATLAS_GIT_CREATED_TIME}")
# endif ()
#
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_GIT_BRANCH="${ATLAS_GIT_BRANCH}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_GIT_TAG="${ATLAS_GIT_TAG}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_GIT_REVISION="${ATLAS_GIT_REVISION}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_GIT_REVISION_BRIEF="${ATLAS_GIT_REVISION_BRIEF}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_GIT_CREATED_TIME="${ATLAS_GIT_CREATED_TIME}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_COMPILER_ID="${CMAKE_CXX_COMPILER_ID}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_COMPILER_VER="${CMAKE_CXX_COMPILER_VERSION}")
# target_compile_definitions(${PROJECT_NAME} PRIVATE ATLAS_PLATFORM_ID="${CMAKE_CXX_PLATFORM_ID}")
#endfunction()

View File

@@ -1,23 +0,0 @@
# /cmake_modules/win32.cmake
if (WIN32)
set(which_program "where")
set(os_path_separator "\\")
set(
NEEDED_QT_FOLDERS
"${CMAKE_BINARY_DIR}/bin/data"
"${CMAKE_BINARY_DIR}/bin/iconengines"
"${CMAKE_BINARY_DIR}/bin/imageformats"
"${CMAKE_BINARY_DIR}/bin/networkinformation"
"${CMAKE_BINARY_DIR}/bin/platforms"
"${CMAKE_BINARY_DIR}/bin/styles"
"${CMAKE_BINARY_DIR}/bin/tls"
)
function(PlatformPreSetup)
endfunction() # PlatformPreSetup
function(PlatformPostSetup)
endfunction() # PlatformPostSetup
endif () # if (WIN32)

1
fgl_cmake_modules Submodule

Submodule fgl_cmake_modules added at 11a7071280

View File

@@ -5,28 +5,8 @@ file(GLOB_RECURSE CPP_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/**.hpp"
)
add_library(FGLEngine STATIC ${CPP_SOURCES} ${HPP_SOURCES})
set(CMAKE_CXX_STANDARD 23)
if (DEFINED FGL_ENABLE_PCH AND FGL_ENABLE_PCH)
target_precompile_headers(FGLEngine PRIVATE
<vulkan/vulkan.h>
<tracy/Tracy.hpp>
<vma/vma_impl.hpp>
<glm/glm.hpp>
<glm/gtc/matrix_transform.hpp>
<glm/gtc/constants.hpp>
<glm/vec3.hpp>
<glm/vec2.hpp>
<glm/mat4x4.hpp>
)
endif ()
AddFGLLibrary(FGLEngine STATIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
#add_library(FGLEngine STATIC ${CPP_SOURCES} ${HPP_SOURCES})
target_compile_definitions(FGLEngine PUBLIC VULKAN_HPP_FLAGS_MASK_TYPE_AS_PUBLIC)
@@ -36,7 +16,6 @@ include(dependencies/imgui)
target_link_libraries(FGLEngine PUBLIC Vulkan::Vulkan glm ImGui FGLLoader spdlog shaderc)
target_link_libraries(FGLEngine PUBLIC glfw Tracy::TracyClient VMA)
target_include_directories(FGLEngine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
set_target_properties(FGLEngine PROPERTIES COMPILE_FLAGS ${FGL_FLAGS})
target_compile_features(FGLEngine PUBLIC cxx_std_23)
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_UPPER_BUILD_TYPE)

View File

@@ -78,3 +78,5 @@
FGL_ASSERT( !std::isnan( ( vec3 ).x ), "X value was NaN!" ); \
FGL_ASSERT( !std::isnan( ( vec3 ).y ), "Y value was NaN!" ); \
FGL_ASSERT( !std::isnan( ( vec3 ).z ), "Z value was NaN!" )
#define FGL_TODO() throw std::runtime_error( std::format( "TODO: {}:{}:{}", __FILE__, __LINE__, __PRETTY_FUNCTION__ ) );

View File

@@ -5,7 +5,12 @@
#include "FlameGraph.hpp"
#include <cassert>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Weffc++"
#include <imgui.h>
#pragma GCC diagnostic pop
#include "engine/FGL_DEFINES.hpp"
#include "engine/clock.hpp"
@@ -39,7 +44,7 @@ namespace fgl::engine::debug
FGL_DELETE_COPY( Node );
Node( Node&& other ) :
Node( Node&& other ) noexcept :
m_name( std::move( other.m_name ) ),
m_start( other.m_start ),
m_end( other.m_end ),
@@ -81,18 +86,19 @@ namespace fgl::engine::debug
if ( percent_as_total )
{
const auto total_time { getTotalTime() };
percent = ( static_cast< double >( time.count() ) / static_cast< double >( total_time.count() ) ) * 100.0f;
percent = ( static_cast< double >( time.count() ) / static_cast< double >( total_time.count() ) ) * 100.0;
}
else if ( m_parent )
else if ( m_parent != nullptr )
{
const auto parent_time { this->m_parent->getDuration() };
percent = ( static_cast< double >( time.count() ) / static_cast< double >( parent_time.count() ) ) * 100.0f;
percent = ( static_cast< double >( time.count() ) / static_cast< double >( parent_time.count() ) ) * 100.0;
}
const std::string str { std::format(
"{} -- {:2.2f}ms, ({:2.2f}%)",
m_name,
( std::chrono::duration_cast< std::chrono::microseconds >( diff ).count() / 1000.0f ),
( static_cast< double >( std::chrono::duration_cast< std::chrono::microseconds >( diff ).count() )
/ 1000.0 ),
percent ) };
ImGuiTreeNodeFlags flags { ImGuiTreeNodeFlags_None };

View File

@@ -16,18 +16,13 @@ namespace fgl::engine
bool rayHit( const Ray& ray, const OrientedBoundingBox< CS::World >& obb )
{
FGL_TODO();
return false;
}
bool rayHit( const Ray& ray, const AxisAlignedBoundingBox< CS::World >& aabb )
{
FGL_TODO();
}
} // namespace fgl::engine

View File

@@ -1,9 +1,3 @@
file(GLOB_RECURSE CPP_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/**.cpp")
add_library(FGLLoader STATIC ${CPP_SOURCES})
target_include_directories(FGLLoader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
set_target_properties(FGLLoader PROPERTIES COMPILE_FLAGS ${FGL_CHILD_FLAGS})
AddFGLLibrary(FGLLoader STATIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
#target_include_directories(FGLLoader PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)

View File

@@ -2,8 +2,22 @@
// Created by kj16609 on 1/10/24.
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wcast-qual"
#pragma GCC diagnostic ignored "-Wduplicated-branches"
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#define TINYGLTF_IMPLEMENTATION
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define TINYGLTF_USE_CPP14
#include "tiny_gltf.h"
#pragma GCC diagnostic pop

View File

@@ -2,5 +2,12 @@
// Created by kj16609 on 1/10/24.
//
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wold-style-cast"
#pragma GCC diagnostic ignored "-Wuseless-cast"
#define TINYOBJLOADER_IMPLEMENTATION
#include "tiny_obj_loader.h"
#include "tiny_obj_loader.h"
#pragma GCC diagnostic pop