Skip to content

Commit

Permalink
Merge pull request json-c#321 from commodo/fix-cmake-vasprintf
Browse files Browse the repository at this point in the history
build,cmake: fix vasprintf implicit definition and generate both static & shared libs
  • Loading branch information
hawicz authored Jun 19, 2017
2 parents e8e574f + f10a5ae commit a363969
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@
/missing
/stamp-h1
/stamp-h2

# cmake auto-generated files
/CMakeCache.txt
/CMakeFiles
/cmake_install.cmake
/include
/libjson-c-static.a
/libjson-c.so
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if(MSVC)
file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h.win32 ${CMAKE_CURRENT_BINARY_DIR}/include/json_config.h)
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -D_GNU_SOURCE")
execute_process(COMMAND echo ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(COMMAND sh autogen.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(COMMAND ./configure WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
Expand Down Expand Up @@ -55,13 +55,20 @@ set(JSON_C_SOURCES
)

add_library(json-c
SHARED
${JSON_C_SOURCES}
${JSON_C_HEADERS}
)

add_library(json-c-static
STATIC
${JSON_C_SOURCES}
${JSON_C_HEADERS}
)

set_property(TARGET json-c PROPERTY C_STANDARD 99)

install(TARGETS json-c
install(TARGETS json-c json-c-static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
Expand Down

0 comments on commit a363969

Please sign in to comment.