Browse Source

cmake: Update for libuv.

v0.7.4-release
Tom Hughes 14 years ago
committed by Ryan Dahl
parent
commit
707b1dee84
  1. 5
      cmake/configure.cmake
  2. 18
      cmake/libc-ares.cmake
  3. 10
      cmake/libev.cmake
  4. 4
      cmake/libs.cmake
  5. 2
      cmake/libuv.cmake
  6. 47
      cmake/node_build.cmake
  7. 6
      cmake/package.cmake
  8. 32
      deps/uv/CMakeLists.txt
  9. 25
      deps/uv/src/ares/CMakeLists.txt
  10. 23
      deps/uv/src/eio/CMakeLists.txt
  11. 16
      deps/uv/src/ev/CMakeLists.txt

5
cmake/configure.cmake

@ -34,10 +34,13 @@ if(${node_arch} MATCHES unknown)
set(node_arch x86) set(node_arch x86)
endif() endif()
set(NODE_INCLUDE_PREFIX ${CMAKE_INSTALL_PREFIX})
# Copy tools directory for out-of-source build # Copy tools directory for out-of-source build
string(COMPARE EQUAL $(PROJECT_BINARY_DIR) ${PROJECT_SOURCE_DIR} in_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) 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() endif()
# Set some compiler/linker flags.. # Set some compiler/linker flags..

18
cmake/libc-ares.cmake

@ -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()

10
cmake/libev.cmake

@ -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()

4
cmake/libs.cmake

@ -47,9 +47,7 @@ if(OPENSSL_FOUND)
set(extra_libs ${extra_libs} ${OPENSSL_LIBRARIES}) set(extra_libs ${extra_libs} ${OPENSSL_LIBRARIES})
endif() endif()
include("cmake/libc-ares.cmake") include("cmake/libuv.cmake")
include("cmake/libev.cmake")
include("cmake/libv8.cmake") include("cmake/libv8.cmake")
add_subdirectory(deps/libeio)
add_subdirectory(deps/http_parser) add_subdirectory(deps/http_parser)

2
cmake/libuv.cmake

@ -0,0 +1,2 @@
add_subdirectory(deps/uv)
set(LIBUV_INCLUDE_DIR deps/uv/include)

47
cmake/node_build.cmake

