diff --git a/.github/workflows/Test_windows.yml b/.github/workflows/Test_windows.yml index 6b110c8..fc94d33 100644 --- a/.github/workflows/Test_windows.yml +++ b/.github/workflows/Test_windows.yml @@ -12,9 +12,10 @@ on: env: BUILD_TYPE: Release + VERSION_NAME: 1.1 jobs: - Test_windows: + Build_exec: runs-on: windows-latest steps: - name: Checkout repository @@ -34,4 +35,48 @@ jobs: uses: actions/upload-artifact@v3 with: name: SWPacker - path: ${{github.workspace}}\out\1.1\Release\ \ No newline at end of file + path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\ + + Build_Unpack_Shared: + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Config executables + run: | + mkdir build && cd build + cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_SHARED=ON .. + + - name: Build executables + run: | + cd ${{github.workspace}}\build + cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}} + + - name: Archive Library + uses: actions/upload-artifact@v3 + with: + name: SWPacker + path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\ + + Build_Unpack_Static: + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Config executables + run: | + mkdir build && cd build + cmake -B ${{github.workspace}}\build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_UNPACK_LIB_STATIC=ON .. + + - name: Build executables + run: | + cd ${{github.workspace}}\build + cmake --build ${{github.workspace}}\build --target SWEngine-unpacker_${{env.VERSION_NAME}} --config ${{env.BUILD_TYPE}} + + - name: Archive library + uses: actions/upload-artifact@v3 + with: + name: SWPacker + path: ${{github.workspace}}\out\${{env.VERSION_NAME}}\Release\ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 285e919..2b745e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,8 @@ message(${PREFIX_MESSAGE} "Project location: " ${CMAKE_SOURCE_DIR}) message(${PREFIX_MESSAGE} "Project system: " ${CMAKE_SYSTEM_NAME}) option(SWFP_COMP "Define if the packer will enable compact process" ) +option(BUILD_UNPACK_LIB_SHARED "Define if Unpacker is build as a library as shared" ) +option(BUILD_UNPACK_LIB_STATIC "Define if Unpacker is build as a library as static" ) ## IMPORTED STATIC LIBRARY NAME set( STATIC_LIB_NAME @@ -45,7 +47,6 @@ list(LENGTH STATIC_LIB_NAME list_len) math(EXPR LIST_LEN "${list_len} - 1") if (${LIST_LEN} GREATER_EQUAL 0) - foreach(ctr RANGE ${LIST_LEN}) list(GET STATIC_LIB_NAME ${ctr} lib) list(GET STATIC_LIB ${ctr} filelib) diff --git a/README.md b/README.md index 26d04ef..7e04ae9 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ cmake --build . --target SWEngine-[packer/unpacker]_1.1 --config [Debug/Release] You can define an option by using : `-D[option]=[value]` - CMAKE_BUILD_TYPE: Debug/Release - SWFP_COMP: ON/OFF +- BUILD_UNPACK_LIB_SHARED: ON/OFF +- BUILD_UNPACK_LIB_STATIC: ON/OFF ## Usage ### Packer diff --git a/cmake/Packer.cmake b/cmake/Packer.cmake index 2b4e51b..ba30fbb 100644 --- a/cmake/Packer.cmake +++ b/cmake/Packer.cmake @@ -59,16 +59,6 @@ if(MSVC) endif() ## <=====================================> -## IMPORTED STATIC LIBRARY NAME -set( STATIC_LIB_NAME - zstd_static - ) - -## IMPORTED STATIC LIBRARY .lib file -set( STATIC_LIB - ${CMAKE_SOURCE_DIR}/libraries/zstd_static.lib - ) - ## STATIC LIBRARY LINKING ## <=====================================> if (${STATIC_LIB_NAME}) diff --git a/cmake/UnPacker.cmake b/cmake/UnPacker.cmake index 4c17552..d456223 100644 --- a/cmake/UnPacker.cmake +++ b/cmake/UnPacker.cmake @@ -36,8 +36,21 @@ file(GLOB SRC ${TMP}) ## OUTPUT ## <=====================================> -## EXECUTABLE -add_executable(${EXEC} ${SRC}) + +if (NOT ${BUILD_UNPACK_LIB_SHARED} AND NOT ${BUILD_UNPACK_LIB_STATIC}) + ## EXECUTABLE + add_executable(${EXEC} ${SRC}) + message(${PREFIX_MESSAGE} "Unpacker build as executable") +elseif (${BUILD_UNPACK_LIB_SHARED}) + ## SHARED LIB + add_library(${EXEC} SHARED ${SRC}) + message(${PREFIX_MESSAGE} "Unpacker build as Shared library") +elseif (${BUILD_UNPACK_LIB_STATIC}) + ## STATIC LIB + add_library(${EXEC} STATIC ${SRC}) + message(${PREFIX_MESSAGE} "Unpacker build as Static library") +endif () + ## <=====================================> target_compile_definitions(${EXEC} PUBLIC "SWFP_UNPACKER") @@ -58,7 +71,7 @@ endif() ## STATIC LIBRARY LINKING ## <=====================================> -if (${STATIC_LIB_NAME}) +if (NOT ${STATIC_LIB_NAME} STREQUAL "") target_link_libraries(${EXEC} PUBLIC ${STATIC_LIB_NAME}