Added ability to build shared library

This commit is contained in:
rexy712 2018-12-14 17:47:26 -08:00
parent edcfee90eb
commit 686541279f
2 changed files with 11 additions and 2 deletions

View File

@ -13,15 +13,24 @@ configure_file(
include_directories("${INCLUDE_PATH}")
option(ENABLE_DIAGNOSTICS "Print diagnostic messages when parsing json to help identify issues" ON)
option(ENABLE_SHARED "Build shared library" OFF)
set(SOURCE_LIST "src/input.c" "src/output.c" "src/strings.c")
if(ENABLE_SHARED)
add_library(rjp SHARED ${SOURCE_LIST})
else()
add_library(rjp STATIC ${SOURCE_LIST})
endif()
add_library (rjp STATIC src/input.c src/output.c src/strings.c)
set_target_properties(rjp PROPERTIES PUBLIC_HEADER ${INCLUDE_PATH}/rjp.h)
set_target_properties(rjp PROPERTIES SOVERSION "${rjp_VERSION_MAJOR}.${rjp_VERSION_MINOR}")
if(ENABLE_DIAGNOSTICS)
target_compile_definitions(rjp PRIVATE RJP_DIAGNOSTICS)
endif()
install(TARGETS rjp
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

View File

@ -6,7 +6,7 @@ rjp (rexy's json parser) is a very simplistic json parser written in C. There is
Currently only installs 2 files: librjp.a and rjp.h
## Building
Building will produce a static library with no option to create shared because it's such a simple library.
Building will produce a static library by default but can be configured to build a shared library.
##### Run the following commands
```