Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
cmake: Various fixes.
Browse files Browse the repository at this point in the history
* Allow overriding install path with CMAKE_INSTALL_PREFIX.
* make sure js2min.py can be found when building out of source.
* Replace empty macros with void(0).
  Expressions like "debug(x) && foo()" fail if debug(x) is an empty macro.
* Make sure node-natives.h creation is deterministic.
* Fix version string.
  The copyright header made the node_version.h file larger
  than the previously set file read limit.
  • Loading branch information
thughes authored and bnoordhuis committed Aug 7, 2011
1 parent 3056c2c commit b267dc4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion cmake/configure.cmake
Expand Up @@ -33,10 +33,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..
Expand Down
14 changes: 9 additions & 5 deletions cmake/node_build.cmake
Expand Up @@ -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)
Expand All @@ -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")
Expand Down Expand Up @@ -138,5 +142,5 @@ install(FILES
src/node_version.h
${PROJECT_BINARY_DIR}/src/node_config.h

DESTINATION include/node
DESTINATION ${NODE_INCLUDE_PREFIX}/include/node
)
4 changes: 4 additions & 0 deletions cmake/package.cmake
Expand Up @@ -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
Expand Down

0 comments on commit b267dc4

Please sign in to comment.