Skip to content

Commit 540a132

Browse files
authored
Merge branch 'master' into different-output-folders
2 parents f2e4f5e + 3aee781 commit 540a132

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ CMakeCache.txt
5252
tests_tmp_dll/
5353
tests_tmp_app/
5454
*.aps
55+
56+
# Just because I like building into /bin...
57+
/bin

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ If you'd rather not build from source, check out the [Releases](https://github.c
1414
Asar can also be built as a DLL. This makes it easier and faster to use in other programs (such as a sprite insertion tool). You can find documentation on the DLL API in the respective bindings (asardll.h, asar.cs, asar.py).
1515

1616
## Asar as a static library
17-
Asar can also be build as a static library. All "out-facing" functions are in interface-lib.h. This is useful for embedding Asar in other programs which don't want to use DLLs. The easiest way to add asar as a static library to your project, assuming you are using CMake (at least 3.11), is to use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) to fetch the source code, then add the following to your CMakeLists.txt:
17+
Asar can also be built as a static library. All "out-facing" functions are in interface-lib.h. This is useful for embedding Asar in other programs which don't want to use DLLs. The easiest way to add asar as a static library to your project is to add it as a git submodule
18+
19+
`git submodule add https://github.com/RPGHacker/asar <path-to-subdir>`
20+
21+
then add the following to your CMakeLists.txt:
1822
```CMake
19-
target_include_directories(YourTarget PUBLIC ${asar_SOURCE_DIR}/src)
23+
add_subdirectory(<path-to-subdir>/src)
24+
get_target_property(ASAR_INCLUDE_DIR asar-static INCLUDE_DIRECTORIES)
25+
include_directories(${ASAR_INCLUDE_DIR})
26+
target_link_libraries(YourTarget PUBLIC asar-static)
2027
```
21-
to be able to include the header files. It is also recommended to add `set(ASAR_TESTING_DISABLED TRUE)` to your CMakeLists.txt to disable building tests.
28+
to be able to include the header files. It is also recommended to turn off every build in target in asar except the static one using the appropriate CMake options. You will need to make sure that your project has an Asar compatible license.
2229

2330
## Folder layout
2431
* `docs` contains the source of the manual and changelog.

src/asar/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,16 @@ if(ASAR_GEN_EXE)
235235
target_compile_options(asar-standalone PRIVATE -fprofile-arcs -ftest-coverage)
236236
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage -fprofile-arcs")
237237
endif()
238-
238+
239239
set_target_properties(asar-standalone
240240
PROPERTIES
241241
OUTPUT_NAME "asar"
242242
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
243243
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
244244
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin"
245245
)
246+
247+
install(TARGETS asar-standalone)
246248
endif(ASAR_GEN_EXE)
247249

248250

@@ -260,6 +262,7 @@ if(ASAR_GEN_DLL)
260262
${ASAR_SHARED_SOURCE_FILES}
261263
${ASAR_LIB_RESOURCE_FILES}
262264
)
265+
263266
target_compile_definitions(asar PRIVATE "ASAR_SHARED")
264267
set_asar_shared_properties(asar "T" TRUE)
265268

@@ -269,6 +272,9 @@ if(ASAR_GEN_DLL)
269272
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib"
270273
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib"
271274
)
275+
276+
install(TARGETS asar)
277+
272278
endif(ASAR_GEN_DLL)
273279

274280

@@ -288,6 +294,8 @@ if (ASAR_GEN_LIB)
288294
target_compile_definitions(asar-static PRIVATE "ASAR_STATIC")
289295
set_asar_shared_properties(asar-static "D" FALSE)
290296

297+
install(TARGETS asar-static)
298+
291299
# there's no need to set the PDB name since static libraries don't produce PDBs
292300
set_target_properties(asar-static
293301
PROPERTIES

0 commit comments

Comments
 (0)