Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e44655a66 | |||
|
|
e4953b64ff | ||
| 5ffd23050e | |||
| 6ab0444bd3 | |||
| 9ade0feebd | |||
| e8bb87bb28 | |||
| 37280fb95c | |||
| 95aa4bc5d9 | |||
| 4f09dda70a |
@@ -3,6 +3,13 @@ include(compiler/features)
|
||||
include(helpers)
|
||||
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"))
|
||||
include(compiler/gcc)
|
||||
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
set(FGL_STATIC_ANALYSIS 0)
|
||||
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 "-Wanalyzer-too-complex")
|
||||
# Breaks more often then it is helpful
|
||||
@@ -167,10 +167,10 @@
|
||||
list(APPEND FGL_SHARED_DEBUG "-fvar-tracking-assignments")
|
||||
|
||||
# Optimization flags
|
||||
set(FGL_FINAL_FLAGS_RELEASE "-O2;-s;${FGL_GENERAL_OPTIMIZATION_FLAGS};${FGL_SHARED_OPTIMIZATION_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_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_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_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};${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};${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};${FGL_SHARED_FLAGS}") # System specific flags. Probably not portable
|
||||
|
||||
list(APPEND FGL_FLAGS ${FGL_CONFIG})
|
||||
list(APPEND FGL_FLAGS ${FGL_FINAL_FLAGS_${UPPER_BUILD_TYPE}})
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.26)
|
||||
project(TestCXX)
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
# Default to C++23
|
||||
set(STD_VERSION 23)
|
||||
# Test actual compilation of C++26 code
|
||||
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
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-std=c++26" COMPILER_SUPPORTS_CXX26)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX26)
|
||||
set(STD_VERSION 26)
|
||||
if (HAS_CXX26)
|
||||
message("-- C++26: ON")
|
||||
else ()
|
||||
message("-- C++26: OFF")
|
||||
endif ()
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${STD_VERSION})
|
||||
|
||||
@@ -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 ()
|
||||
@@ -23,14 +23,17 @@ function(ConfigureFGLTarget NAME SRC_DIR INCLUDE_DIR)
|
||||
target_compile_definitions(${NAME} PUBLIC "-DFGL_STRICT_WARNINGS=1")
|
||||
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)
|
||||
else ()
|
||||
message("Setting target ${NAME} to c++23")
|
||||
target_compile_features(${NAME} PUBLIC cxx_std_23)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
function(SplitDebugSymbols NAME)
|
||||
if (DEFINED FGL_STRIP_DEBUG AND FGL_STRIP_DEBUG)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
add_custom_command(TARGET ${NAME} POST_BUILD
|
||||
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"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
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 +68,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 +96,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})
|
||||
|
||||
Reference in New Issue
Block a user