Граф коммитов

52 Коммитов

Автор SHA1 Сообщение Дата
Sam Clegg 5c38582561
cmake: Default to installing into sysroot (#14293)
Assuming the user/project does not specify a CMAKE_INSTALL_PREFIX
to install to we can and should default to installing into the
emscripten sysroot.

Also, add a test that uses `cmake --install` to install a library and
the `finc_package` to find the library config.

This confirms that #6595 is fixed even though technicall the fix landed
in in #14291
2021-05-27 18:58:03 +02:00
Sam Clegg f56479d4e8
Update Emscripten.cmake to be aware of new sysroot location. (#14291)
Also, add more testing in order to verify that finding resources
inside the sysroot works as expected.

See: https://github.com/emscripten-core/emsdk/issues/824#
See: #6595

I'm not sure if this is also fixes #6595 and will likely followup with a
test for find_package.

Fixes: #10078
2021-05-27 04:04:07 +01:00
Sam Clegg 9d542882fe
Update cmake features with C++23 support (#14071)
This is needed for test_cmake_compile_features to pass after cmake
3.20.0.

This is needed to because something changed with the circleci macOS
image that cause the cmake version to go from 3.18.4 (cmake-3.18.4.catalina.bottle.tar.gz)
to 3.20.2.  Its not totally clear to me what changed on the circleci side but it seems like they
had to update homebrew in a hurry:
  https://discuss.circleci.com/t/macos-images-need-homebrew-update-urgently/39748/5
2021-05-01 13:07:02 -07:00
Sam Clegg 1fb4802149
Update Emscripten.cmake to support C++20 (#13616)
Co-authored-by: nowakowsk <64333006+nowakowsk@users.noreply.github.com>
2021-03-07 12:37:56 -08:00
Benedikt Meurer 0881d95a25
Don't change default CMake compiler / linker flags (#13083)
It's a bit of a surprise that `Emscripten.cmake` overrides the
defaults for CMake's C/C++ compiler and linker flags. In particular
`RelWithDebInfo` by default doesn't include debugging information.
From the history of this file it wasn't clear why this decision was
made in the first place, but nowadays there doesn't seem to be a
good reason to keep doing it.
2021-01-07 02:43:10 -08:00
Sam Clegg e61e33c96b
Remove fastcomp support from Emscripten.cmake (#13085) 2020-12-22 09:28:20 -08:00
Sam Clegg 3abb4a6993
Output executables by default. (#11799)
Only output object files if `-c`, `-r` or `-shared` is specified.

We have a `link_to_object` mode which was previously used by default
if the output didn't end with EXECUTABLE_ENDINGS.  After this change
`link_to_object` is only used if `-r` or `-shared` are passed
explicitly.

This allows linking executables (JS files) with arbitrary extensions.
For example, I can do `emcc foo.c -o foo.txt` and I will actually get a
JS file called `foo.txt`.  This matches the behaviour of clang and gcc.

This removes some rather unhelpful errors and warnings that we were
needless generating when this `link_to_object` mode was automatically
triggered.

It also allowed me to do some refactoring to move js_target and
final_suffix declarations closer to their actual first use.

See: #11753
Replaces: #7697
2020-09-14 18:16:26 -07:00
Clément Grégoire 3e2c1073f0
CMake toolchain file should cache CMAKE_*_COMPILER (#11832) 2020-08-31 10:02:37 -07:00
Bruce Mitchener ef108c67d9
cmake: Add missing -DNDEBUG flag to RelWithDebInfo. (#12084)
When building in RelWithDebInfo mode, you want debug info (-g)
but not debug code. Most compilers in the cmake distribution
enable -DNDEBUG in all release configurations.
2020-08-31 08:21:06 -07:00
Sam Clegg 2b6e3aff45
Remove asmjs validation (#11551)
This only ever worked in spidermonkey and I don't think we care
about asmjs validation anymore anyway.

Perhaps this should wait until after we remove fastcomp which is the
only route to generating valid asm.js that we still maintain.
2020-08-11 15:08:05 -07:00
Gabriel bb2dc5015d
Allow overwriting of CMAKE_FIND_ROOT_PATH_MODE_LIBRARY & INCLUDE & PACKAGE (#10184) 2020-06-19 13:32:56 -07:00
Paul Du 05110865e4
Fix CMake compilation for static libraries with IPO (#11143) (#11161) 2020-05-14 16:36:38 -07:00
Sam Clegg 5509b8c7e6
Disable EMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES under the wasm backend (#10909)
With the wasm backend there is not reason not to use `.a` archives,
even in LTO builds.
2020-04-17 16:39:27 -07:00
Sam Clegg bbc4d8f5da
A couple of cmake cleanups. NFC. (#10934)
These are the NFC parts #10909.
2020-04-16 10:25:21 -07:00
Sam Clegg b5512c43d2
Tidy up Emscripten.cmake. NFC (#10908)
- Convert tabs to spaces
- Remove trailing whitespace
- Reflow comments
- Consistent use of set() over SET()
2020-04-14 11:04:32 -07:00
Derek Schuff 0428a433a2
Update the list of CXX_COMPILE_FEATURES in Emscripten.cmake to include C++20 (#9794)
Newer versions of CMake recognize cxx_std_20 as a thing that a compiler
frontend can support, and indeed the emscripten frontend supports it.
2019-11-06 17:38:34 -08:00
András Kucsma 0ab4e43873 Remove cmake_minimum_required call from Emscripten.cmake (#9706)
Toolchain cmakes generally don't define cmake_minimum_required.
See official toolchains here:
https://github.com/Kitware/CMake/tree/master/Modules/Platform

This also eliminates possible CMP0063 warnings coming from
`em_link_js_library` and similar when using cmake 3.3.0 or newer.
2019-10-29 10:27:09 -07:00
Bruce Mitchener 75272370ee cmake: Update to work with cmake 3.15 and later. (#9102)
CMake 3.15 and later weren't correctly handling `CMAKE_CXX_STANRDARD`
and friends when using the emscripten cmake modules. This was because
there is a new variable that needs to be set to indicate whether
the compiler is using GNU or MSVC command line options.

Fixes #9100
2019-07-30 13:50:39 -07:00
Alon Zakai e3aa5c006a
Remove cmake WASM=0 hack (#8851)
It was there because we couldn't rely on wasm support being in node, but these days it is in node LTS (and in the node we ship with the emsdk). Using wasm avoids using wasm2js there which might be a problem with the wasm backend, as it doesn't support 100% of features.

There is some risk here - wasm does behave differently in some ways, like having a separate file, having async startup. Without seeing a concrete problem though it's not worth trying to add hacks for those things. But I do worry that we don't have enough test coverage here, as this PR fixes #8848 (see more details there) which noticed issues we don't cover in the test suite (but that I'm not sure are worth adding - basically, things that wasm2js can't do).
2019-06-25 05:44:21 -07:00
Sam Clegg 3426a347ea
Set TARGET_SUPPORTS_SHARED_LIBS in cmake config (#8362)
This means we don't need to specify -DBUILD_SHARED_LIBS=OFF since
it will effectively be the default.
2019-04-01 15:51:11 -07:00
Shane Peelar c3e93f3bf1 Update Emscripten.cmake to support C++17 (#8030)
These simple changes allow for C++17 support in CMake projects with
Emscripten:
~~~
set(CMAKE_CXX17_COMPILE_FEATURES "cxx_std_17")
~~~
Tested both sdk-incoming-64bit and sdk-wasm-master-64bit.
Modified line was pulled from a known working generated `CMakeCXXCompiler.cmake` by CMake (version `3.13.4`)
2019-02-12 21:00:56 +02:00
Alon Zakai (kripken) 329faa388d update links to emsdk, now that it is in emscripten-core/ 2019-01-21 23:50:06 +02:00
Sam Clegg feb5be841f
Remove ERROR_ON_UNDEFINED_SYMBOLS=1 from tests and other places since it is now the default (#7282)
Also remove no longer relevant FAQ question.
2018-10-15 04:32:19 -07:00
Sam Clegg a1958e2e56
Output emscripten version info to stderr (#7064)
This matches what clang and gcc do.  This change specifically
fixes `other.test_cmake` with the llvm backend, because the cmake
code that checks for emscripten was checking for the word
emscripten in stderr and not stdout.

For the fastcomp this is fine because the word emscripten appears
in the stderr of `clang -v`, but for the llvm backend we rely on
the first line of `emcc -v` output which contains the word emscripten.

For reference once the output `emcc -v` is something like like this:

```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.38.11
clang version 8.0.0 (trunk 340421) (llvm/trunk 340423)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/sbc/dev/wasm/llvm-build/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8.0.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8.0.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

Prior to this change the first line went to stdout and the rest
to stderr.
2018-08-29 20:47:26 -07:00
juj c39a45d9a5 Add EMSCRIPTEN_VERSION variable to user CMake scripts (#6809)
Add EMSCRIPTEN_VERSION variable to user CMake scripts so that they can do

if ("${EMSCRIPTEN_VERSION}" VERSION_GREATER 1.38.6)

to check for a particular Emscripten version.
2018-07-05 10:05:48 -07:00
Alon Zakai 6e5818017d
Emit WebAssembly by default (#6419)
This changes the default output from asm.js to WebAssembly. Only the default is changed - we of course still support asm.js, and will for a very long time. But changing the default makes sense as the recommended output for most use cases should be WebAssembly, given it has shipped in all major browsers and platforms and is more efficient than asm.js.

The main changes in this PR are:

*    The actual flipping of the switch to wasm.
*    Cleanups in emcc.py and emscripten.py for that flag change - I swapped all BINARYEN to WASM, which made reading the a code a lot easier, at least for me. I also added some clearer warnings/errors for mismatched flags (features we just support in asm.js, like split memory).
*    Update the test suite. A lot of tests required some changes, e.g. because some are actually asm.js tests (so we must force wasm off) or they assume sync startup (which wasm does not do by default), etc. This is a big change, but nothing really sophisticated there.
*    Update the tutorial, FAQ, optimization docs, etc.
*    Make LEGACY_VM_SUPPORT flip off wasm. When targeting old VMs, IE11, etc., wasm doesn't make sense. As a result, this PR should not break code using that option.
*    Without the EMCC_BROWSER_ALSO_ASMJS env var, we just run browser tests normally (using wasm, unless a test says otherwise). But pthreads tests we run in asm.js since wasm isn't stable yet. And with that env var, we run the test also in asm.js mode (we don't need the extra also_asmjs arg to do that, can just look at the arguments, do they disable wasm or not).
2018-05-09 19:44:18 -07:00
Jukka Jylänki d29fcc9321 Reset minimum required CMake version to CMake 3.0.0, because the original minimum required version bump from https://github.com/kripken/emscripten/commit/a151ef1485 was not strictly necessary. Fixes https://github.com/juj/emsdk/issues/108 2017-10-24 14:31:57 +03:00
Jukka Jylänki 078ea51843 Fix CMake compiler version detection regex and test other.test_cmake on macOS 10.12.6 with CMake 3.7.2 2017-10-24 14:31:57 +03:00
Jukka Jylänki c7b995bac4 Advertise C & C++ standard according to how CMake 3.8 detects them in Emscripten CMake toolchain. 2017-06-19 11:41:55 +03:00
Jukka Jylanki 08ff3c3c1a Accept both 'Emscripten' and 'emscripten' when detecting emcc in CMake. #5203 2017-05-09 13:21:04 +03:00
Jukka Jylanki 909e396f56 Fix Emscripten compiler detection in CMake when EMCC_SKIP_SANITY_CHECK=1 is specified, and add a test. Fixes #5145. 2017-05-05 14:51:47 +03:00
Jacob Gravelle a255996e21 Remove unnecessary specification of CMAKE_(C|CXX)_COMPILER_TARGET
We already pass -target=LLVM_TARGET, no need to hardcode the triple for
libraries.
2016-11-14 09:52:17 -08:00
Jukka Jylänki a3456ef978 Add CMake option -DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=ON which can be used to make Emscripten CMake builds generate LLVM bitcode files as static libraries as opposed to the default UNIX ar archives. 2016-10-27 16:36:07 +03:00
Jukka Jylänki bc40d00348 Don't do CMake compiler autodetection for Emscripten, since CMake doesn't know about Emscripten toolchain. Instead report the supported features from the module toolchain, and add a test that those are correct. Supercedes #4138. 2016-09-21 16:00:04 +03:00
Jukka Jylänki 69a2d54820 Perform compiler IDing manually in Emscripten toolchain to set `CMAKE_C_STANDARD_COMPUTED_DEFAULT` and `CMAKE_CXX_STANDARD_COMPUTED_DEFAULT` variables. Fixes #4129 and supercedes #4134. Also refactor other.test_cmake to do fewer permutations of the test, because CMake detection code is slow and there's too many cases to try all of them. Thanks to @Lectem for the test case. 2016-09-21 14:22:06 +03:00
Jukka Jylänki 777bc91e7b Clarify comment on EMSCRIPTEN_FORCE_COMPILERS 2016-08-17 13:47:14 +03:00
Alexandre Pretyman 01e0fc581d Emscripten.cmake: use list(APPEND CMAKE_FIND_ROOT_PATH ...)
Do no overwrite CMAKE_FIND_ROOT_PATH, this enables 3rd party
extensions to emscripten CMake scripts, such as *Config.cmake files to
emulate emscripten's built in libraries
2016-08-14 16:33:44 -03:00
Alexandre Pretyman 36531a9750 Emscripten.cmake: CMakeForceCompilers OPTION defaulted to OFF
CMakeForceCompilers not to be used with CMake 3.5+
https://cmake.org/cmake/help/v3.5/module/CMakeForceCompiler.html
2016-08-12 23:15:06 -03:00
Alexandre Pretyman 48b6d54f1c Emscripten.cmake: use list(APPEND CMAKE_MODULE_PATH ...)
Removes unecessary code
2016-08-12 23:15:06 -03:00
Jukka Jylänki a151ef1485 Require CMake 3.4.3 in Emscripten toolchain file to establish a minimum version baseline for testing purposes. This is a good version to pick, since LLVM now requires CMake 3.4.3 as well. 2016-08-11 14:26:07 +03:00
mhenschel b2661be003 Treat js-libraries as libraries in cmake 2015-10-21 18:25:09 +02:00
Jukka Jylänki bf4aaf08b5 Advertise CMAKE_SYSTEM_PROCESSOR=x86 when building with CMake (as opposed to CMAKE_SYSTEM_PROCESSOR=x86_64 for 64-bit platform). Helps with OpenCV CMake build detection. 2015-08-16 21:01:41 +03:00
Matt McCormick 832d95d92d Add support for CMAKE_CROSSCOMPILING_EMULATOR.
This variable was added in recent CMake Git master.  It should point to an
executable that acts like an emulator for the target system when
cross-compiling.  For emscripten, this is nodejs.

This executable is used by CMake to run executables in try_run commands.  By
adding support for this variable, it prevents the need to manually populate
the tedious TryRunResults.cmake file.

The emscripten configured path to NodeJS is added to the emcmake command.  In
the Emscripten.cmake file, if CMAKE_CROSSCOMPILING_EMULATOR is not defined
(which is would be if using emcmake), and attempt is made to find nodejs and
use it.
2015-05-12 09:57:57 -04:00
Jukka Jylänki 07684f25c9 Restore CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER, since it is useful to find_program() for external system utilities. 2014-09-17 21:48:51 +03:00
Jukka Jylänki 945cb74230 As per jP_wanN's comment, fix the CMake toolchain file find feature to never look at native system directories, but only look at CMAKE_FIND_ROOT_PATH. 2014-09-17 21:24:14 +03:00
Nicholas Wilson b0d12cc455 tell cmake that there is no library for dlopen on emscripten (shuts up warnings "emcc: cannot find library "dl"" for projects that add CMAKE_DL_LIBS to the link line) 2014-09-04 10:09:58 +01:00
Jukka Jylänki cb2cb14604 Fix EMSCRIPTEN root path search in CMake toolchain file. 2014-07-12 13:07:40 +03:00
Jukka Jylänki c064ab8e40 Restore the soname symlink generation feature when using CMAKE_SYSTEM_NAME "Emscripten", like the previous CMAKE_SYSTEM_NAME "Linux" did. This lets test_openjpeg generate output files with same file names as before the system name change. 2014-07-10 20:40:08 +03:00
Jukka Jylänki 2e3b8c817e After previous toolchain directory/include structure change, UNIX=1 was not getting set by default, so set that to Emscripten CMake toolchain manually now. 2014-07-10 20:18:36 +03:00
Jukka Jylänki 789c8ca33c Add explicit support for CMake CMakeBackwardsCompatibilityC.cmake detection logic for Emscripten, without running through test builds which have issues with endianness detection. 2014-07-10 20:17:50 +03:00