aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-12-13 23:39:57 +1030
committerMark Pulford <mark@kyne.com.au>2011-12-13 23:39:57 +1030
commit2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d (patch)
tree70df6d593f00a3282ac634dc0c7e0cf3735950fb
parent8e5aa7cfe7b873b4eb8dd522054e16a67fb66ca8 (diff)
downloadlua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.tar.gz
lua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.tar.bz2
lua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.zip
Add support for building via CMake
-rw-r--r--CMakeLists.txt47
-rwxr-xr-xruntests.sh10
2 files changed, 57 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..bfb28cc
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,47 @@
1# If Lua is installed in a non-standard location, please set the LUA_DIR
2# environment variable to point to prefix for the install. Eg:
3# Unix: export LUA_DIR=/home/user/pkg
4# Windows: set LUA_DIR=c:\lua51
5
6project(lua_cjson C)
7cmake_minimum_required(VERSION 2.6)
8
9set(CMAKE_BUILD_TYPE Release)
10
11find_package(Lua51 REQUIRED)
12include_directories(${LUA_INCLUDE_DIR})
13
14# Use thread-safe POSIX.1-2008 uselocale() where available, otherwise
15# fall back to ANSI C setlocale().
16include(CheckFunctionExists)
17CHECK_FUNCTION_EXISTS(uselocale HAVE_USELOCALE)
18if(HAVE_USELOCALE)
19 add_definitions(-DUSE_POSIX_USELOCALE)
20else()
21 add_definitions(-DUSE_POSIX_SETLOCALE)
22endif()
23
24# Handle platforms missing isinf() macro (Eg, some Solaris systems).
25include(CheckSymbolExists)
26CHECK_SYMBOL_EXISTS(isinf math.h HAVE_ISINF)
27if(NOT HAVE_ISINF)
28 add_definitions(-DUSE_INTERNAL_ISINF)
29endif()
30
31if(APPLE)
32 set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
33 "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
34endif()
35
36get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH)
37if(WIN32)
38 set(_lua_module_dir "${_lua_lib_dir}")
39else()
40 set(_lua_module_dir "${_lua_lib_dir}/lua/5.1")
41endif()
42
43add_library(cjson MODULE lua_cjson.c strbuf.c)
44set_target_properties(cjson PROPERTIES PREFIX "")
45install(TARGETS cjson DESTINATION "${_lua_module_dir}")
46
47# vi:ai et sw=4 ts=4:
diff --git a/runtests.sh b/runtests.sh
index f273385..c520be0 100755
--- a/runtests.sh
+++ b/runtests.sh
@@ -54,6 +54,16 @@ do_tests
54make clean 54make clean
55rm -f tests/cjson.so 55rm -f tests/cjson.so
56 56
57echo "===== Testing Cmake build ====="
58mkdir build
59cd build
60cmake ..
61make
62cd ..
63cp build/cjson.so tests
64do_tests
65rm -rf build tests/cjson.so
66
57if [ "$PLATFORM" = "Linux" ] 67if [ "$PLATFORM" = "Linux" ]
58then 68then
59 echo "===== Testing RPM build =====" 69 echo "===== Testing RPM build ====="