Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dmalnati opened this issue Dec 20, 2024 · 2 comments
Open

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

dmalnati opened this issue Dec 20, 2024 · 2 comments

Comments

@dmalnati
Copy link

dmalnati commented Dec 20, 2024

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

@akosthekiss
Copy link
Member

@dmalnati Thank you for the issue report, but: can you please edit your report to

  • remove the unnecessary parts that are left over from the template ("First of all, when reporting a bug, give the issue a descriptive title....")
  • use triple backtick guards around code snippets to improve readability (it may only affect me, but at the moment, it is not completely clear what the build steps are)

@dmalnati
Copy link
Author

dmalnati commented Dec 20, 2024

@dmalnati Thank you for the issue report, but: can you please edit your report to

  • remove the unnecessary parts that are left over from the template ("First of all, when reporting a bug, give the issue a descriptive title....")
  • use triple backtick guards around code snippets to improve readability (it may only affect me, but at the moment, it is not completely clear what the build steps are)

Oh yeah sorry, hadn't realized what a disaster the entry looked like. Fixed now.

Long story short, when I bring in the jerryscript lib, into my project (called UseJerryScript), it looks like when I use FetchContent_MakeAvailable that the CMakeLists.txt within the root of jerryscript winds up looking for the ./tools/version.py within the UseJerryScript root folder as opposed to the correct root folder of jerryscript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants