Skip to content

Commit 9cc5185

Browse files
committed
Add option to build shared or static library for unpacker
1 parent 4c7e2ec commit 9cc5185

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
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

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/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)