aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt48
1 files changed, 41 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ffc718b..2f3e970 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,18 +3,45 @@
3# Unix: export LUA_DIR=/home/user/pkg 3# Unix: export LUA_DIR=/home/user/pkg
4# Windows: set LUA_DIR=c:\lua51 4# Windows: set LUA_DIR=c:\lua51
5 5
6project(lua_cjson C) 6project(lua-cjson C)
7cmake_minimum_required(VERSION 2.6) 7cmake_minimum_required(VERSION 2.6)
8 8
9set(CMAKE_BUILD_TYPE Release) 9option(USE_INTERNAL_DTOA "Use internal strtod() / dtoa code for performance")
10option(MULTIPLE_THREADS
11 "Build internal dtoa with support for multi-threaded applications - recommended" ON)
12
13if(NOT CMAKE_BUILD_TYPE)
14 set(CMAKE_BUILD_TYPE Release CACHE STRING
15 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
16 FORCE)
17endif()
10 18
11find_package(Lua51 REQUIRED) 19find_package(Lua51 REQUIRED)
12include_directories(${LUA_INCLUDE_DIR}) 20include_directories(${LUA_INCLUDE_DIR})
13 21
14include(TestBigEndian) 22if(NOT USE_INTERNAL_DTOA)
15TEST_BIG_ENDIAN(BIG_ENDIAN) 23 # Use libc number conversion routines (strtod(), sprintf())
16if(HAVE_BIG_ENDIAN) 24 set(FPCONV_SOURCES fpconv.c)
17 add_definitions(-DIEEE_BIG_ENDIAN) 25else()
26 # Use internal number conversion routines
27 add_definitions(-DUSE_INTERNAL_DTOA)
28 set(FPCONV_SOURCES g_fmt.c dtoa.c)
29
30 include(TestBigEndian)
31 TEST_BIG_ENDIAN(IEEE_BIG_ENDIAN)
32 if(IEEE_BIG_ENDIAN)
33 add_definitions(-DIEEE_BIG_ENDIAN)
34 endif()
35
36 if(MULTIPLE_THREADS)
37 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
38 find_package(Threads REQUIRED)
39 if(NOT CMAKE_USE_PTHREADS_INIT)
40 message(FATAL_ERROR
41 "Pthreads not found - required by MULTIPLE_THREADS option")
42 endif()
43 add_definitions(-DMULTIPLE_THREADS)
44 endif()
18endif() 45endif()
19 46
20# Handle platforms missing isinf() macro (Eg, some Solaris systems). 47# Handle platforms missing isinf() macro (Eg, some Solaris systems).
@@ -36,8 +63,15 @@ else()
36 set(_lua_module_dir "${_lua_lib_dir}/lua/5.1") 63 set(_lua_module_dir "${_lua_lib_dir}/lua/5.1")
37endif() 64endif()
38 65
39add_library(cjson MODULE lua_cjson.c strbuf.c fpconv.c) 66set(_MODULE_LINK "${CMAKE_THREAD_LIBS_INIT}")
67if(WIN32)
68 # Win32 modules need to be linked to the Lua library.
69 set(_MODULE_LINK ${LUA_LIBRARY} ${_MODULE_LINK})
70endif()
71
72add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES})
40set_target_properties(cjson PROPERTIES PREFIX "") 73set_target_properties(cjson PROPERTIES PREFIX "")
74target_link_libraries(cjson ${_MODULE_LINK})
41install(TARGETS cjson DESTINATION "${_lua_module_dir}") 75install(TARGETS cjson DESTINATION "${_lua_module_dir}")
42 76
43# vi:ai et sw=4 ts=4: 77# vi:ai et sw=4 ts=4: