Skip to content

${CMAKE_SOURCE_DIR}/tools/version.py fails in FetchContent build #5205

Open
@dmalnati

Description

@dmalnati

When building jerryscript via CMake, using FetchContent, there is a visible error relating to executing version.py.

[cmake] python: can't open file 'C:/Users/dougl/git/playground/cmake/use3rdPartyLib/UseJerryScript/tools/version.py': [Errno 2] No such file or directory

Seems like it's the jerryscript/CMakeLists.txt entry of

# Determining version
execute_process(COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/tools/version.py
                OUTPUT_VARIABLE JERRY_VERSION
                OUTPUT_STRIP_TRAILING_WHITESPACE)

Does CMAKE_SOURCE_DIR, refer to my project when I use FetchContent? That's what the error implies. Seems like CMAKE_CURRENT_LIST_DIR might work as expected?

JerryScript revision

v3.0.0

Build platform

Windows-10-10.0.22631-SP0

Build steps
cmake_minimum_required(VERSION 3.15...3.31)

set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(PROJECT_NAME UseJerryScript)

project(${PROJECT_NAME} LANGUAGES CXX)


# Example 2
add_executable(api_ex2 api_ex2.cpp)
target_link_libraries(api_ex2 PRIVATE jerry-core jerry-port)

# Fetch JerryScript
include(FetchContent)

FetchContent_Declare(
  jerryscript
  GIT_REPOSITORY https://github.com/jerryscript-project/jerryscript.git
  GIT_TAG v3.0.0
)

FetchContent_MakeAvailable(jerryscript)
Build log
[cmake] python: can't open file 'C:/Users/dougl/git/playground/cmake/use3rdPartyLib/UseJerryScript/tools/version.py': [Errno 2] No such file or directory
Test case

n/a

Execution platform

n/a

Execution steps

n/a

Output

see above

Backtrace
Expected behavior

not error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions