basic project
This commit is contained in:
46
.clang-format
Executable file
46
.clang-format
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
# .clang-format for native code portion
|
||||||
|
|
||||||
|
BasedOnStyle: Google
|
||||||
|
|
||||||
|
# force T* or T&
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
PointerAlignment: Left
|
||||||
|
|
||||||
|
TabWidth: 4
|
||||||
|
IndentWidth: 4
|
||||||
|
UseTab: Always
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakStringLiterals: false
|
||||||
|
|
||||||
|
ColumnLimit: 150
|
||||||
|
CompactNamespaces: false
|
||||||
|
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ContinuationIndentWidth: 0
|
||||||
|
|
||||||
|
# turning this on causes major issues with initializer lists
|
||||||
|
Cpp11BracedListStyle: false
|
||||||
|
SpaceBeforeCpp11BracedList: true
|
||||||
|
|
||||||
|
FixNamespaceComments: true
|
||||||
|
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ReflowComments: true
|
||||||
|
|
||||||
|
SortIncludes: CaseInsensitive
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
# specifically for YAML
|
||||||
|
[{yml, yaml}]
|
||||||
|
indent_style = space
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/build
|
||||||
|
/.cache
|
||||||
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
# Block unsupported platforms immediately.
|
||||||
|
if(WIN32 OR APPLE OR BSD)
|
||||||
|
message(FATAL_ERROR "tv2hv doesn't configure or build on these platforms.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
project(tv2hv
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||||
|
|
||||||
|
include(Policies)
|
||||||
|
include(Options)
|
||||||
|
include(ProjectFuncs)
|
||||||
|
include(CompilerFlags)
|
||||||
|
|
||||||
|
# required system dependencies
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
# the source code
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# tv2hv
|
||||||
|
|
||||||
|
this is a very experimental project to emulate a MSN TV 2 (RCA RM4100) box.
|
||||||
52
cmake/CompilerFlags.cmake
Normal file
52
cmake/CompilerFlags.cmake
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
|
||||||
|
# Core compile arguments used for the whole native project
|
||||||
|
|
||||||
|
if(NOT TV2HV_LINKER)
|
||||||
|
message(FATAL_ERROR "Somehow we got here without a set TV2HV_LINKER, bailing.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# This isn't really the best place to put this, but it's probably the only one which makes sense.
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
|
# TODO: Use a list so that this isn't one giant line, and we can just append compile flags to it as needed
|
||||||
|
set(TV2HV_CORE_COMPILE_ARGS "-Wall -Wno-builtin-declaration-mismatch -Wformat=2 -fstrict-flex-arrays=3 -fstack-clash-protection -fstack-protector-strong")
|
||||||
|
set(TV2HV_CORE_LINKER_ARGS "-fuse-ld=${TV2HV_LINKER}")
|
||||||
|
|
||||||
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
|
||||||
|
# Disable C assert() in release builds (needed since we wipe cmake core args) and enable FORTIFY_SOURCE
|
||||||
|
set(TV2HV_CORE_COMPILE_ARGS "${TV2HV_CORE_COMPILE_ARGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -DNDEBUG")
|
||||||
|
|
||||||
|
# If on Release and we are prompted to use link-time optimizations do so
|
||||||
|
if("lto" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
# On clang we use ThinLTO for even better build performance.
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
message(STATUS "CompilerFlags: Using LLVM ThinLTO")
|
||||||
|
set(TV2HV_CORE_COMPILE_ARGS "${TV2HV_CORE_COMPILE_ARGS} -flto=thin")
|
||||||
|
set(TV2HV_CORE_LINKER_ARGS "${TV2HV_CORE_LINKER_ARGS} -flto=thin")
|
||||||
|
else()
|
||||||
|
message(STATUS "CompilerFlags: Using LTO")
|
||||||
|
set(TV2HV_CORE_COMPILE_ARGS "${TV2HV_CORE_COMPILE_ARGS} -flto")
|
||||||
|
set(TV2HV_CORE_LINKER_ARGS "${TV2HV_CORE_LINKER_ARGS} -flto")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(SanitizerSetup)
|
||||||
|
|
||||||
|
# Set core CMake toolchain variables so that they get applied to all projects.
|
||||||
|
# A bit nasty, but /shrug, this way our third party libraries can be mostly sanitized/etc as well.
|
||||||
|
#
|
||||||
|
# Note that -g3 in release flags is temporary, and will be removed once we don't need it
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${TV2HV_CORE_COMPILE_ARGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS "${TV2HV_CORE_COMPILE_ARGS}")
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
|
||||||
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g3")
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "-O3 -g3")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g3")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -g3")
|
||||||
|
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${TV2HV_CORE_LINKER_ARGS} -Wl,-z,noexecstack,-z,relro,-z,now")
|
||||||
1
cmake/Options.cmake
Normal file
1
cmake/Options.cmake
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Common place for CMake options
|
||||||
22
cmake/Policies.cmake
Normal file
22
cmake/Policies.cmake
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# CMake policy configuration
|
||||||
|
|
||||||
|
# Macro to enable new CMake policy.
|
||||||
|
# Makes this file a *LOT* shorter.
|
||||||
|
macro (_new_cmake_policy policy)
|
||||||
|
if(POLICY ${policy})
|
||||||
|
#message(STATUS "Enabling new policy ${policy}")
|
||||||
|
cmake_policy(SET ${policy} NEW)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
_new_cmake_policy(CMP0026) # CMake 3.0: Disallow use of the LOCATION property for build targets.
|
||||||
|
_new_cmake_policy(CMP0042) # CMake 3.0+ (2.8.12): MacOS "@rpath" in target's install name
|
||||||
|
_new_cmake_policy(CMP0046) # warn about non-existent dependencies
|
||||||
|
_new_cmake_policy(CMP0048) # CMake 3.0+: project() command now maintains VERSION
|
||||||
|
_new_cmake_policy(CMP0054) # CMake 3.1: Only interpret if() arguments as variables or keywords when unquoted.
|
||||||
|
_new_cmake_policy(CMP0056) # try_compile() linker flags
|
||||||
|
_new_cmake_policy(CMP0066) # CMake 3.7: try_compile(): use per-config flags, like CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
_new_cmake_policy(CMP0067) # CMake 3.8: try_compile(): honor language standard variables (like C++11)
|
||||||
|
_new_cmake_policy(CMP0068) # CMake 3.9+: `RPATH` settings on macOS do not affect `install_name`.
|
||||||
|
_new_cmake_policy(CMP0075) # CMake 3.12+: Include file check macros honor `CMAKE_REQUIRED_LIBRARIES`
|
||||||
|
_new_cmake_policy(CMP0077) # CMake 3.13+: option() honors normal variables.
|
||||||
27
cmake/ProjectFuncs.cmake
Normal file
27
cmake/ProjectFuncs.cmake
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
function(tv2hv_target target)
|
||||||
|
target_compile_definitions(${target} PRIVATE "$<$<CONFIG:DEBUG>:TV2HV_DEBUG>")
|
||||||
|
#target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR})
|
||||||
|
target_compile_features(${target} PRIVATE cxx_std_23)
|
||||||
|
target_include_directories(${target} PRIVATE ${PROJECT_SOURCE_DIR}/src/lib ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(_tv2hv_set_alternate_linker)
|
||||||
|
find_program(LINKER_EXECUTABLE ld.${TV2HV_LINKER} ${TV2HV_LINKER})
|
||||||
|
if(LINKER_EXECUTABLE)
|
||||||
|
message(STATUS "Using ${TV2HV_LINKER} as linker")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Linker ${TV2HV_LINKER} does not exist on your system. Please specify one which does or omit this option from your configure command.")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# Set a default linker if the user never provided one.
|
||||||
|
# This defaults based on the detected compiler to the "best" linker possible
|
||||||
|
if(NOT TV2HV_LINKER AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
|
set(TV2HV_LINKER "lld")
|
||||||
|
elseif(NOT TV2HV_LINKER)
|
||||||
|
set(TV2HV_LINKER "bfd")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Do the magic
|
||||||
|
_tv2hv_set_alternate_linker()
|
||||||
34
cmake/SanitizerSetup.cmake
Normal file
34
cmake/SanitizerSetup.cmake
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
set(_TV2HV_CORE_WANTED_SANITIZERS "")
|
||||||
|
|
||||||
|
if("asan" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
# Error if someone's trying to mix asan and tsan together,
|
||||||
|
# they aren't compatible.
|
||||||
|
if("tsan" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
message(FATAL_ERROR "ASAN and TSAN cannot be used together.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Enabling ASAN because it was in TV2HV_BUILD_FEATURES")
|
||||||
|
list(APPEND _TV2HV_CORE_WANTED_SANITIZERS "address")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("tsan" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
if("asan" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
message(FATAL_ERROR "ASAN and TSAN cannot be used together.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Enabling TSAN because it was in TV2HV_BUILD_FEATURES")
|
||||||
|
list(APPEND _TV2HV_CORE_WANTED_SANITIZERS "thread")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("ubsan" IN_LIST TV2HV_BUILD_FEATURES)
|
||||||
|
message(STATUS "Enabling UBSAN because it was in TV2HV_BUILD_FEATURES")
|
||||||
|
list(APPEND _TV2HV_CORE_WANTED_SANITIZERS "undefined")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(LENGTH _TV2HV_CORE_WANTED_SANITIZERS _TV2HV_CORE_WANTED_SANITIZERS_LENGTH)
|
||||||
|
if(NOT _TV2HV_CORE_WANTED_SANITIZERS_LENGTH EQUAL 0)
|
||||||
|
list(JOIN _TV2HV_CORE_WANTED_SANITIZERS "," _TV2HV_CORE_WANTED_SANITIZERS_ARG)
|
||||||
|
message(STATUS "Enabled sanitizers: ${_TV2HV_CORE_WANTED_SANITIZERS_ARG}")
|
||||||
|
set(TV2HV_CORE_COMPILE_ARGS "${TV2HV_CORE_COMPILE_ARGS} -fsanitize=${_TV2HV_CORE_WANTED_SANITIZERS_ARG}")
|
||||||
|
set(TV2HV_CORE_LINKER_ARGS "${TV2HV_CORE_LINKER_ARGS} -fsanitize=${_TV2HV_CORE_WANTED_SANITIZERS_ARG}")
|
||||||
|
endif()
|
||||||
6
src/CMakeLists.txt
Normal file
6
src/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
add_executable(tv2hv
|
||||||
|
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
tv2hv_target(tv2hv)
|
||||||
5
src/main.cpp
Normal file
5
src/main.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user