Skip to content

Sanity check of missing CMakeLists.txt when running cmake-rn #151

Open
@kraenhansen

Description

@kraenhansen

When trying out cmake-rn in an empty project, it would be neat with a sanity check for the existence of a CMakeLists.txt file in the source directory.

The current experience of running cmake-rn in an empty folder is this:

❯ npx cmake-rn
ℹ Using default triplets (aarch64-linux-android, arm64-apple-ios-sim)
✖ Failed to configure projects: Running 'cmake' failed (code = 1)
CMake Error: The source directory "/Users/kraen.hansen/Repositories/node-api-example-lib" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
file:///Users/kraen.hansen/Repositories/node-api-example-lib/node_modules/bufout/dist/spawn.js:110
                reject(new SpawnFailure(command, args, code, signal, flushOutput));
                       ^

SpawnFailure [Error]: Running 'cmake' failed (code = 1)
    at ChildProcess.<anonymous> (file:///Users/kraen.hansen/Repositories/node-api-example-lib/node_modules/bufout/dist/spawn.js:110:24)
    at Object.onceWrapper (node:events:633:26)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12) {
  command: 'cmake',
  args: [
    '-S',
    '/Users/kraen.hansen/Repositories/node-api-example-lib',
    '-B',
    '/Users/kraen.hansen/Repositories/node-api-example-lib/build/aarch64-linux-android',
    '-D',
    'CMAKE_JS_INC=/Users/kraen.hansen/Repositories/node-api-example-lib/node_modules/node-api-headers/include;/Users/kraen.hansen/Repositories/node-api-example-lib/node_modules/node-addon-api',
    '-D',
    'CMAKE_JS_LIB=/Users/kraen.hansen/Repositories/node-api-example-lib/node_modules/react-native-node-api/weak-node-api/weak-node-api.android.node/arm64-v8a/libweak-node-api.so',
    '-D',
    'CMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/kraen.hansen/Repositories/node-api-example-lib/build/aarch64-linux-android/out',
    '-G',
    'Ninja',
    '--toolchain',
    '/Users/kraen.hansen/Library/Android/sdk/ndk/27.1.12297006/build/cmake/android.toolchain.cmake',
    '-D',
    'CMAKE_SYSTEM_NAME=Android',
    '-D',
    'CMAKE_MAKE_PROGRAM=ninja',
    '-D',
    'ANDROID_NDK=/Users/kraen.hansen/Library/Android/sdk/ndk/27.1.12297006',
    '-D',
    'ANDROID_ABI=arm64-v8a',
    '-D',
    'ANDROID_TOOLCHAIN=clang',
    '-D',
    'ANDROID_STL=c++_shared',
    '-D',
    'CMAKE_SHARED_LINKER_FLAGS='
  ],
  code: 1,
  signal: null,
  flush: [Function (anonymous)]
}

Node.js v22.15.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions