diff options
| author | Mark Pulford <mark@kyne.com.au> | 2011-12-13 23:39:57 +1030 |
|---|---|---|
| committer | Mark Pulford <mark@kyne.com.au> | 2011-12-13 23:39:57 +1030 |
| commit | 2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d (patch) | |
| tree | 70df6d593f00a3282ac634dc0c7e0cf3735950fb | |
| parent | 8e5aa7cfe7b873b4eb8dd522054e16a67fb66ca8 (diff) | |
| download | lua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.tar.gz lua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.tar.bz2 lua-cjson-2487f7fa11a9c3c6d24948b4abc9a0e5468d1b1d.zip | |
Add support for building via CMake
Diffstat (limited to '')
| -rw-r--r-- | CMakeLists.txt | 47 | ||||
| -rwxr-xr-x | runtests.sh | 10 |
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 | |||
| 6 | project(lua_cjson C) | ||
| 7 | cmake_minimum_required(VERSION 2.6) | ||
| 8 | |||
| 9 | set(CMAKE_BUILD_TYPE Release) | ||
| 10 | |||
| 11 | find_package(Lua51 REQUIRED) | ||
| 12 | include_directories(${LUA_INCLUDE_DIR}) | ||
| 13 | |||
| 14 | # Use thread-safe POSIX.1-2008 uselocale() where available, otherwise | ||
| 15 | # fall back to ANSI C setlocale(). | ||
| 16 | include(CheckFunctionExists) | ||
| 17 | CHECK_FUNCTION_EXISTS(uselocale HAVE_USELOCALE) | ||
| 18 | if(HAVE_USELOCALE) | ||
| 19 | add_definitions(-DUSE_POSIX_USELOCALE) | ||
| 20 | else() | ||
| 21 | add_definitions(-DUSE_POSIX_SETLOCALE) | ||
| 22 | endif() | ||
| 23 | |||
| 24 | # Handle platforms missing isinf() macro (Eg, some Solaris systems). | ||
| 25 | include(CheckSymbolExists) | ||
| 26 | CHECK_SYMBOL_EXISTS(isinf math.h HAVE_ISINF) | ||
| 27 | if(NOT HAVE_ISINF) | ||
| 28 | add_definitions(-DUSE_INTERNAL_ISINF) | ||
| 29 | endif() | ||
| 30 | |||
| 31 | if(APPLE) | ||
| 32 | set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS | ||
| 33 | "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup") | ||
| 34 | endif() | ||
| 35 | |||
| 36 | get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH) | ||
| 37 | if(WIN32) | ||
| 38 | set(_lua_module_dir "${_lua_lib_dir}") | ||
| 39 | else() | ||
| 40 | set(_lua_module_dir "${_lua_lib_dir}/lua/5.1") | ||
| 41 | endif() | ||
| 42 | |||
| 43 | add_library(cjson MODULE lua_cjson.c strbuf.c) | ||
| 44 | set_target_properties(cjson PROPERTIES PREFIX "") | ||
| 45 | install(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 | |||
| 54 | make clean | 54 | make clean |
| 55 | rm -f tests/cjson.so | 55 | rm -f tests/cjson.so |
| 56 | 56 | ||
| 57 | echo "===== Testing Cmake build =====" | ||
| 58 | mkdir build | ||
| 59 | cd build | ||
| 60 | cmake .. | ||
| 61 | make | ||
| 62 | cd .. | ||
| 63 | cp build/cjson.so tests | ||
| 64 | do_tests | ||
| 65 | rm -rf build tests/cjson.so | ||
| 66 | |||
| 57 | if [ "$PLATFORM" = "Linux" ] | 67 | if [ "$PLATFORM" = "Linux" ] |
| 58 | then | 68 | then |
| 59 | echo "===== Testing RPM build =====" | 69 | echo "===== Testing RPM build =====" |
