From 6f5f8e7076e4626cf2f1112ab9076d4495ed1824 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 16 May 2024 23:51:01 +0100 Subject: [PATCH 01/18] Fix FMT library issues --- HarmonyLinkLib/CMakeLists.txt | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 6727506..41e608a 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -16,6 +16,7 @@ project(HarmonyLinkLib VERSION 2.1.0) include(FetchContent) +# Fetch fmt library FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git @@ -23,11 +24,6 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(fmt) -if(NOT fmt_POPULATED) - FetchContent_Populate(fmt) - # Add fmt but exclude it from the ALL target, reducing IDE clutter - add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() set_target_properties(fmt PROPERTIES FOLDER External) set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE TRUE) @@ -55,7 +51,7 @@ endif() configure_file(include/Version.h.in Version.generated.h) # Specify the C++ standard -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) # Define metadata variables @@ -96,6 +92,23 @@ set(COMMON_INCLUDES "src/Utilities.h" ) +# Adding fmt headers explicitly +set(FMT_HEADERS + "${fmt_SOURCE_DIR}/include/fmt/args.h" + "${fmt_SOURCE_DIR}/include/fmt/chrono.h" + "${fmt_SOURCE_DIR}/include/fmt/color.h" + "${fmt_SOURCE_DIR}/include/fmt/compile.h" + "${fmt_SOURCE_DIR}/include/fmt/core.h" + "${fmt_SOURCE_DIR}/include/fmt/format.h" + "${fmt_SOURCE_DIR}/include/fmt/format-inl.h" + "${fmt_SOURCE_DIR}/include/fmt/os.h" + "${fmt_SOURCE_DIR}/include/fmt/ostream.h" + "${fmt_SOURCE_DIR}/include/fmt/printf.h" + "${fmt_SOURCE_DIR}/include/fmt/ranges.h" + "${fmt_SOURCE_DIR}/include/fmt/std.h" + "${fmt_SOURCE_DIR}/include/fmt/xchar.h" +) + set(WINDOWS_SOURCES "src/Platform/Windows/WindowsUtilities.cpp" ) @@ -165,6 +178,9 @@ target_include_directories(HarmonyLinkLibStatic ) target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC) +# Include fmt headers +target_include_directories(HarmonyLinkLibStatic PUBLIC ${FMT_HEADERS}) + # Set output directories for all build types foreach(TYPE IN ITEMS DEBUG RELEASE) string(TOUPPER ${TYPE} TYPE_UPPER) @@ -179,5 +195,5 @@ foreach(TYPE IN ITEMS DEBUG RELEASE) endforeach() # Link fmt library to both shared and static libraries -target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt) -target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt) +target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only) +target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only) From ff303b1277a07910985f8f3b0643dce8f28e36de Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 16 May 2024 23:54:22 +0100 Subject: [PATCH 02/18] Version bump --- HarmonyLinkLib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 41e608a..28fdbd2 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -12,7 +12,7 @@ # limitations under the License. cmake_minimum_required(VERSION 3.10) -project(HarmonyLinkLib VERSION 2.1.0) +project(HarmonyLinkLib VERSION 2.1.1) include(FetchContent) From fa3c03340a6c09aa0ecf16bb4b0cec07d0e2caa3 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 17 May 2024 01:12:12 +0100 Subject: [PATCH 03/18] Fix Unreal Engine Compile error for Linux builds --- HarmonyLinkLib/CMakeLists.txt | 33 ++++++++++++-------------- HarmonyLinkLib/include/Enums/EDevice.h | 3 +++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 28fdbd2..ab02348 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -51,7 +51,7 @@ endif() configure_file(include/Version.h.in Version.generated.h) # Specify the C++ standard -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) # Define metadata variables @@ -94,19 +94,7 @@ set(COMMON_INCLUDES # Adding fmt headers explicitly set(FMT_HEADERS - "${fmt_SOURCE_DIR}/include/fmt/args.h" - "${fmt_SOURCE_DIR}/include/fmt/chrono.h" - "${fmt_SOURCE_DIR}/include/fmt/color.h" - "${fmt_SOURCE_DIR}/include/fmt/compile.h" - "${fmt_SOURCE_DIR}/include/fmt/core.h" - "${fmt_SOURCE_DIR}/include/fmt/format.h" - "${fmt_SOURCE_DIR}/include/fmt/format-inl.h" - "${fmt_SOURCE_DIR}/include/fmt/os.h" - "${fmt_SOURCE_DIR}/include/fmt/ostream.h" - "${fmt_SOURCE_DIR}/include/fmt/printf.h" - "${fmt_SOURCE_DIR}/include/fmt/ranges.h" - "${fmt_SOURCE_DIR}/include/fmt/std.h" - "${fmt_SOURCE_DIR}/include/fmt/xchar.h" + "${fmt_SOURCE_DIR}/include/fmt" ) set(WINDOWS_SOURCES @@ -179,7 +167,7 @@ target_include_directories(HarmonyLinkLibStatic target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC) # Include fmt headers -target_include_directories(HarmonyLinkLibStatic PUBLIC ${FMT_HEADERS}) +target_include_directories(HarmonyLinkLibStatic PRIVATE ${FMT_HEADERS}) # Set output directories for all build types foreach(TYPE IN ITEMS DEBUG RELEASE) @@ -194,6 +182,15 @@ foreach(TYPE IN ITEMS DEBUG RELEASE) ) endforeach() -# Link fmt library to both shared and static libraries -target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only) -target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only) +# Link the fmt library and standard library +target_link_libraries(HarmonyLinkLibStatic + PUBLIC + fmt + stdc++fs +) + +target_link_libraries(HarmonyLinkLibShared + PUBLIC + fmt + stdc++fs +) diff --git a/HarmonyLinkLib/include/Enums/EDevice.h b/HarmonyLinkLib/include/Enums/EDevice.h index f49c7ec..c11919d 100644 --- a/HarmonyLinkLib/include/Enums/EDevice.h +++ b/HarmonyLinkLib/include/Enums/EDevice.h @@ -14,6 +14,9 @@ #pragma once +// Undefine the LINUX macro to avoid conflicts with the enum definition. +#undef LINUX + #include // Enum class for representing different types of devices From 5ac5d8b025548dde906876f1d36b5ab2f2cf1fa4 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 17 May 2024 01:16:16 +0100 Subject: [PATCH 04/18] Remove Macos from github actions workflow --- .github/workflows/cmake-multi-platform.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 95ddb78..3b1b52a 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -24,7 +24,7 @@ jobs: # # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest] # macos-latest build_type: [Release] c_compiler: [gcc, clang, cl] cpp_compiler: [g++, clang++, cl] @@ -50,14 +50,14 @@ jobs: c_compiler: cl - os: ubuntu-latest cpp_compiler: cl - - os: macos-latest - c_compiler: gcc - - os: macos-latest - cpp_compiler: g++ - - os: macos-latest - c_compiler: cl - - os: macos-latest - cpp_compiler: cl + #- os: macos-latest + # c_compiler: gcc + #- os: macos-latest + # cpp_compiler: g++ + #- os: macos-latest + # c_compiler: cl + #- os: macos-latest + # cpp_compiler: cl steps: - uses: actions/checkout@v4 with: From 5ed3a257a7a156ea9e3c32bbe4316a755a143e2c Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 17 May 2024 01:18:05 +0100 Subject: [PATCH 05/18] Forgot mac option --- .github/workflows/cmake-multi-platform.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 3b1b52a..6c5b9f7 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -38,9 +38,9 @@ jobs: - os: ubuntu-latest c_compiler: clang cpp_compiler: clang++ - - os: macos-latest - c_compiler: clang - cpp_compiler: clang++ + #- os: macos-latest + # c_compiler: clang + # cpp_compiler: clang++ exclude: - os: windows-latest c_compiler: gcc From 80d1a0323120675246adae69af61392001dd5f49 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 17 May 2024 01:25:03 +0100 Subject: [PATCH 06/18] Fixed Windows Includes --- HarmonyLinkLib/CMakeLists.txt | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index ab02348..60a7b26 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -182,15 +182,27 @@ foreach(TYPE IN ITEMS DEBUG RELEASE) ) endforeach() -# Link the fmt library and standard library -target_link_libraries(HarmonyLinkLibStatic - PUBLIC - fmt - stdc++fs -) +# Link the fmt library and standard library conditionally +if (UNIX) + target_link_libraries(HarmonyLinkLibStatic + PUBLIC + fmt + stdc++fs + ) -target_link_libraries(HarmonyLinkLibShared - PUBLIC - fmt - stdc++fs -) + target_link_libraries(HarmonyLinkLibShared + PUBLIC + fmt + stdc++fs + ) +elseif (WIN32) + target_link_libraries(HarmonyLinkLibStatic + PUBLIC + fmt + ) + + target_link_libraries(HarmonyLinkLibShared + PUBLIC + fmt + ) +endif() From fa0e30987546012acff3f639d9b6e7c1d5f49e96 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 17 May 2024 01:30:25 +0100 Subject: [PATCH 07/18] Fix includes --- HarmonyLinkLib/CMakeLists.txt | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 60a7b26..03440bf 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -182,27 +182,10 @@ foreach(TYPE IN ITEMS DEBUG RELEASE) ) endforeach() -# Link the fmt library and standard library conditionally +target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt) +target_link_libraries(HarmonyLinkLibShared PRIVATE fmt) + if (UNIX) - target_link_libraries(HarmonyLinkLibStatic - PUBLIC - fmt - stdc++fs - ) - - target_link_libraries(HarmonyLinkLibShared - PUBLIC - fmt - stdc++fs - ) -elseif (WIN32) - target_link_libraries(HarmonyLinkLibStatic - PUBLIC - fmt - ) - - target_link_libraries(HarmonyLinkLibShared - PUBLIC - fmt - ) + target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) + target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) endif() From 18129ac7c25c8592a5b3a11bcac116b928efdeab Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Wed, 22 May 2024 18:56:31 +0100 Subject: [PATCH 08/18] Ignore Idea folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0839667..2e489f4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ build/** # Blacklist specific build directories linuxbuild/ build/ +.idea/ From 7dbe088577b6b78414a61d9d5878e910f2f142ce Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Wed, 22 May 2024 18:59:53 +0100 Subject: [PATCH 09/18] Forgot to add semi-colon to unsupported platform message --- HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp b/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp index 735eeab..555cc10 100644 --- a/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp +++ b/HarmonyLinkLib/src/Platform/IPlatformUtilities.cpp @@ -49,7 +49,7 @@ namespace HarmonyLinkLib INSTANCE = std::make_shared(); // ... other platform checks #else - std::wcout << "Platform is not supported.\n" + std::wcout << "Platform is not supported.\n"; #endif } From 53f661ece8b43d22a08a3ed97ce37d35fb0e65f2 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 24 May 2024 21:05:34 +0100 Subject: [PATCH 10/18] Fix fmt not being included in library --- HarmonyLinkLib/CMakeLists.txt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 03440bf..eb67f49 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -92,11 +92,6 @@ set(COMMON_INCLUDES "src/Utilities.h" ) -# Adding fmt headers explicitly -set(FMT_HEADERS - "${fmt_SOURCE_DIR}/include/fmt" -) - set(WINDOWS_SOURCES "src/Platform/Windows/WindowsUtilities.cpp" ) @@ -166,9 +161,6 @@ target_include_directories(HarmonyLinkLibStatic ) target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC) -# Include fmt headers -target_include_directories(HarmonyLinkLibStatic PRIVATE ${FMT_HEADERS}) - # Set output directories for all build types foreach(TYPE IN ITEMS DEBUG RELEASE) string(TOUPPER ${TYPE} TYPE_UPPER) @@ -182,8 +174,9 @@ foreach(TYPE IN ITEMS DEBUG RELEASE) ) endforeach() -target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt) -target_link_libraries(HarmonyLinkLibShared PRIVATE fmt) +# Link fmt to HarmonyLinkLib +target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only) +target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only) if (UNIX) target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) From 810cea013ea74369664f9709e0024d55e8e756f9 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 24 May 2024 21:08:11 +0100 Subject: [PATCH 11/18] Version Bump --- HarmonyLinkLib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index eb67f49..7146d8e 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -12,7 +12,7 @@ # limitations under the License. cmake_minimum_required(VERSION 3.10) -project(HarmonyLinkLib VERSION 2.1.1) +project(HarmonyLinkLib VERSION 2.1.2) include(FetchContent) From f25ca44f03cef8667052fb2f0a284fde471045e2 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Mon, 27 May 2024 19:09:17 +0100 Subject: [PATCH 12/18] Linux compile working --- .gitignore | 4 ++ Compile.bat | 68 ++++++++++++++++++++++++++++++++ Compile.sh | 73 +++++++++++++++++++++++++++++++++++ HarmonyLinkLib/CMakeLists.txt | 16 +++++++- HarmonyLinkLib/include/Core.h | 12 +++++- 5 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 Compile.bat create mode 100644 Compile.sh diff --git a/.gitignore b/.gitignore index 2e489f4..a7fdac2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,7 @@ build/** linuxbuild/ build/ .idea/ +winbuild/ + +!Compile.sh +!Compile.bat diff --git a/Compile.bat b/Compile.bat new file mode 100644 index 0000000..ccad60c --- /dev/null +++ b/Compile.bat @@ -0,0 +1,68 @@ +@echo off +setlocal enabledelayedexpansion + +REM Clear the screen +cls + +REM Define the color codes +set GREEN= +set NC= + +REM Prompt the user to choose a compiler +echo %GREEN%Select the compiler to use:%NC% +echo 1^ ) MSBuild (default) +echo 2^ ) MinGW +echo 3^ ) Ninja +set /p choice=Enter the number of your choice: + +REM Set the generator and compiler based on the user's choice +if "%choice%"=="2" ( + set "GENERATOR=MinGW Makefiles" + set "COMPILER_OPTION=-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++" +) else if "%choice%"=="3" ( + set "GENERATOR=Ninja" + set "COMPILER_OPTION=" +) else ( + set "GENERATOR=Visual Studio 17 2022" + set "COMPILER_OPTION=-A x64" + set "choice=1" +) + +echo Using generator: %GENERATOR% + +REM Prompt the user to choose a build type +echo %GREEN%Select the build type:%NC% +echo 1^ ) Release (default) +echo 2^ ) Debug +set /p build_choice=Enter the number of your choice: + +REM Set the build type based on the user's choice +if "%build_choice%"=="2" ( + set "BUILD_TYPE=Debug" +) else ( + set "BUILD_TYPE=Release" +) + +echo Build type: %BUILD_TYPE% + +REM Create the build directory if it doesn't exist +if not exist "winbuild" ( + mkdir winbuild +) + +cd winbuild + +REM Get the number of processors +for /f "tokens=2 delims==" %%a in ('wmic cpu get NumberOfLogicalProcessors /value') do set "NUM_PROCESSORS=%%a" + +REM Run CMake with the selected generator and build type +cmake -G "%GENERATOR%" %COMPILER_OPTION% -DCMAKE_BUILD_TYPE=%BUILD_TYPE% .. + +REM Build the project +if "%choice%"=="1" ( + cmake --build . --config %BUILD_TYPE% -- /m:%NUM_PROCESSORS% +) else ( + cmake --build . --config %BUILD_TYPE% -- -j %NUM_PROCESSORS% +) + +cd .. diff --git a/Compile.sh b/Compile.sh new file mode 100644 index 0000000..c8d82ea --- /dev/null +++ b/Compile.sh @@ -0,0 +1,73 @@ +#!/bin/sh + +set -e + +clear + +# Define the color codes +GREEN='\033[0;32m' +NC='\033[0m' # No Color + +# Prompt the user to choose a compiler +echo "${GREEN}Select the compiler to use:${NC}" +echo "1) g++ (default)" +echo "2) clang++" +echo "3) clang++ 15" +echo "4) clang++ 16" +read -p "Enter the number of your choice: " choice + +# Set the compiler based on the user's choice +case $choice in + 2) + C_COMPILER=clang + CXX_COMPILER=clang++ + ;; + 3) + C_COMPILER=clang-15 + CXX_COMPILER=clang++-15 + ;; + 4) + C_COMPILER=clang-16 + CXX_COMPILER=clang++-16 + ;; + *) + C_COMPILER=gcc + CXX_COMPILER=g++ + ;; +esac + +echo "Using C compiler: $C_COMPILER" +echo "Using C++ compiler: $CXX_COMPILER" + +# Prompt the user to choose a build type +echo "${GREEN}Select the build type:${NC}" +echo "1) Release (default)" +echo "2) Debug" +read -p "Enter the number of your choice: " build_choice + +# Set the build type based on the user's choice +case $build_choice in + 2) + BUILD_TYPE=Debug + ;; + *) + BUILD_TYPE=Release + ;; +esac + +echo "Build type: $BUILD_TYPE" + +# Create the build directory if it doesn't exist +if [ ! -d "linuxbuild" ]; then + mkdir linuxbuild +fi + +cd linuxbuild + +# Run CMake with the selected compiler and build type +cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER .. + +# Build the project +cmake --build . --config $BUILD_TYPE --clean-first -j 15 --verbose + +cd .. diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 7146d8e..eba9442 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -120,6 +120,18 @@ set(MAC_INCLUDES "src/Platform/Unix/UnixUtilities.h" ) +# Platform-specific definitions +if(WIN32) + add_definitions(-DBUILD_WINDOWS) +elseif(UNIX) + if(APPLE) + add_definitions(-DBUILD_MACOS) + else() + add_definitions(-DBUILD_LINUX) + endif() + add_definitions(-DBUILD_UNIX) +endif() + # Platform-specific definitions if(WIN32) message(STATUS "Compiling for Windows...") @@ -140,7 +152,7 @@ elseif(UNIX) endif() # Create the shared library -add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES}) +add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES} ${LIB_INCLUDES}) target_include_directories(HarmonyLinkLibShared PRIVATE "${PROJECT_SOURCE_DIR}/src" @@ -151,7 +163,7 @@ target_include_directories(HarmonyLinkLibShared target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED) # Create the static library -add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES}) +add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES} ${LIB_INCLUDES}) target_include_directories(HarmonyLinkLibStatic PRIVATE "${PROJECT_SOURCE_DIR}/src" diff --git a/HarmonyLinkLib/include/Core.h b/HarmonyLinkLib/include/Core.h index 94a32d2..90babed 100644 --- a/HarmonyLinkLib/include/Core.h +++ b/HarmonyLinkLib/include/Core.h @@ -15,7 +15,7 @@ #pragma once // Use a preprocessor definition to switch between export and import declarations -#ifdef _WIN32 +#ifdef BUILD_WINDOWS #ifdef HARMONYLINKLIB_STATIC #define HARMONYLINKLIB_API #else @@ -26,5 +26,13 @@ #endif #endif #else - #define HARMONYLINKLIB_API + #ifdef HARMONYLINKLIB_SHARED + #ifdef __clang__ + #define HARMONYLINKLIB_API __attribute__((visibility("default"))) + #else + #define HARMONYLINKLIB_API + #endif + #else + #define HARMONYLINKLIB_API + #endif #endif From daa49af2476b0733dd4f67897958e7d621d6cb36 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Fri, 31 May 2024 23:43:22 +0100 Subject: [PATCH 13/18] Working in UE4 --- .gitignore | 1 + HarmonyLinkLib/CMakeLists.txt | 1 - HarmonyLinkLib/include/HarmonyLinkLib.h | 16 ++++--- HarmonyLinkLib/src/HarmonyLinkLib.cpp | 13 ++++-- HarmonyLinkLib/src/dllmain.cpp | 61 ------------------------- HarmonyLinkTest/src/main.cpp | 10 +++- 6 files changed, 29 insertions(+), 73 deletions(-) delete mode 100644 HarmonyLinkLib/src/dllmain.cpp diff --git a/.gitignore b/.gitignore index a7fdac2..2e552b2 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ winbuild/ !Compile.sh !Compile.bat +HarmonyLinkLib/.vscode/ diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index eba9442..e61dfb3 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -69,7 +69,6 @@ set(COMMON_SOURCES "src/Platform/IPlatformUtilities.cpp" "src/HarmonyLinkLib.cpp" "src/Version.cpp" - "src/dllmain.cpp" "src/Platform/WineUtilities.cpp" "src/Utilities.cpp" ) diff --git a/HarmonyLinkLib/include/HarmonyLinkLib.h b/HarmonyLinkLib/include/HarmonyLinkLib.h index d6575a5..0298e2d 100644 --- a/HarmonyLinkLib/include/HarmonyLinkLib.h +++ b/HarmonyLinkLib/include/HarmonyLinkLib.h @@ -44,17 +44,19 @@ class IPlatformUtilities; namespace HarmonyLinkLib { - extern "C" HARMONYLINKLIB_API bool get_is_wine(); + HARMONYLINKLIB_API bool HL_Init(); - extern "C" HARMONYLINKLIB_API bool get_is_linux(); + HARMONYLINKLIB_API bool get_is_wine(); - extern "C" HARMONYLINKLIB_API bool get_is_docked(); + HARMONYLINKLIB_API bool get_is_linux(); - extern "C" HARMONYLINKLIB_API FCPUInfo* get_cpu_info(); + HARMONYLINKLIB_API bool get_is_docked(); - extern "C" HARMONYLINKLIB_API FDevice* get_device_info(); + HARMONYLINKLIB_API FCPUInfo* get_cpu_info(); - extern "C" HARMONYLINKLIB_API FOSVerInfo* get_os_version(); + HARMONYLINKLIB_API FDevice* get_device_info(); + + HARMONYLINKLIB_API FOSVerInfo* get_os_version(); - extern "C" HARMONYLINKLIB_API FBattery* get_battery_status(); + HARMONYLINKLIB_API FBattery* get_battery_status(); } diff --git a/HarmonyLinkLib/src/HarmonyLinkLib.cpp b/HarmonyLinkLib/src/HarmonyLinkLib.cpp index 91ccc2c..f57feac 100644 --- a/HarmonyLinkLib/src/HarmonyLinkLib.cpp +++ b/HarmonyLinkLib/src/HarmonyLinkLib.cpp @@ -16,10 +16,19 @@ #include #include "Platform/IPlatformUtilities.h" +#include "Version.h" namespace HarmonyLinkLib { - std::shared_ptr PlatformUtilities = IPlatformUtilities::GetInstance(); + std::shared_ptr PlatformUtilities = nullptr; + + bool HL_Init() + { + std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n"; + PlatformUtilities = IPlatformUtilities::GetInstance(); + + return PlatformUtilities != nullptr; + } bool get_is_wine() { @@ -92,8 +101,6 @@ namespace HarmonyLinkLib FOSVerInfo* get_os_version() { - - if (!PlatformUtilities) { std::wcout << "Failed to get platform utilities!\n"; diff --git a/HarmonyLinkLib/src/dllmain.cpp b/HarmonyLinkLib/src/dllmain.cpp deleted file mode 100644 index 5e6df48..0000000 --- a/HarmonyLinkLib/src/dllmain.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) 2024 Jordon Brooks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include "Version.h" - -namespace HarmonyLinkLib -{ - void HarmonyLinkInit() - { - std::wcout << "HarmonyLink V" << version::ToString().c_str() << " Copyright (C) 2023 Jordon Brooks\n"; - } -} - - -#if BUILD_WINDOWS -#include - -// Standard DLL entry point -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - // Code to run when the DLL is loaded - HarmonyLinkLib::HarmonyLinkInit(); - break; - case DLL_THREAD_ATTACH: - // Code to run when a thread is created during the DLL's lifetime - case DLL_THREAD_DETACH: - // Code to run when a thread ends normally. - case DLL_PROCESS_DETACH: - // Code to run when the DLL is unloaded - default: - break; - } - return TRUE; // Successful DLL_PROCESS_ATTACH. -} -#endif - -#if BUILD_UNIX -__attribute__((constructor)) -static void onLibraryLoad() { - // Code to run when the library is loaded - HarmonyLinkLib::HarmonyLinkInit(); -} - -__attribute__((destructor)) -static void onLibraryUnload() { - // Code to run when the library is unloaded -} -#endif diff --git a/HarmonyLinkTest/src/main.cpp b/HarmonyLinkTest/src/main.cpp index e9eaf87..d4d2d29 100644 --- a/HarmonyLinkTest/src/main.cpp +++ b/HarmonyLinkTest/src/main.cpp @@ -85,10 +85,18 @@ void checkForQuit() { int main() { - std::cout << "Hello, World!" << '\n'; + std::cout << "Hello, World!\n"; std::thread inputThread(checkForQuit); + if (!HarmonyLinkLib::HL_Init()) + { + std::cout << "Failed to init HarmonyLinkLib\n"; + return 1; + } + + std::cout << "HarmonyLinkLib successfully initialised!\n"; + const bool isWine = HarmonyLinkLib::get_is_wine(); const char* test = isWine ? "is" : "isn't"; From 9a1e6f24b1ddf2a66e3d7a6cf3388fb9bc86e15e Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 6 Jun 2024 16:04:11 +0100 Subject: [PATCH 14/18] Fix clang compiler error --- CMakeLists.txt | 12 +++---- HarmonyLinkLib/CMakeLists.txt | 64 ++++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02296e9..a394d22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,12 +44,12 @@ elseif(UNIX) endif() # Set global output directories for all build types -foreach(TYPE IN ITEMS DEBUG RELEASE) - string(TOUPPER ${TYPE} TYPE_UPPER) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}") - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}") -endforeach() +#foreach(TYPE IN ITEMS DEBUG RELEASE) +# string(TOUPPER ${TYPE} TYPE_UPPER) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}") +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}") +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}") +#endforeach() # Add the library and executable directories diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index e61dfb3..2e2ed12 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -12,7 +12,7 @@ # limitations under the License. cmake_minimum_required(VERSION 3.10) -project(HarmonyLinkLib VERSION 2.1.2) +project(HarmonyLinkLib VERSION 2.1.2 LANGUAGES CXX) include(FetchContent) @@ -150,6 +150,14 @@ elseif(UNIX) endif() endif() +# Detect the compiler name +get_filename_component(COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME) + +# Replace forbidden characters in file names (optional, if needed) +string(REPLACE "." "_" COMPILER_NAME ${COMPILER_NAME}) +string(REPLACE "/" "_" COMPILER_NAME ${COMPILER_NAME}) +string(REPLACE "\\" "_" COMPILER_NAME ${COMPILER_NAME}) + # Create the shared library add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES} ${LIB_INCLUDES}) target_include_directories(HarmonyLinkLibShared @@ -160,6 +168,7 @@ target_include_directories(HarmonyLinkLibShared "${PROJECT_SOURCE_DIR}/include" ) target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED) +set_target_properties(HarmonyLinkLibShared PROPERTIES OUTPUT_NAME "HarmonyLinkLibShared_${COMPILER_NAME}") # Create the static library add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES} ${LIB_INCLUDES}) @@ -171,25 +180,54 @@ target_include_directories(HarmonyLinkLibStatic "${PROJECT_SOURCE_DIR}/include" ) target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC) +set_target_properties(HarmonyLinkLibStatic PROPERTIES OUTPUT_NAME "HarmonyLinkLibStatic_${COMPILER_NAME}") # Set output directories for all build types -foreach(TYPE IN ITEMS DEBUG RELEASE) - string(TOUPPER ${TYPE} TYPE_UPPER) - set_target_properties(HarmonyLinkLibShared PROPERTIES - RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkLib" - LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkLib" - ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLib" - ) - set_target_properties(HarmonyLinkLibStatic PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLibStatic" - ) -endforeach() +#foreach(TYPE IN ITEMS DEBUG RELEASE) +# string(TOUPPER ${TYPE} TYPE_UPPER) +# set_target_properties(HarmonyLinkLibShared PROPERTIES +# RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/HarmonyLinkLib" +# LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/HarmonyLinkLib" +# ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLib" +# ) +# set_target_properties(HarmonyLinkLibStatic PROPERTIES +# ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/HarmonyLinkLibStatic" +# ) +#endforeach() # Link fmt to HarmonyLinkLib target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only) target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only) -if (UNIX) +# Determine the compiler and set appropriate flags for libc++ +if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Use libc++ instead of libstdc++ with Clang + target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) + target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) + target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) + target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) + + # Ensure the proper include paths for libc++ + target_include_directories(HarmonyLinkLibStatic SYSTEM PRIVATE + /usr/include/c++/v1 + /usr/local/include/c++/v1 + /usr/include + ) + target_include_directories(HarmonyLinkLibShared SYSTEM PRIVATE + /usr/include/c++/v1 + /usr/local/include/c++/v1 + /usr/include + ) + + # Link against the libc++ library and the filesystem library + target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental) + target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental) +elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") + # Use libstdc++ with GCC + target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++) + target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++) + + # Link against the libstdc++ filesystem library if necessary target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) endif() From 7f0fa0b90d7464378b6d0941cab930e60b2e9b3c Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 6 Jun 2024 16:04:34 +0100 Subject: [PATCH 15/18] Improved Compile.sh --- Compile.sh | 134 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 40 deletions(-) diff --git a/Compile.sh b/Compile.sh index c8d82ea..63ea1c3 100644 --- a/Compile.sh +++ b/Compile.sh @@ -1,49 +1,96 @@ -#!/bin/sh +#!/bin/bash set -e clear -# Define the color codes +# Define color codes GREEN='\033[0;32m' NC='\033[0m' # No Color +PURPLE='\033[0;35m' +GRAY='\033[1;30m' -# Prompt the user to choose a compiler -echo "${GREEN}Select the compiler to use:${NC}" -echo "1) g++ (default)" -echo "2) clang++" -echo "3) clang++ 15" -echo "4) clang++ 16" -read -p "Enter the number of your choice: " choice +# Ensure dialog is installed +if ! command -v dialog &> /dev/null +then + echo "dialog could not be found. Please install it to use this script." + exit +fi -# Set the compiler based on the user's choice -case $choice in - 2) - C_COMPILER=clang - CXX_COMPILER=clang++ - ;; - 3) - C_COMPILER=clang-15 - CXX_COMPILER=clang++-15 - ;; - 4) - C_COMPILER=clang-16 - CXX_COMPILER=clang++-16 - ;; - *) - C_COMPILER=gcc - CXX_COMPILER=g++ - ;; -esac +# Function to check if a compiler is installed +check_compiler() { + if command -v $1 &> /dev/null + then + COMPILER_OPTIONS+=("$2" "$3" "$4") + fi +} -echo "Using C compiler: $C_COMPILER" -echo "Using C++ compiler: $CXX_COMPILER" +# Array to store the menu options +COMPILER_OPTIONS=() + +# Add available compilers to the options array +check_compiler g++ "1" "g++ (default)" "on" +check_compiler clang++ "2" "clang++" "off" +check_compiler clang++-15 "3" "clang++ 15" "off" +check_compiler clang++-16 "4" "clang++ 16" "off" +check_compiler clang++-17 "5" "clang++ 17" "off" + +# Debug: print the compiler options +echo "Compiler options: ${COMPILER_OPTIONS[@]}" + +# Check if any compilers are available +if [ ${#COMPILER_OPTIONS[@]} -eq 0 ]; then + dialog --msgbox "No compilers found. Please install a compiler to use this script." 10 40 + exit +fi + +# Prompt the user to choose one or more compilers +compiler_choices=$(dialog --colors --title "\Zb\Z5Select Compiler\Zn" --checklist "\nChoose one or more compilers:" 15 60 ${#COMPILER_OPTIONS[@]} "${COMPILER_OPTIONS[@]}" 3>&1 1>&2 2>&3) + +# Process the selected compilers +C_COMPILERS=() +CXX_COMPILERS=() + +# Debug: print the compiler choices +echo "Compiler choices: $compiler_choices" + +for choice in $compiler_choices; do + case $choice in + 1) + C_COMPILERS+=("gcc") + CXX_COMPILERS+=("g++") + ;; + 2) + C_COMPILERS+=("clang") + CXX_COMPILERS+=("clang++") + ;; + 3) + C_COMPILERS+=("clang-15") + CXX_COMPILERS+=("clang++-15") + ;; + 4) + C_COMPILERS+=("clang-16") + CXX_COMPILERS+=("clang++-16") + ;; + 5) + C_COMPILERS+=("clang-17") + CXX_COMPILERS+=("clang++-17") + ;; + esac +done + +# Output the chosen compilers +msg="Chosen compilers:\n" +for i in "${!C_COMPILERS[@]}"; do + msg+="C compiler: ${C_COMPILERS[$i]}, C++ compiler: ${CXX_COMPILERS[$i]}\n" +done + +dialog --colors --msgbox "\Zb\Z5$msg\Zn" 20 60 # Prompt the user to choose a build type -echo "${GREEN}Select the build type:${NC}" -echo "1) Release (default)" -echo "2) Debug" -read -p "Enter the number of your choice: " build_choice +build_choice=$(dialog --colors --title "\Zb\Z5Select Build Type\Zn" --menu "\nChoose a build type:" 10 40 2 \ +1 "Release (default)" \ +2 "Debug" 3>&1 1>&2 2>&3) # Set the build type based on the user's choice case $build_choice in @@ -55,7 +102,10 @@ case $build_choice in ;; esac -echo "Build type: $BUILD_TYPE" +# Output the chosen build type +dialog --colors --msgbox "\Zb\Z5Build type:\Zn $BUILD_TYPE" 10 40 + +clear # Create the build directory if it doesn't exist if [ ! -d "linuxbuild" ]; then @@ -64,10 +114,14 @@ fi cd linuxbuild -# Run CMake with the selected compiler and build type -cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER .. - -# Build the project -cmake --build . --config $BUILD_TYPE --clean-first -j 15 --verbose +# Run CMake with the selected compilers and build type +for i in "${!C_COMPILERS[@]}"; do + cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_COMPILER=${C_COMPILERS[$i]} -DCMAKE_CXX_COMPILER=${CXX_COMPILERS[$i]} .. + # Build the project + cmake --build . --config $BUILD_TYPE -j 15 #--clean-first #--verbose +done cd .. + +# End with a success message +dialog --colors --msgbox "\Zb\Z5Build(s) completed successfully!\Zn" 10 40 From a7a80571ea304f1fa9baeb89f5a17194593b9853 Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 6 Jun 2024 19:20:29 +0100 Subject: [PATCH 16/18] Remove stdc++fs requirement by using an external library --- .gitattributes | 5 +- HarmonyLinkLib/CMakeLists.txt | 78 +++++++++++-------- HarmonyLinkLib/src/Platform/WineUtilities.cpp | 6 +- 3 files changed, 55 insertions(+), 34 deletions(-) diff --git a/.gitattributes b/.gitattributes index 970e13f..92bbb8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -36,4 +36,7 @@ # Executables *.exe binary *.out binary -*.app binary \ No newline at end of file +*.app binary + +# Linux shell files must always be LF +*.sh text eol=lf \ No newline at end of file diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 2e2ed12..311eed3 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -28,6 +28,18 @@ FetchContent_MakeAvailable(fmt) set_target_properties(fmt PROPERTIES FOLDER External) set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE TRUE) +# Fetch ghc library +FetchContent_Declare( + ghc_filesystem + GIT_REPOSITORY https://github.com/gulrak/filesystem.git + GIT_TAG v1.5.14 # Specify the desired version of ghc +) + +FetchContent_MakeAvailable(ghc_filesystem) + +set_target_properties(ghc_filesystem PROPERTIES FOLDER External) +set_target_properties(ghc_filesystem PROPERTIES POSITION_INDEPENDENT_CODE TRUE) + # Find the current Git branch and the last commit timestamp find_package(Git QUIET) if(GIT_FOUND) @@ -199,35 +211,39 @@ set_target_properties(HarmonyLinkLibStatic PROPERTIES OUTPUT_NAME "HarmonyLinkLi target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt-header-only) target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt-header-only) +# Link ghc to HarmonyLinkLib +target_link_libraries(HarmonyLinkLibStatic PRIVATE ghc_filesystem) +target_link_libraries(HarmonyLinkLibShared PRIVATE ghc_filesystem) + # Determine the compiler and set appropriate flags for libc++ -if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Use libc++ instead of libstdc++ with Clang - target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) - target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) - target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) - target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) - - # Ensure the proper include paths for libc++ - target_include_directories(HarmonyLinkLibStatic SYSTEM PRIVATE - /usr/include/c++/v1 - /usr/local/include/c++/v1 - /usr/include - ) - target_include_directories(HarmonyLinkLibShared SYSTEM PRIVATE - /usr/include/c++/v1 - /usr/local/include/c++/v1 - /usr/include - ) - - # Link against the libc++ library and the filesystem library - target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental) - target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental) -elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") - # Use libstdc++ with GCC - target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++) - target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++) - - # Link against the libstdc++ filesystem library if necessary - target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) - target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) -endif() +#if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") +# # Use libc++ instead of libstdc++ with Clang +# target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) +# target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) +# target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) +# target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) +# +# # Ensure the proper include paths for libc++ +# target_include_directories(HarmonyLinkLibStatic SYSTEM PRIVATE +# /usr/include/c++/v1 +# /usr/local/include/c++/v1 +# /usr/include +# ) +# target_include_directories(HarmonyLinkLibShared SYSTEM PRIVATE +# /usr/include/c++/v1 +# /usr/local/include/c++/v1 +# /usr/include +# ) +# +# # Link against the libc++ library and the filesystem library +# target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental) +# target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental) +#elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") +# # Use libstdc++ with GCC +# target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++) +# target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++) +# +# # Link against the libstdc++ filesystem library if necessary +# target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) +# target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) +#endif() diff --git a/HarmonyLinkLib/src/Platform/WineUtilities.cpp b/HarmonyLinkLib/src/Platform/WineUtilities.cpp index efe48a3..fca7352 100644 --- a/HarmonyLinkLib/src/Platform/WineUtilities.cpp +++ b/HarmonyLinkLib/src/Platform/WineUtilities.cpp @@ -18,12 +18,14 @@ #include #include #include -#include +#include #ifdef BUILD_WINDOWS #include #endif +namespace fs = ghc::filesystem; + namespace HarmonyLinkLib { bool force_detect_wine = false; @@ -38,7 +40,7 @@ namespace HarmonyLinkLib FBattery result = {}; for (int i = 0; i <= 9; ++i) { - if (std::string bat_path = append + "/sys/class/power_supply/BAT" + std::to_string(i); std::filesystem::exists(bat_path)) { + if (std::string bat_path = append + "/sys/class/power_supply/BAT" + std::to_string(i); fs::exists(bat_path)) { result.has_battery = true; std::ifstream status_file(bat_path + "/status"); From 416fdb3bdbd5addd6880e62e06daa9fa046c0b0e Mon Sep 17 00:00:00 2001 From: Jordon Brooks Date: Thu, 6 Jun 2024 20:06:09 +0100 Subject: [PATCH 17/18] UE4 Linux successful compile --- HarmonyLinkLib/CMakeLists.txt | 50 +++++++++++++---------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/HarmonyLinkLib/CMakeLists.txt b/HarmonyLinkLib/CMakeLists.txt index 311eed3..de087b6 100644 --- a/HarmonyLinkLib/CMakeLists.txt +++ b/HarmonyLinkLib/CMakeLists.txt @@ -216,34 +216,22 @@ target_link_libraries(HarmonyLinkLibStatic PRIVATE ghc_filesystem) target_link_libraries(HarmonyLinkLibShared PRIVATE ghc_filesystem) # Determine the compiler and set appropriate flags for libc++ -#if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") -# # Use libc++ instead of libstdc++ with Clang -# target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) -# target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) -# target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) -# target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) -# -# # Ensure the proper include paths for libc++ -# target_include_directories(HarmonyLinkLibStatic SYSTEM PRIVATE -# /usr/include/c++/v1 -# /usr/local/include/c++/v1 -# /usr/include -# ) -# target_include_directories(HarmonyLinkLibShared SYSTEM PRIVATE -# /usr/include/c++/v1 -# /usr/local/include/c++/v1 -# /usr/include -# ) -# -# # Link against the libc++ library and the filesystem library -# target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental) -# target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental) -#elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") -# # Use libstdc++ with GCC -# target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++) -# target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++) -# -# # Link against the libstdc++ filesystem library if necessary -# target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) -# target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) -#endif() +if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Use libc++ instead of libstdc++ with Clang + target_compile_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) + target_compile_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) + target_link_options(HarmonyLinkLibStatic PRIVATE -stdlib=libc++) + target_link_options(HarmonyLinkLibShared PRIVATE -stdlib=libc++) + + # Link against the libc++ library and the filesystem library + target_link_libraries(HarmonyLinkLibStatic PRIVATE c++ c++abi c++experimental) + target_link_libraries(HarmonyLinkLibShared PRIVATE c++ c++abi c++experimental) +elseif (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "GNU") + # Use libstdc++ with GCC + target_link_options(HarmonyLinkLibStatic PRIVATE -static-libgcc -static-libstdc++) + target_link_options(HarmonyLinkLibShared PRIVATE -static-libgcc -static-libstdc++) + + # Link against the libstdc++ filesystem library if necessary + #target_link_libraries(HarmonyLinkLibStatic PRIVATE stdc++fs) + #target_link_libraries(HarmonyLinkLibShared PRIVATE stdc++fs) +endif() From cb84f3dff845286163f73d6baf566fd128076b59 Mon Sep 17 00:00:00 2001 From: jordon Date: Sun, 4 May 2025 14:28:55 +0100 Subject: [PATCH 18/18] Updated links --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 81a55f2..f8a5b5e 100644 --- a/README.md +++ b/README.md @@ -61,22 +61,22 @@ As you can see, Even though it's running on Proton, we can still detect the unde Integrate HarmonyLink 2.0 into your game project with ease: -1. Download the latest version of HarmonyLink 2.0 from the [releases page](https://github.com/Jordonbc/HarmonyLink/releases/latest). +1. Download the latest version of HarmonyLink 2.0 from the [releases page](https://git.bbgames.dev/jordon/HarmonyLink/releases/latest). 2. Add the HarmonyLink DLL to your project according to your development environment's specifications. 3. Utilize the provided API to access device-specific metrics and enhance your game's performance on handheld devices. -Refer to the [integration documentation](https://github.com/Jordonbc/HarmonyLink/wiki/Integration-Guide) for detailed instructions. +Refer to the [integration documentation](https://git.bbgames.dev/jordon/HarmonyLink/wiki) for detailed instructions. ### Unreal Engine 5 Plugin For developers leveraging Unreal Engine 5.3 or newer*, HarmonyLink 2.0 is readily accessible as a plugin: -1. Clone or download the HarmonyLink UE5 Plugin from the [Unreal Engine Plugin repository](https://github.com/Jordonbc/HarmonyLinkUE). +1. Clone or download the HarmonyLink UE5 Plugin from the [Unreal Engine Plugin repository](https://git.bbgames.dev/jordon/HarmonyLinkUE). 2. Place the HarmonyLink plugin folder into the `Plugins` directory of your Unreal Engine 5 project. 3. Enable the HarmonyLink plugin from the Edit > Plugins menu within Unreal Engine 5. 4. Access HarmonyLink functionalities via Blueprints or C++ within your project. -For a step-by-step guide, visit the [Unreal Engine 5 Plugin instructions](https://github.com/Jordonbc/HarmonyLinkUE/wiki/Integration-Guide) on our wiki. +For a step-by-step guide, visit the [Unreal Engine 5 Plugin instructions](https://git.bbgames.dev/jordon/HarmonyLinkUE/wiki) on our wiki. *With potential backward compatibility, not verified. @@ -91,7 +91,7 @@ If you prefer to build HarmonyLink 2.0 from the source code, follow these steps: 5. Compile the code by running `cmake --build build --config Release`. 6. The built DLL will be located in the `build/bin/HarmonyLinkLib` directory. -For additional building options and troubleshooting, refer to the [building from source documentation](https://github.com/Jordonbc/HarmonyLink/wiki/Building-From-Source). +For additional building options and troubleshooting, refer to the [building from source documentation](https://git.bbgames.dev/jordon/HarmonyLink/wiki). ## How It Works