Skip to content

Fix CMake config installation path to match package name - #1479

Merged
saghul merged 2 commits into
quickjs-ng:masterfrom
qr243vbi:patch-1
May 19, 2026
Merged

saghul merged 2 commits into
quickjs-ng:masterfrom
qr243vbi:patch-1

Conversation

@qr243vbi

@qr243vbi qr243vbi commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

The qjsConfig.cmake should be named as quickjsConfig.cmake instead, in order to match the package name and help CMake (the find_package(quickjs) command) find the requested library configuration.

@saghul

saghul commented May 17, 2026

Copy link
Copy Markdown
Contributor

What is this fixing?

@qr243vbi

Copy link
Copy Markdown
Contributor Author

What is this fixing?

qjs not found error

@bnoordhuis

Copy link
Copy Markdown
Contributor

Isn't that just you using the wrong path? Can you show what you tried to do in your own cmake files that errored?

@qr243vbi

Copy link
Copy Markdown
Contributor Author

find_package(qjs CONFIG QUIET)

@saghul

saghul commented May 18, 2026

Copy link
Copy Markdown
Contributor

I guess this is because the target name is qjs and thus cmake generates that directory?

What would it take to change it to "quickjs" so projects do find_package(quickjs CONFIG QUIET)

instead?

@CarterLi

Copy link
Copy Markdown
Contributor

@saghul sorry for a duplicate PR.

What would it take to change it to "quickjs" so projects do find_package(quickjs CONFIG QUIET)

find_package(%pkgname%) will search ${prefix}/lib/cmake/%pkgname%/%pkgname%Config.cmake

So if you do find_package(quickjs CONFIG QUIET), CMake will search ${prefix}/lib/cmake/quickjs/quickjsConfig.cmake, which doesn't exist either.

install(EXPORT qjsConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/quickjs)

This line will generate ${CMAKE_INSTALL_LIBDIR}/cmake/quickjs/qjsConfig.cmake, we must either change EXPORT qjsConfig to EXPORT quickjsConfig (find_package(quickjs) will work in this case), or change DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/quickjs to DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qjs

@qr243vbi qr243vbi changed the title Fix quickjs cmake config Fix CMake config installation path to match package name May 19, 2026
@qr243vbi

qr243vbi commented May 19, 2026 •

Copy link
Copy Markdown
Contributor Author

I guess this is because the target name is qjs and thus cmake generates that directory?

What would it take to change it to "quickjs" so projects do find_package(quickjs CONFIG QUIET)

instead?

No, that does not work. I tried both find_package(quickjs CONFIG QUIET) and find_package(qjs CONFIG QUIET), but neither works due to a bug in CMakeLists.txt of quickjs-ng. I renamed qjsConfig to quickjsConfig, which made find_package(quickjs CONFIG QUIET) work correctly.

@saghul

saghul commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

I think keeping things as is (plus this PR) is the right thing to do now, otherwise everyone might need to adapt their CMake files.

We can reconsider that for 1.0 maybe.

EDIT: Nevermind, I mixed the 2 PRs. I'm landing this.

@saghul
saghul merged commit 32eb2ce into quickjs-ng:master May 19, 2026
124 checks passed
@CarterLi

CarterLi commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

fd461ce introduces another inconsistency: the package name is quickjs but exposes a target named qjs. So I have to write find_package(quickjs) target_link_libraries(myproject PRIVATE qjs). This is even more problematic when variables are used

find_package(${CMAKE_PACKAGE_NAME})
if (${CMAKE_PACKAGE_NAME}_FOUND)
    if (${CMAKE_PACKAGE_NAME} STREQUAL quickjs)
        set(CMAKE_PACKAGE_NAME qjs)
    endif()
    target_link_libraries(myproject PRIVATE ${CMAKE_PACKAGE_NAME})
endif()

This is frustrating‌. @saghul Can we change the package name back to qjs?

@saghul

saghul commented May 20, 2026

Copy link
Copy Markdown
Contributor

Fair point, we want the least amount of disruption.

@saghul

saghul commented May 20, 2026

Copy link
Copy Markdown
Contributor

Would you like to send a PR?

@CarterLi

Copy link
Copy Markdown
Contributor

@saghul #1499

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

Successfully merging this pull request may close these issues.

4 participants