Permalink
Browse files

cmake: Update for libuv.

  • Loading branch information...
1 parent 76fd364 commit 707b1dee84685c0c17530d568192455cdf790078 @thughes thughes committed with ry Jul 28, 2011
View
@@ -34,10 +34,13 @@ if(${node_arch} MATCHES unknown)
set(node_arch x86)
endif()
+set(NODE_INCLUDE_PREFIX ${CMAKE_INSTALL_PREFIX})
+
# Copy tools directory for out-of-source build
string(COMPARE EQUAL $(PROJECT_BINARY_DIR) ${PROJECT_SOURCE_DIR} in_source_build)
-if(NOT ${in_source_build})
+if(NOT in_source_build)
execute_process(COMMAND cmake -E copy_directory ${PROJECT_SOURCE_DIR}/tools ${PROJECT_BINARY_DIR}/tools)
+ configure_file(${PROJECT_SOURCE_DIR}/deps/v8/tools/jsmin.py ${PROJECT_BINARY_DIR}/tools COPYONLY)
endif()
# Set some compiler/linker flags..
View
@@ -1,18 +0,0 @@
-if(SHARED_CARES)
- find_library(LIBCARES_LIBRARY NAMES cares)
- find_path(LIBCARES_INCLUDE_DIR ares.h
- PATH_SUFFIXES include
- ) # Find header
- find_package_handle_standard_args(libcares DEFAULT_MSG LIBCARES_LIBRARY LIBCARES_INCLUDE_DIR)
-else()
- set(cares_arch ${node_arch})
-
- if(${node_arch} MATCHES x86_64)
- set(cares_arch x64)
- elseif(${node_arch} MATCHES x86)
- set(cares_arch ia32)
- endif()
-
- add_subdirectory(deps/c-ares)
- set(LIBCARES_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/deps/c-ares ${CMAKE_SOURCE_DIR}/deps/c-ares/${node_platform}-${cares_arch})
-endif()
View
@@ -1,10 +0,0 @@
-if(SHARED_LIBEV)
- find_library(LIBEV_LIBRARY NAMES ev)
- find_path(LIBEV_INCLUDE_DIR ev.h
- PATH_SUFFIXES include/ev include
- ) # Find header
- find_package_handle_standard_args(libev DEFAULT_MSG LIBEV_LIBRARY LIBEV_INCLUDE_DIR)
-else()
- add_subdirectory(deps/libev)
- set(LIBEV_INCLUDE_DIR deps/libev)
-endif()
View
@@ -47,9 +47,7 @@ if(OPENSSL_FOUND)
set(extra_libs ${extra_libs} ${OPENSSL_LIBRARIES})
endif()
-include("cmake/libc-ares.cmake")
-include("cmake/libev.cmake")
+include("cmake/libuv.cmake")
include("cmake/libv8.cmake")
-add_subdirectory(deps/libeio)
add_subdirectory(deps/http_parser)
View
@@ -0,0 +1,2 @@
+add_subdirectory(deps/uv)
+set(LIBUV_INCLUDE_DIR deps/uv/include)
View
@@ -6,8 +6,8 @@ set(macros_file ${PROJECT_BINARY_DIR}/macros.py)
# replace debug(x) and assert(x) with nothing in release build
if(${CMAKE_BUILD_TYPE} MATCHES Release)
- file(APPEND ${macros_file} "macro debug(x) = ;\n")
- file(APPEND ${macros_file} "macro assert(x) = ;\n")
+ file(APPEND ${macros_file} "macro debug(x) = void(0);\n")
+ file(APPEND ${macros_file} "macro assert(x) = void(0);\n")
endif()
if(NOT DTRACE)
@@ -21,16 +21,20 @@ if(NOT DTRACE)
DTRACE_NET_SOCKET_READ
DTRACE_NET_SOCKET_WRITE)
foreach(probe ${dtrace_probes})
- file(APPEND ${macros_file} "macro ${probe}(x) = ;\n")
+ file(APPEND ${macros_file} "macro ${probe}(x) = void(0);\n")
endforeach()
endif()
+# Sort the JS files being built into natives so that the build is
+# deterministic
+list(SORT js2c_files)
+
# include macros file in generation
set(js2c_files ${js2c_files} ${macros_file})
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/src/node_natives.h
- COMMAND ${PYTHON_EXECUTABLE} tools/js2c.py ${PROJECT_BINARY_DIR}/src/node_natives.h ${js2c_files}
+ COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/tools/js2c.py ${PROJECT_BINARY_DIR}/src/node_natives.h ${js2c_files}
DEPENDS ${js2c_files})
set(node_platform_src "src/platform_${node_platform}.cc")
@@ -48,21 +52,28 @@ set(node_sources
src/node_javascript.cc
src/node_extensions.cc
src/node_http_parser.cc
- src/node_net.cc
- src/node_io_watcher.cc
- src/node_child_process.cc
src/node_constants.cc
- src/node_cares.cc
- src/node_events.cc
src/node_file.cc
- src/node_signal_watcher.cc
- src/node_stat_watcher.cc
- src/node_stdio.cc
- src/node_timer.cc
src/node_script.cc
src/node_os.cc
src/node_dtrace.cc
src/node_string.cc
+ src/timer_wrap.cc
+ src/handle_wrap.cc
+ src/stream_wrap.cc
+ src/tcp_wrap.cc
+ src/pipe_wrap.cc
+ src/cares_wrap.cc
+ src/stdio_wrap.cc
+ src/process_wrap.cc
+ src/node_cares.cc
+ src/node_net.cc
+ src/node_signal_watcher.cc
+ src/node_stat_watcher.cc
+ src/node_io_watcher.cc
+ src/node_stdio.cc
+ src/node_child_process.cc
+ src/node_timer.cc
src/node_natives.h
${node_extra_src})
@@ -86,8 +97,7 @@ include_directories(
deps/libeio
deps/http_parser
${V8_INCLUDE_DIR}
- ${LIBEV_INCLUDE_DIR}
- ${LIBCARES_INCLUDE_DIR}
+ ${LIBUV_INCLUDE_DIR}
${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/src
@@ -105,9 +115,7 @@ endif()
add_executable(node ${node_sources})
set_target_properties(node PROPERTIES DEBUG_POSTFIX "_g")
target_link_libraries(node
- ev
- eio
- cares
+ uv
http_parser
${V8_LIBRARY_PATH}
${CMAKE_THREAD_LIBS_INIT}
@@ -134,9 +142,8 @@ install(FILES
src/node.h
src/node_object_wrap.h
src/node_buffer.h
- src/node_events.h
src/node_version.h
${PROJECT_BINARY_DIR}/src/node_config.h
- DESTINATION include/node
+ DESTINATION ${NODE_INCLUDE_PREFIX}/include/node
)
View
@@ -2,6 +2,10 @@
# package
#
+# Allow absolute paths when installing
+# see http://www.cmake.org/pipermail/cmake/2008-July/022958.html
+set(CPACK_SET_DESTDIR "ON")
+
if(${node_platform} MATCHES darwin)
set(CPACK_GENERATOR "TGZ;PackageMaker")
# CPack requires the files to end in .txt
@@ -24,7 +28,7 @@ set(CPACK_PACKAGE_DESCRIPTION "Evented I/O for V8 JavaScript.
presents the event loop as a language construct instead of as a library.")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
set(CPACK_DEBIAN_PACKAGE_SECTION "web")
-file(READ ${PROJECT_SOURCE_DIR}/src/node_version.h node_version_h LIMIT 1024 OFFSET 0)
+file(READ ${PROJECT_SOURCE_DIR}/src/node_version.h node_version_h OFFSET 0)
string(REGEX REPLACE ".*NODE_MAJOR_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MAJOR "${node_version_h}")
string(REGEX REPLACE ".*NODE_MINOR_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_MINOR "${node_version_h}")
string(REGEX REPLACE ".*NODE_PATCH_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH "${node_version_h}")
View
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(uv)
+
+string(TOLOWER ${CMAKE_SYSTEM_NAME} uv_platform)
+
+set(uv_platform_source ${uv_SOURCE_DIR}/src/uv-${uv_platform}.c)
+
+set(uv_source
+ src/uv-common.c
+ src/uv-eio.c
+ src/uv-unix.c)
+
+if(EXISTS ${uv_platform_source})
+ set(uv_source ${uv_source} ${uv_platform_source})
+else()
+ message(FATAL_ERROR "Unsupported platform: ${uv_platform}")
+endif()
+
+include_directories(
+ include
+ src/ares/config_${uv_platform})
+
+add_subdirectory(src/ev)
+add_subdirectory(src/eio)
+add_subdirectory(src/ares)
+
+add_library(uv ${uv_source})
+target_link_libraries(uv
+ ev
+ eio
+ ares)
@@ -1,22 +1,27 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${node_platform}-${cares_arch})
+cmake_minimum_required(VERSION 2.6)
+
+project(ares)
+
+string(TOLOWER ${CMAKE_SYSTEM_NAME} ares_platform)
+
+include_directories(config_${ares_platform})
add_definitions(-DHAVE_CONFIG_H=1)
include(CheckLibraryExists)
check_library_exists(socket socket "" HAVE_SOCKET_LIB)
check_library_exists(nsl gethostbyname "" HAVE_NSL_LIB)
-file(GLOB lib_sources *.c)
-add_library(cares ${lib_sources})
+file(GLOB ares_source *.c)
+add_library(ares ${ares_source})
-if(${HAVE_SOCKET_LIB})
- set(cares_libs ${cares_libs} socket)
+if(HAVE_SOCKET_LIB)
+ set(ares_libs ${ares_libs} socket)
endif()
-if(${HAVE_NSL_LIB})
- set(cares_libs ${cares_libs} nsl)
+if(HAVE_NSL_LIB)
+ set(ares_libs ${ares_libs} nsl)
endif()
-if(cares_libs)
- target_link_libraries(cares ${cares_libs})
+if(ares_libs)
+ target_link_libraries(ares ${ares_libs})
endif()
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 2.6)
+
+include(FindThreads)
+
+project(eio)
+
+add_definitions(-D_GNU_SOURCE)
+
+if(!${CMAKE_USE_PTHREADS_INIT})
+ message(FATAL_ERROR "Unable to find pthreads")
+endif()
+
+string(TOLOWER ${CMAKE_SYSTEM_NAME} eio_platform)
+set(config_header ${ev_SOURCE_DIR}/config_${eio_platform}.h)
+
+if(EXISTS ${config_header})
+ add_definitions(-DEIO_CONFIG_H="${config_header}")
+else()
+ message(FATAL_ERROR "Unsupported platform: ${eio_platform}")
+endif()
+
+add_library(eio eio.c)
+target_link_libraries(eio ${CMAKE_THREAD_LIBS_INIT})
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(ev)
+
+add_definitions(-DEV_MULTIPLICITY=0)
+
+string(TOLOWER ${CMAKE_SYSTEM_NAME} ev_platform)
+set(config_header ${ev_SOURCE_DIR}/config_${ev_platform}.h)
+
+if(EXISTS ${config_header})
+ add_definitions(-DEV_CONFIG_H="${config_header}")
+else()
+ message(FATAL_ERROR "Unsupported platform: ${ev_platform}")
+endif()
+
+add_library (ev ev.c)

0 comments on commit 707b1de

Please sign in to comment.