Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.14.0 Development #72

Merged
merged 8 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 252 additions & 55 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions cmake/modules/FeatureCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ include(CheckCXXSourceCompiles)
function(feature_check_assert)
message(STATUS "[*] Checking library and feature availability")
foreach(arg IN LISTS ARGN)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/check/Check${arg}.cmake")
if(NOT EXISTS "${HDK_ROOT_PROJECT_SOURCE_DIR}/.hadouken/cmake/modules/check/Check${arg}.cmake")
message(FATAL_ERROR "\t[X] Feature check module for `${arg}` not found!")
endif()
include(check/Check${arg})
string(TOUPPER ${arg} ARG_AS_UPPER)
if (NOT ${PB_PARENT_PROJECT_NAME_UPPER}_FEATURE_HAS_${ARG_AS_UPPER})
if (NOT ${HDK_ROOT_PROJECT_NAME_UPPER}_FEATURE_HAS_${ARG_AS_UPPER})
message(FATAL_ERROR "\t[-] `${arg}` failed")
else()
message(STATUS "\t[+] `${arg}` OK")
add_compile_definitions(${PB_PARENT_PROJECT_NAME_UPPER}_FEATURE_HAS_${ARG_AS_UPPER})
add_compile_definitions(${HDK_ROOT_PROJECT_NAME_UPPER}_FEATURE_HAS_${ARG_AS_UPPER})
endif()
endforeach()
endfunction()
82 changes: 0 additions & 82 deletions cmake/modules/buildvariant/BuildVariant.cmake

This file was deleted.

23 changes: 0 additions & 23 deletions cmake/modules/buildvariant/BuildVariant_Clang.cmake

This file was deleted.

114 changes: 0 additions & 114 deletions cmake/modules/buildvariant/BuildVariant_GCC.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/modules/check/CheckGccBuiltinExpect.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ check_cxx_source_compiles("
return 0;
}
"
${PB_PARENT_PROJECT_NAME_UPPER}_FEATURE_HAS_GCC_BUILTIN_EXPECT
${HDK_ROOT_PROJECT_NAME_UPPER}_FEATURE_HAS_GCC_BUILTIN_EXPECT
)
2 changes: 1 addition & 1 deletion cmake/modules/check/CheckPthreads.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ check_cxx_source_compiles("
return result;
}
"
${PB_PARENT_PROJECT_NAME_UPPER}_FEATURE_HAS_PTHREADS
${HDK_ROOT_PROJECT_NAME_UPPER}_FEATURE_HAS_PTHREADS
)
135 changes: 135 additions & 0 deletions cmake/modules/core/BuildVariant.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/env cmake

# ______________________________________________________
# Contains helper functions to invoke common git commands in CMake.
#
# @file BuildVariant.cmake
# @author Mustafa Kemal GILOR <[email protected]>
# @date 25.02.2020
#
# Copyright (c) Nettsi Informatics Technology Inc.
# All rights reserved. Licensed under the Apache 2.0 License.
# See LICENSE in the project root for license information.
#
# SPDX-License-Identifier: Apache 2.0
# ______________________________________________________

include(CMakeDetermineCCompiler)
include(CMakeDetermineCXXCompiler)

function(hdk_set_build_variant)
hdk_log_set_context("hadouken.buildvariant")
hdk_log_status("Setting up build variant and flags")

if(NOT CMAKE_BUILD_TYPE)
hdk_log_status("Build variant is not explicitly specified. Assuming `RelWithDebInfo`.")
set(CMAKE_BUILD_TYPE RelWithDebInfo PARENT_SCOPE)
endif()

hdk_log_status("Build variant: ${CMAKE_BUILD_TYPE}")
hdk_log_verbose("CXX flags (debug): ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_DEBUG}")
hdk_log_verbose("CXX flags (release): ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELEASE}")
hdk_log_verbose("CXX flags (relwithdebinfo): ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELWITHDEBINFO}")
hdk_log_verbose("CXX flags (minsizerel): ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_MINSIZEREL}")

set(CMAKE_CXX_FLAGS_DEBUG ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELEASE})
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_RELWITHDEBINFO})
set(CMAKE_CXX_FLAGS_MINSIZEREL ${${HDK_ROOT_PROJECT_NAME_UPPER}_HDK_CXX_FLAGS_MINSIZEREL})


