Skip to content

Only set CMAKE_EXECUTABLE_SUFFIX in toolchain if not defined already#22315

Closed
starball5 wants to merge 2 commits intoemscripten-core:mainfrom
starball5:patch-1
Closed

Only set CMAKE_EXECUTABLE_SUFFIX in toolchain if not defined already#22315
starball5 wants to merge 2 commits intoemscripten-core:mainfrom
starball5:patch-1

Conversation

@starball5
Copy link
Contributor

Fixes #18860

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change LGTM, but can you add a test for this (i.e. update one of the existing cmake tests so that it will fail without this change).

@sbc100
Copy link
Collaborator

sbc100 commented Aug 6, 2024

Looks like the test-other failures are geniune.

@aviallon
Copy link

Is that still needed, or should this be closed?

@sbc100
Copy link
Collaborator

sbc100 commented Feb 10, 2026

@starball5 would you have time to rebase and add a test? Or should someone else take a look?

sbc100 added a commit to sbc100/emscripten that referenced this pull request Feb 10, 2026
For some reason setting `CMAKE_EXECUTABLE_SUFFIX` from the command line
does not work, even though settings `CMAKE_EXECUTABLE_SUFFIX_<LANG>`
does work.  This seems to be true regardless of what I do in the
toolchain file.  Its also true for native/host cmake.

i.e. `-DCMAKE_EXECUTABLE_SUFFIX=.foo` has no effect but
`-DCMAKE_EXECUTABLE_SUFFIX_C=.foo` works.

Replaces: emscripten-core#22315
@sbc100
Copy link
Collaborator

sbc100 commented Feb 10, 2026

I tried to pick up this PR but I noticed that -DCMAKE_EXECUTABLE_SUFFIX=xx does not work from the command line ,even after this PR. It also doesn't work from the command line for native / host projects.

However, -DCMAKE_EXECUTABLE_SUFFIX_<LANG>=xx , does work. So I created a PR to test this: #26244.

Its unfortunate that -DCMAKE_EXECUTABLE_SUFFIX does not work but it seems to be a limitation of cmake and not emscripten.

@bradking maybe can you explain this seemingly behavior?

@bradking
Copy link

CMAKE_EXECUTABLE_SUFFIX was not designed to be set by end users or in the cache. It's normally set by the platform modules or toolchain files. If it needs to be changed for some use case, that needs to be modeled with other options such that the platform module knows to set the needed value.


set(CMAKE_EXECUTABLE_SUFFIX ".js")
if(NOT DEFINED CMAKE_EXECUTABLE_SUFFIX)
set(CMAKE_EXECUTABLE_SUFFIX ".js")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(NOT DEFINED CMAKE_EXECUTABLE_SUFFIX) may never be true because CMake's Modules/CMakeGenericSystem.cmake always sets a default empty value earlier. Therefore this change may regress the existing default.

@sbc100
Copy link
Collaborator

sbc100 commented Feb 11, 2026

Thanks @bradking. I suppose emscripten is a little strange in that we support different output file suffixes and each one comes with different output behaviour so users often want to set the output suffix themselves.

I think this PR can be closed than.

I might still try to land #26244.

@sbc100 sbc100 closed this Feb 11, 2026
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.

Using Emscripten in CMake doesn't output html

4 participants