-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
Hey there,
The output flag "-o" for emcc seems to be overwritten when using together with CMake. Instead the target name is used.
As I post this here, I hope this is more an error of emscripten and not just me being stupid :)
Here is a minimal example that reproduces this inconvenience:
CMakeLists.txt
cmake_minimum_required(VERSION 3.5.0)
set(CMAKE_VERBOSE_MAKEFILE ON)
add_definitions(-std=c++11)
add_executable(targetname main.cpp)
set_target_properties(targetname PROPERTIES LINK_FLAGS "-o thing.js")
main.cpp
#include <stdio.h>
int main() {
printf("hello, world!\n");
return 0;
}
calling cmake:
cmake -DCMAKE_TOOLCHAIN_FILE=(..)/1.37.37/cmake/Modules/Platform/Emscripten.cmake .
cmake version is 3.5.1
When calling make (Version: GNU Make 4.1) some of the output looks like this:
[ 50%] Building CXX object CMakeFiles/targetname.dir/main.cpp.o
/home/wattux/src/emsdk/emscripten/1.37.37/em++ -std=c++11 -o CMakeFiles/targetname.dir/main.cpp.o -c /home/wattux/src/emscripten/main.cpp
[100%] Linking CXX executable targetname.js
/usr/bin/cmake -E cmake_link_script CMakeFiles/targetname.dir/link.txt --verbose=1
/home/wattux/src/emsdk/emscripten/1.37.37/em++ -o thing.js @CMakeFiles/targetname.dir/objects1.rsp -o targetname.js
In the last output line, one can see the second "-o" flag, which will apparently overwrite the first one (which is the correct behaviour, I'd say).
I looked at the toolchain file Emscripten.cmake and at line 188, 189 it states:
SET(CMAKE_C_CREATE_STATIC_LIBRARY "<CMAKE_C_COMPILER> -o <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_CXX_COMPILER> -o <TARGET> <LINK_FLAGS> <OBJECTS>")
This is nothing but a wild guess, but maybe this will overwrite my own "-o" flag?
Big thanks in advance!