diff options
| author | Mark Pulford <mark@kyne.com.au> | 2012-01-03 21:58:50 +1030 |
|---|---|---|
| committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 18:54:34 +1030 |
| commit | 9f85048c49caca1d1774c96681546b178cb7ca78 (patch) | |
| tree | f1f084420621e90ba810172ed96e621d9f5b1577 | |
| parent | 314f0d0675d8fdfdab3c44afd2ce7d6af8c05a46 (diff) | |
| download | lua-cjson-9f85048c49caca1d1774c96681546b178cb7ca78.tar.gz lua-cjson-9f85048c49caca1d1774c96681546b178cb7ca78.tar.bz2 lua-cjson-9f85048c49caca1d1774c96681546b178cb7ca78.zip | |
Add support to USE_INTERNAL_DTOA to CMake build
- Provide build options for USE_INTERNAL_DTOA and MULTIPLE_THREADS
- Link module with Lua library under Windows
| -rw-r--r-- | CMakeLists.txt | 48 |
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 | ||
| 6 | project(lua_cjson C) | 6 | project(lua-cjson C) |
| 7 | cmake_minimum_required(VERSION 2.6) | 7 | cmake_minimum_required(VERSION 2.6) |
| 8 | 8 | ||
| 9 | set(CMAKE_BUILD_TYPE Release) | 9 | option(USE_INTERNAL_DTOA "Use internal strtod() / dtoa code for performance") |
| 10 | option(MULTIPLE_THREADS | ||
| 11 | "Build internal dtoa with support for multi-threaded applications - recommended" ON) | ||
| 12 | |||
| 13 | if(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) | ||
| 17 | endif() | ||
| 10 | 18 | ||
| 11 | find_package(Lua51 REQUIRED) | 19 | find_package(Lua51 REQUIRED) |
| 12 | include_directories(${LUA_INCLUDE_DIR}) | 20 | include_directories(${LUA_INCLUDE_DIR}) |
| 13 | 21 | ||
| 14 | include(TestBigEndian) | 22 | if(NOT USE_INTERNAL_DTOA) |
| 15 | TEST_BIG_ENDIAN(BIG_ENDIAN) | 23 | # Use libc number conversion routines (strtod(), sprintf()) |
| 16 | if(HAVE_BIG_ENDIAN) | 24 | set(FPCONV_SOURCES fpconv.c) |
| 17 | add_definitions(-DIEEE_BIG_ENDIAN) | 25 | else() |
| 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() | ||
| 18 | endif() | 45 | endif() |
| 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") |
| 37 | endif() | 64 | endif() |
| 38 | 65 | ||
| 39 | add_library(cjson MODULE lua_cjson.c strbuf.c fpconv.c) | 66 | set(_MODULE_LINK "${CMAKE_THREAD_LIBS_INIT}") |
| 67 | if(WIN32) | ||
| 68 | # Win32 modules need to be linked to the Lua library. | ||
| 69 | set(_MODULE_LINK ${LUA_LIBRARY} ${_MODULE_LINK}) | ||
| 70 | endif() | ||
| 71 | |||
| 72 | add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES}) | ||
| 40 | set_target_properties(cjson PROPERTIES PREFIX "") | 73 | set_target_properties(cjson PROPERTIES PREFIX "") |
| 74 | target_link_libraries(cjson ${_MODULE_LINK}) | ||
| 41 | install(TARGETS cjson DESTINATION "${_lua_module_dir}") | 75 | install(TARGETS cjson DESTINATION "${_lua_module_dir}") |
| 42 | 76 | ||
| 43 | # vi:ai et sw=4 ts=4: | 77 | # vi:ai et sw=4 ts=4: |