if(CMAKE_CXX_COMPILER_ID MATCHES "[gG][nN][uU]")
hdk_log_status("Toolchain: GNU (GCC) version ${CMAKE_CXX_COMPILER_VERSION}")
include(core/DiagnosticFlags_GCC)
elseif((CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]") OR (CMAKE_C_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]") )
hdk_log_status("Toolchain: LLVM (Clang) version ${CMAKE_CXX_COMPILER_VERSION}")
include(core/DiagnosticFlags_Clang)
else()
hdk_log_warn("Unable to determine toolchain")
return()
endif()

set(WARN_BUT_NO_ERROR "")
set(EXTENDED_WARNINGS "")
set(EXCLUDED_WARNIGS "")

# Append
foreach(VER_MAJOR RANGE 0 99)
foreach(VER_MINOR RANGE 0 99)

if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER ${VER_MAJOR}.${VER_MINOR})

# Warn but no error
if(DEFINED ${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_WARN_BUT_NO_ERROR)
hdk_log_trace("Appended ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_WARN_BUT_NO_ERROR} to WARN_BUT_NO_ERROR")
string(CONCAT WARN_BUT_NO_ERROR ${WARN_BUT_NO_ERROR} " " ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_WARN_BUT_NO_ERROR})
endif()

# Extended warnings which are not included in -Wall
if(DEFINED ${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXTENDED_WARNINGS)
hdk_log_trace("Appended ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXTENDED_WARNINGS} to EXTENDED_WARNINGS")
string(CONCAT EXTENDED_WARNINGS ${EXTENDED_WARNINGS} " " ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXTENDED_WARNINGS})
endif()

# Excluded warnings which are included in -Wall but not so much useful
if(DEFINED ${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXCLUDED_WARNINGS)
hdk_log_trace("Appended ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXCLUDED_WARNINGS} to EXCLUDED_WARNINGS")
string(CONCAT EXCLUDED_WARNINGS ${EXCLUDED_WARNINGS} " " ${${HADOUKEN_COMPILER}_${VER_MAJOR}${VER_MINOR}_EXCLUDED_WARNINGS})
endif()

endif()
endforeach()
endforeach()


if((CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR (CMAKE_BUILD_TYPE MATCHES Release))
hdk_log_status("########################################################################")
hdk_log_status("BEWARE: As this is a release build, warnings will be treated as errors.")
hdk_log_status("########################################################################")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic ${EXTENDED_WARNINGS} -Werror ${EXCLUDED_WARNINGS} ${EXCLUDED_WERRORS}")
else()
hdk_log_status("########################################################################")
hdk_log_status("NOTE: In debug builds, -Werror is disabled in order to not frustate you.")
hdk_log_status("Build your code with release variant before committing it to the remote.")
hdk_log_status("Release build will fail on any kind of warning generated by compiler.")
hdk_log_status("########################################################################")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wpedantic ${EXTENDED_WARNINGS} ${WARN_BUT_NO_ERROR} ${EXCLUDED_WARNINGS}")
endif()
hdk_log_status("########################################################################")
hdk_log_status("CXX Flags")
hdk_log_indent(2)
hdk_log_status("(any): ${CMAKE_CXX_FLAGS}")
hdk_log_status("(debug): ${CMAKE_CXX_FLAGS_DEBUG}")
hdk_log_status("(release): ${CMAKE_CXX_FLAGS_RELEASE}")
hdk_log_status("(relwithdebinfo): ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
hdk_log_status("(minsizerel): ${CMAKE_CXX_FLAGS_MINSIZEREL}")
hdk_log_unindent(2)
hdk_log_status("########################################################################")
hdk_log_status("Build details are set.")

set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} PARENT_SCOPE)
set(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL} PARENT_SCOPE)
endfunction()



function (hdk_build_variant_export_to_macro)
cmake_parse_arguments(ARGS "" "PREFIX;" "" ${ARGN})

if(ARGS_PREFIX)
string(TOUPPER ${ARGS_PREFIX} ARGS_PREFIX)

# Maket it C preprocessor macro friently
string(REGEX REPLACE "[^a-zA-Z0-9]" "_" ARGS_PREFIX ${ARGS_PREFIX})
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
add_compile_definitions(${ARGS_PREFIX}DEBUG=1)
else()
# Other build types are considered non-debug
add_compile_definitions(${ARGS_PREFIX}NDEBUG=1)
endif()
endfunction()
Loading