2 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
4 IF(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
5 MESSAGE(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt. ")
8 FIND_PACKAGE( Lua51 REQUIRED )
9 FIND_PACKAGE( OpenSSL REQUIRED )
10 FIND_PACKAGE( Threads REQUIRED )
12 SET( BOOST_MIN_VERSION "1.44.0" )
14 # We want to statically link the multithreaded versions. And we don't want Boost auto-link feature
15 # since it doesn't play nice with CMake
16 SET( Boost_USE_STATIC_LIBS ON )
17 SET( Boost_USE_MULTITHREADED ON )
18 SET( Boost_USE_STATIC_RUNTIME OFF )
19 ADD_DEFINITIONS( -DBOOST_ALL_NO_LIB )
21 # boost::thread since version 1.50 relies on boost::chrono
22 # So check which Boost version is available and look for the required libs
24 SET( local_boost_version "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}" )
25 IF (${local_boost_version} VERSION_GREATER "1.49")
26 FIND_PACKAGE( Boost ${BOOST_MIN_VERSION} COMPONENTS system date_time thread chrono REQUIRED )
28 FIND_PACKAGE( Boost ${BOOST_MIN_VERSION} COMPONENTS system date_time thread REQUIRED )
31 FIND_PROGRAM(LUA NAMES lua-5.1 lua5.1 lua)
34 # Windows specific code
35 ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
36 ADD_DEFINITIONS( -D_WIN32_WINNT=0x0501 )
38 src/luanode_file_win32.cpp
39 src/platform_windows.cpp
40 src/luanode_stdio_win32.cpp
41 src/detail/windows/input_tty.cpp
42 src/detail/windows/output_tty.cpp
43 src/detail/windows/windows_tty.cpp
45 ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
47 FIND_LIBRARY(KVM_LIBRARIES NAMES kvm)
49 src/luanode_file_linux.cpp
51 src/luanode_stdio_linux.cpp
52 src/luanode_posix_stream.cpp
53 src/detail/posix/tty_stream.cpp
55 ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
56 # Mac OS X specific code
58 src/luanode_file_linux.cpp
59 src/platform_darwin.cpp
60 src/luanode_stdio_linux.cpp
61 src/luanode_posix_stream.cpp
62 src/detail/posix/tty_stream.cpp
67 src/luanode_file_linux.cpp
68 src/platform_linux.cpp
69 src/luanode_stdio_linux.cpp
70 src/luanode_posix_stream.cpp
71 src/detail/posix/tty_stream.cpp
76 lib/luanode/child_process
82 lib/luanode/event_emitter
85 lib/luanode/introspect
89 lib/luanode/querystring
98 lib/luanode/__private_luastate
99 lib/luanode/__private_traverse
100 lib/luanode/__private_url
103 deps/stacktraceplus/src/StackTracePlus
106 SET(SRC ${CMAKE_SOURCE_DIR})
107 SET(DST ${CMAKE_SOURCE_DIR}/build/temp)
108 # Create a temp directory to store Lua .precomp files
109 FILE(MAKE_DIRECTORY ${DST})
111 ADD_DEFINITIONS( -D_SOURCE_PATH=\"${CMAKE_SOURCE_DIR}\" )
112 FILE(WRITE ${DST}/${target}/build_path.precomp \"${SRC}\")
114 FOREACH(filename ${LUAS})
115 GET_FILENAME_COMPONENT(base ${filename} NAME)
116 SET(target "${DST}/${base}.precomp")
117 MESSAGE(STATUS "Precompiling ${filename} into ${target}")
118 EXECUTE_PROCESS(COMMAND ${LUA} ${SRC}/tools/bin2c.lua ${SRC}/${filename}.lua extension_status OUTPUT_FILE ${target} RESULT_VARIABLE res)
119 IF(NOT ${res} EQUAL 0)
120 MESSAGE(FATAL_ERROR "Error while precompiling Lua file. ${SRC}/${filename}.lua" )
127 src/luanode_child_process.cpp
128 src/luanode_constants.cpp
129 src/luanode_crypto.cpp
131 src/luanode_datagram_udp.cpp
132 src/luanode_hrtime.cpp
133 src/luanode_http_parser.cpp
134 src/luanode_module_api.cpp
136 src/luanode_net_acceptor.cpp
137 src/luanode_timer.cpp
142 deps/http-parser/http_parser.c
145 INCLUDE_DIRECTORIES(src ${LUA_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${DST})
146 ADD_EXECUTABLE(luanode ${SOURCES})
147 TARGET_LINK_LIBRARIES(luanode ${LUA_LIBRARIES} ${OPENSSL_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
150 # Windows specific code
151 ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "BSD")
153 TARGET_LINK_LIBRARIES(luanode ${KVM_LIBRARIES} rt)
154 ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
155 # Mac OS X specific code
157 # Linux specific code
158 TARGET_LINK_LIBRARIES(luanode rt)