-
Notifications
You must be signed in to change notification settings - Fork 811
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
Add CMake building system support #28
Comments
Hi, and thanks for the suggestion. However, I'm not willing to support two different build systems. Autotools works fine for me (and for others), and if it cannot be used for some reason, it's quite straightforward just to take all .c files and compile them as a library by hand. |
For anyone else wanting CMake support, here's the CMakeLists.txt I wrote which properly configures jansson_config.h and sets up a install target: cmake_minimum_required(VERSION 2.8)
include(CheckSymbolExists)
include(CheckCSourceCompiles)
check_symbol_exists(localeconv locale.h json_have_localeconv)
if(NOT json_have_localeconv)
set(json_have_localeconv 0)
endif()
check_c_source_compiles("int main() { long long test = 0; return test; }" json_have_long_long)
if(NOT json_have_long_long)
set(json_have_long_long 0)
endif()
check_c_source_compiles("inline int test() { return 0; }\nint main() { return test(); }" json_inline)
if(json_inline)
set(json_inline inline)
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/jansson_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/jansson_config.h)
set(json_have_long_long 0)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_library(jansson STATIC
src/dump.c
src/error.c
src/hashtable.c
src/load.c
src/memory.c
src/pack_unpack.c
src/strbuffer.c
src/strconv.c
src/utf.c
src/value.c)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h ${CMAKE_CURRENT_BINARY_DIR}/jansson_config.h DESTINATION include)
install(TARGETS jansson ARCHIVE DESTINATION lib) |
Hi Petri =))
CMake building system going to be more popular. It will be good to add this build system support.
I wrote working example code for this project, which should be place in "src" directory into file CMakeLists.txt
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(janson_SOURCES
dump.c
error.c
hashtable.c
hashtable.h
jansson_private.h
load.c
memory.c
pack_unpack.c
strbuffer.c
strbuffer.h
utf.c
utf.h
value.c)
add_library(janson STATIC ${janson_SOURCES})
This code builds jansson as a static libary.
The text was updated successfully, but these errors were encountered: