Skip to content

Commit e0ab7e6

Browse files
authored
Merge pull request #5 from Creative-Rift/feature/library
Feature/library
2 parents 4c7e2ec + fa30576 commit e0ab7e6

5 files changed

Lines changed: 67 additions & 16 deletions

File tree

.github/workflows/Test_windows.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ on:
1212

1313
env:
1414
BUILD_TYPE: Release
15+
VERSION_NAME: 1.1
1516

1617
jobs:
17-
Test_windows:
18+
Build_exec:
1819
runs-on: windows-latest
1920
steps:
2021
- name: Checkout repository
@@ -34,4 +35,48 @@ jobs:
3435
uses: actions/upload-artifact@v3
3536
with:
3637
name: SWPacker
37-
path: ${{github.workspace}}\out\1.1\Release\
38+
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\
39+
40+
Build_Unpack_Shared:
41+
runs-on: windows-latest
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v4
45+
46+
- name: Config executables
47+
run: |
48+
mkdir build && cd build
49+
cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_SHARED=ON ..
50+
51+
- name: Build executables
52+
run: |
53+
cd ${{github.workspace}}\build
54+
cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}}
55+
56+
- name: Archive Library
57+
uses: actions/upload-artifact@v3
58+
with:
59+
name: SWPacker
60+
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\
61+
62+
Build_Unpack_Static:
63+
runs-on: windows-latest
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
68+
- name: Config executables
69+
run: |
70+
mkdir build && cd build
71+
cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_STATIC=ON ..
72+
73+
- name: Build executables
74+
run: |
75+
cd ${{github.workspace}}\build
76+
cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}}
77+
78+
- name: Archive library
79+
uses: actions/upload-artifact@v3
80+
with:
81+
name: SWPacker
82+
path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ message(${PREFIX_MESSAGE} "Project location: " ${CMAKE_SOURCE_DIR})
3232
message(${PREFIX_MESSAGE} "Project system: " ${CMAKE_SYSTEM_NAME})
3333

3434
option(SWFP_COMP "Define if the packer will enable compact process" )
35+
option(BUILD_UNPACK_LIB_SHARED "Define if Unpacker is build as a library as shared" )
36+
option(BUILD_UNPACK_LIB_STATIC "Define if Unpacker is build as a library as static" )
3537

3638
## IMPORTED STATIC LIBRARY NAME
3739
set( STATIC_LIB_NAME
@@ -45,7 +47,6 @@ list(LENGTH STATIC_LIB_NAME list_len)
4547
math(EXPR LIST_LEN "${list_len} - 1")
4648

4749
if (${LIST_LEN} GREATER_EQUAL 0)
48-
4950
foreach(ctr RANGE ${LIST_LEN})
5051
list(GET STATIC_LIB_NAME ${ctr} lib)
5152
list(GET STATIC_LIB ${ctr} filelib)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ cmake --build . --target SWEngine-[packer/unpacker]_1.1 --config [Debug/Release]
1414
You can define an option by using : `-D[option]=[value]`
1515
- CMAKE_BUILD_TYPE: Debug/Release
1616
- SWFP_COMP: ON/OFF
17+
- BUILD_UNPACK_LIB_SHARED: ON/OFF
18+
- BUILD_UNPACK_LIB_STATIC: ON/OFF
1719

1820
## Usage
1921
### Packer

cmake/Packer.cmake

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,6 @@ if(MSVC)
5959
endif()
6060
## <=====================================>
6161

62-
## IMPORTED STATIC LIBRARY NAME
63-
set( STATIC_LIB_NAME
64-
zstd_static
65-
)
66-
67-
## IMPORTED STATIC LIBRARY .lib file
68-
set( STATIC_LIB
69-
${CMAKE_SOURCE_DIR}/libraries/zstd_static.lib
70-
)
71-
7262
## STATIC LIBRARY LINKING
7363
## <=====================================>
7464
if (${STATIC_LIB_NAME})

cmake/UnPacker.cmake

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,21 @@ file(GLOB SRC ${TMP})
3636

3737
## OUTPUT
3838
## <=====================================>
39-
## EXECUTABLE
40-
add_executable(${EXEC} ${SRC})
39+
40+
if (NOT ${BUILD_UNPACK_LIB_SHARED} AND NOT ${BUILD_UNPACK_LIB_STATIC})
41+
## EXECUTABLE
42+
add_executable(${EXEC} ${SRC})
43+
message(${PREFIX_MESSAGE} "Unpacker build as executable")
44+
elseif (${BUILD_UNPACK_LIB_SHARED})
45+
## SHARED LIB
46+
add_library(${EXEC} SHARED ${SRC})
47+
message(${PREFIX_MESSAGE} "Unpacker build as Shared library")
48+
elseif (${BUILD_UNPACK_LIB_STATIC})
49+
## STATIC LIB
50+
add_library(${EXEC} STATIC ${SRC})
51+
message(${PREFIX_MESSAGE} "Unpacker build as Static library")
52+
endif ()
53+
4154
## <=====================================>
4255

4356
target_compile_definitions(${EXEC} PUBLIC "SWFP_UNPACKER")
@@ -58,7 +71,7 @@ endif()
5871

5972
## STATIC LIBRARY LINKING
6073
## <=====================================>
61-
if (${STATIC_LIB_NAME})
74+
if (NOT ${STATIC_LIB_NAME} STREQUAL "")
6275
target_link_libraries(${EXEC}
6376
PUBLIC
6477
${STATIC_LIB_NAME}

0 commit comments

Comments
 (0)