Description
I have preparered a minimal CMAKE project containing 2 *.cpp files in order to show the problem
https://github.com/courteous/wasmSideModule
After a bran new installation of emscripten on ubuntu server 18.04.3 i have noticed the following problem
after i run:
cd build
emconfigure cmake ../ -DCMAKE_BUILD_TYPE=WASM
emmake make
i get the following warrning/error:
shared:INFO: (Emscripten: Running sanity checks)
shared:WARNING: ignoring -fPIC flag when not building with SIDE_MODULE or MAIN_MODULE
shared:ERROR: treating warnings as errors (-Werror)
If i disable the line in the main CMakeLists.txt which is responsible for the -fPIC option, then the projects compiles successfully.
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
However I would like to understand why setting the "MAIN_MODULE=1" in the set_target_properties CMAKE does not disable this warning/error
i.e. from the main CMakeLists.txt
set_target_properties(wasmExec PROPERTIES LINK_FLAGS "-std=c++17 -s MAIN_MODULE=1 -s WASM=1 -s TOTAL_MEMORY=512MB -s ALLOW_MEMORY_GROWTH=0 -s NO_EXIT_RUNTIME=1 -s VERBOSE=1 -s DEMANGLE_SUPPORT=1 -s DISABLE_EXCEPTION_CATCHING=0 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s EXTRA_EXPORTED_RUNTIME_METHODS='['cwrap', 'getValue', 'setValue']' " )
this is related to #10209