@ -6,8 +6,8 @@ set(macros_file ${PROJECT_BINARY_DIR}/macros.py)
# replace debug(x) and assert(x) with nothing in release build # replace debug(x) and assert(x) with nothing in release build
if(${CMAKE_BUILD_TYPE} MATCHES Release) if(${CMAKE_BUILD_TYPE} MATCHES Release)
file(APPEND ${macros_file} "macro debug(x) = ;\n") file(APPEND ${macros_file} "macro debug(x) = void(0);\n")
file(APPEND ${macros_file} "macro assert(x) = ;\n") file(APPEND ${macros_file} "macro assert(x) = void(0);\n")
endif() endif()
if(NOT DTRACE) if(NOT DTRACE)
@ -21,16 +21,20 @@ if(NOT DTRACE)
DTRACE_NET_SOCKET_READ DTRACE_NET_SOCKET_READ
DTRACE_NET_SOCKET_WRITE) DTRACE_NET_SOCKET_WRITE)
foreach(probe ${dtrace_probes}) foreach(probe ${dtrace_probes})
file(APPEND ${macros_file} "macro ${probe}(x) = ;\n") file(APPEND ${macros_file} "macro ${probe}(x) = void(0);\n")
endforeach() endforeach()
endif() endif()
# Sort the JS files being built into natives so that the build is
# deterministic
list(SORT js2c_files)
# include macros file in generation # include macros file in generation
set(js2c_files ${js2c_files} ${macros_file}) set(js2c_files ${js2c_files} ${macros_file})
add_custom_command( add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/src/node_natives.h 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}) DEPENDS ${js2c_files})
set(node_platform_src "src/platform_${node_platform}.cc") set(node_platform_src "src/platform_${node_platform}.cc")
@ -48,21 +52,28 @@ set(node_sources
src/node_javascript.cc src/node_javascript.cc
src/node_extensions.cc src/node_extensions.cc
src/node_http_parser.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_constants.cc
src/node_cares.cc
src/node_events.cc
src/node_file.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_script.cc
src/node_os.cc src/node_os.cc
src/node_dtrace.cc src/node_dtrace.cc
src/node_string.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 src/node_natives.h
${node_extra_src}) ${node_extra_src})
@ -86,8 +97,7 @@ include_directories(
deps/libeio deps/libeio
deps/http_parser deps/http_parser
${V8_INCLUDE_DIR} ${V8_INCLUDE_DIR}
${LIBEV_INCLUDE_DIR} ${LIBUV_INCLUDE_DIR}
${LIBCARES_INCLUDE_DIR}
${PROJECT_BINARY_DIR} ${PROJECT_BINARY_DIR}
${PROJECT_BINARY_DIR}/src ${PROJECT_BINARY_DIR}/src
@ -105,9 +115,7 @@ endif()
add_executable(node ${node_sources}) add_executable(node ${node_sources})
set_target_properties(node PROPERTIES DEBUG_POSTFIX "_g") set_target_properties(node PROPERTIES DEBUG_POSTFIX "_g")
target_link_libraries(node target_link_libraries(node
ev uv
eio
cares
http_parser http_parser
${V8_LIBRARY_PATH} ${V8_LIBRARY_PATH}
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
@ -134,9 +142,8 @@ install(FILES
src/node.h src/node.h
src/node_object_wrap.h src/node_object_wrap.h
src/node_buffer.h src/node_buffer.h
src/node_events.h
src/node_version.h src/node_version.h
${PROJECT_BINARY_DIR}/src/node_config.h ${PROJECT_BINARY_DIR}/src/node_config.h
DESTINATION include/node DESTINATION ${NODE_INCLUDE_PREFIX}/include/node
) )

6
cmake/package.cmake

@ -2,6 +2,10 @@
# package # 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) if(${node_platform} MATCHES darwin)
set(CPACK_GENERATOR "TGZ;PackageMaker") set(CPACK_GENERATOR "TGZ;PackageMaker")
# CPack requires the files to end in .txt # 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.") 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_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}")
set(CPACK_DEBIAN_PACKAGE_SECTION "web") 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_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_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}") string(REGEX REPLACE ".*NODE_PATCH_VERSION[ ]*([0-9]+).*" "\\1" CPACK_PACKAGE_VERSION_PATCH "${node_version_h}")

32
deps/uv/CMakeLists.txt

@ -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)

25
deps/uv/src/ares/CMakeLists.txt

@ -1,22 +1,27 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) cmake_minimum_required(VERSION 2.6)
include_directories(${node_platform}-${cares_arch})
project(ares)
string(TOLOWER ${CMAKE_SYSTEM_NAME} ares_platform)
include_directories(config_${ares_platform})
add_definitions(-DHAVE_CONFIG_H=1) add_definitions(-DHAVE_CONFIG_H=1)
include(CheckLibraryExists) include(CheckLibraryExists)
check_library_exists(socket socket "" HAVE_SOCKET_LIB) check_library_exists(socket socket "" HAVE_SOCKET_LIB)
check_library_exists(nsl gethostbyname "" HAVE_NSL_LIB) check_library_exists(nsl gethostbyname "" HAVE_NSL_LIB)
file(GLOB lib_sources *.c) file(GLOB ares_source *.c)
add_library(cares ${lib_sources}) add_library(ares ${ares_source})
if(${HAVE_SOCKET_LIB}) if(HAVE_SOCKET_LIB)
set(cares_libs ${cares_libs} socket) set(ares_libs ${ares_libs} socket)
endif() endif()
if(${HAVE_NSL_LIB}) if(HAVE_NSL_LIB)
set(cares_libs ${cares_libs} nsl) set(ares_libs ${ares_libs} nsl)
endif() endif()
if(cares_libs) if(ares_libs)
target_link_libraries(cares ${cares_libs}) target_link_libraries(ares ${ares_libs})
endif() endif()

23
deps/uv/src/eio/CMakeLists.txt

@ -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})

16
deps/uv/src/ev/CMakeLists.txt

@ -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)
Loading…
Cancel
Save