Skip to content

pkgconfig, static lib and uClibc linking fixes #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion reformatter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)

ADD_EXECUTABLE(json_reformat ${SRCS})

TARGET_LINK_LIBRARIES(json_reformat yajl_s)
TARGET_LINK_LIBRARIES(json_reformat yajl_s m)

# In some environments, we must explicitly link libm (like qnx,
# thanks @shahbag)
Expand Down
11 changes: 8 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ ADD_DEFINITIONS(-DYAJL_BUILD)
# set up some paths
SET (libDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib)
SET (incDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include/yajl)
SET (shareDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/share/pkgconfig)
SET (pcDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib${LIB_SUFFIX}/pkgconfig)

# set the output path for libraries
SET(LIBRARY_OUTPUT_PATH ${libDir})

ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS})
SET_TARGET_PROPERTIES(yajl_s PROPERTIES OUTPUT_NAME yajl)

IF(BUILD_SHARED_LIBS)
ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS})

#### setup shared library version number
Expand All @@ -51,6 +53,7 @@ IF(APPLE)
SET_TARGET_PROPERTIES(yajl PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF(APPLE)
ENDIF(BUILD_SHARED_LIBS)

#### build up an sdk as a post build step

Expand All @@ -61,7 +64,7 @@ FILE(MAKE_DIRECTORY ${incDir})
# generate build-time source
SET(dollar $)
CONFIGURE_FILE(api/yajl_version.h.cmake ${incDir}/yajl_version.h)
CONFIGURE_FILE(yajl.pc.cmake ${shareDir}/yajl.pc)
CONFIGURE_FILE(yajl.pc.cmake ${pcDir}/yajl.pc)

# copy public headers to output directory
FOREACH (header ${PUB_HDRS})
Expand All @@ -77,11 +80,13 @@ INCLUDE_DIRECTORIES(${incDir}/..)

# at build time you may specify the cmake variable LIB_SUFFIX to handle
# 64-bit systems which use 'lib64'
IF(BUILD_SHARED_LIBS)
INSTALL(TARGETS yajl
RUNTIME DESTINATION lib${LIB_SUFFIX}
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
ENDIF(BUILD_SHARED_LIBS)
INSTALL(TARGETS yajl_s ARCHIVE DESTINATION lib${LIB_SUFFIX})
INSTALL(FILES ${PUB_HDRS} DESTINATION include/yajl)
INSTALL(FILES ${incDir}/yajl_version.h DESTINATION include/yajl)
INSTALL(FILES ${shareDir}/yajl.pc DESTINATION share/pkgconfig)
INSTALL(FILES ${pcDir}/yajl.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
2 changes: 1 addition & 1 deletion test/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)
FOREACH (test ${TESTS})
GET_FILENAME_COMPONENT(testProg ${test} NAME_WE)
ADD_EXECUTABLE(${testProg} ${test})
TARGET_LINK_LIBRARIES(${testProg} yajl)
TARGET_LINK_LIBRARIES(${testProg} yajl m)
ENDFOREACH()
2 changes: 1 addition & 1 deletion test/parsing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib)

ADD_EXECUTABLE(yajl_test ${SRCS})

TARGET_LINK_LIBRARIES(yajl_test yajl_s)
TARGET_LINK_LIBRARIES(yajl_test yajl_s m)