Added static library linking
This commit is contained in:
parent
2eb90cf021
commit
d6fcb24863
6 changed files with 171 additions and 42 deletions
|
@ -1,3 +1,16 @@
|
|||
# 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.
|
||||
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(HarmonyLinkLib VERSION 2.0.0)
|
||||
|
||||
|
@ -45,6 +58,16 @@ configure_file(include/Version.h.in Version.generated.h)
|
|||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Define metadata variables
|
||||
set(FILE_DESCRIPTION "Enhances handheld gaming with intelligent hardware recognition, dynamic adaptability, and robust API access for Windows and Linux, including Steam Deck and Wine support.")
|
||||
set(INTERNAL_NAME "HarmonyLinkLib")
|
||||
set(ORIGINAL_FILENAME "HarmonyLinkLib.dll")
|
||||
set(PRODUCT_NAME "HarmonyLinkLib")
|
||||
set(COMMENTS "")
|
||||
|
||||
# Configure version.rc file for shared library
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Resources/Version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
||||
|
||||
# Explicitly list source files
|
||||
set(COMMON_SOURCES
|
||||
"src/Platform/IPlatformUtilities.cpp"
|
||||
|
@ -58,24 +81,19 @@ set(COMMON_SOURCES
|
|||
# Explicitly list include files
|
||||
set(COMMON_INCLUDES
|
||||
"include/Core.h"
|
||||
|
||||
"include/Structs/FBattery.h"
|
||||
"include/Structs/FOSVerInfo.h"
|
||||
"include/Structs/FDevice.h"
|
||||
"include/Structs/FCPUInfo.h"
|
||||
|
||||
"include/Enums/EDevice.h"
|
||||
"include/Enums/EPlatform.h"
|
||||
"include/Enums/ESteamDeck.h"
|
||||
|
||||
"include/FString.h"
|
||||
"include/HarmonyLinkLib.h"
|
||||
"include/Version.h"
|
||||
|
||||
"src/Platform/IPlatformUtilities.h"
|
||||
"src/Platform/WineUtilities.h"
|
||||
|
||||
"src//Utilities.h"
|
||||
"src/Utilities.h"
|
||||
)
|
||||
|
||||
set(WINDOWS_SOURCES
|
||||
|
@ -111,41 +129,55 @@ if(WIN32)
|
|||
message(STATUS "Compiling for Windows...")
|
||||
list(APPEND LIB_SOURCES ${COMMON_SOURCES} ${WINDOWS_SOURCES})
|
||||
list(APPEND LIB_INCLUDES ${COMMON_INCLUDES} ${WINDOWS_INCLUDES})
|
||||
list(APPEND SHARED_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||
elseif(UNIX)
|
||||
message(STATUS "Compiling for Unix-based systems...")
|
||||
if(APPLE)
|
||||
message(STATUS "Compiling for Mac...")
|
||||
list(APPEND LIB_SOURCES ${COMMON_SOURCES} ${MAC_SOURCES})
|
||||
list(APPEND LIB_INCLUDES ${COMMON_INCLUDES} ${MAC_INCLUDES})
|
||||
else()
|
||||
message(STATUS "Compiling for Linux...")
|
||||
list(APPEND LIB_SOURCES ${COMMON_SOURCES} ${LINUX_SOURCES})
|
||||
list(APPEND LIB_INCLUDES ${COMMON_INCLUDES} ${LINUX_INCLUDES})
|
||||
endif()
|
||||
message(STATUS "Compiling for Unix-based systems...")
|
||||
if(APPLE)
|
||||
message(STATUS "Compiling for Mac...")
|
||||
list(APPEND LIB_SOURCES ${COMMON_SOURCES} ${MAC_SOURCES})
|
||||
list(APPEND LIB_INCLUDES ${COMMON_INCLUDES} ${MAC_INCLUDES})
|
||||
else()
|
||||
message(STATUS "Compiling for Linux...")
|
||||
list(APPEND LIB_SOURCES ${COMMON_SOURCES} ${LINUX_SOURCES})
|
||||
list(APPEND LIB_INCLUDES ${COMMON_INCLUDES} ${LINUX_INCLUDES})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Add library
|
||||
add_library(HarmonyLinkLib SHARED ${LIB_SOURCES} ${LIB_INCLUDES})
|
||||
|
||||
target_include_directories(HarmonyLinkLib
|
||||
# Create the shared library
|
||||
add_library(HarmonyLinkLibShared SHARED ${LIB_SOURCES} ${SHARED_SOURCES})
|
||||
target_include_directories(HarmonyLinkLibShared
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
PUBLIC
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
)
|
||||
target_compile_definitions(HarmonyLinkLibShared PRIVATE HARMONYLINKLIB_SHARED)
|
||||
|
||||
target_compile_definitions(HarmonyLinkLib PRIVATE HARMONYLINKLIB_EXPORTS)
|
||||
# Create the static library
|
||||
add_library(HarmonyLinkLibStatic STATIC ${LIB_SOURCES})
|
||||
target_include_directories(HarmonyLinkLibStatic
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/src"
|
||||
PUBLIC
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
)
|
||||
target_compile_definitions(HarmonyLinkLibStatic PRIVATE HARMONYLINKLIB_STATIC)
|
||||
|
||||
# Set output directories for all build types
|
||||
foreach(TYPE IN ITEMS DEBUG RELEASE)
|
||||
string(TOUPPER ${TYPE} TYPE_UPPER)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/bin/${TYPE}/${PROJECT_NAME}"
|
||||
LIBRARY_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/lib/${TYPE}/${PROJECT_NAME}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY_${TYPE_UPPER} "${CMAKE_BINARY_DIR}/archive/${TYPE}/${PROJECT_NAME}"
|
||||
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 library
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)
|
||||
# Link fmt library to both shared and static libraries
|
||||
target_link_libraries(HarmonyLinkLibShared PRIVATE fmt::fmt)
|
||||
target_link_libraries(HarmonyLinkLibStatic PRIVATE fmt::fmt)
|
||||
|
|
49
HarmonyLinkLib/Resources/Version.rc.in
Normal file
49
HarmonyLinkLib/Resources/Version.rc.in
Normal file
|
@ -0,0 +1,49 @@
|
|||
// 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 <windows.h>
|
||||
#include <winver.h>
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0
|
||||
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
FILEFLAGS 0x0L
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904b0"
|
||||
{
|
||||
VALUE "CompanyName", "N/A"
|
||||
VALUE "FileDescription", "@FILE_DESCRIPTION@"
|
||||
VALUE "FileVersion", "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0"
|
||||
VALUE "InternalName", "@INTERNAL_NAME@"
|
||||
VALUE "OriginalFilename", "@ORIGINAL_FILENAME@"
|
||||
VALUE "ProductName", "@PRODUCT_NAME@"
|
||||
VALUE "ProductVersion", "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0"
|
||||
VALUE "Comments", "@COMMENTS@"
|
||||
VALUE "LegalCopyright", "N/A"
|
||||
VALUE "LegalTrademarks", "N/A"
|
||||
VALUE "PrivateBuild", "N/A"
|
||||
VALUE "SpecialBuild", "N/A"
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x409, 1200
|
||||
}
|
||||
}
|
|
@ -16,10 +16,14 @@
|
|||
|
||||
// Use a preprocessor definition to switch between export and import declarations
|
||||
#ifdef _WIN32
|
||||
#ifdef HARMONYLINKLIB_EXPORTS
|
||||
#define HARMONYLINKLIB_API __declspec(dllexport)
|
||||
#ifdef HARMONYLINKLIB_STATIC
|
||||
#define HARMONYLINKLIB_API
|
||||
#else
|
||||
#define HARMONYLINKLIB_API __declspec(dllimport)
|
||||
#ifdef HARMONYLINKLIB_SHARED
|
||||
#define HARMONYLINKLIB_API __declspec(dllexport)
|
||||
#else
|
||||
#define HARMONYLINKLIB_API __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define HARMONYLINKLIB_API
|
||||
|
|
|
@ -23,3 +23,7 @@
|
|||
|
||||
#define GIT_BRANCH_NAME "@GIT_BRANCH_NAME@"
|
||||
#define GIT_COMMIT_TIMESTAMP "@GIT_COMMIT_TIMESTAMP@"
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <winver.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue