From 51c4c6c3c70a1ee8a7e418802d88071edc4f639d Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 26 Jan 2021 16:41:53 +0800 Subject: [PATCH] Fixes building with new version cmake iotjs_add_flags works on list instead of string. Also fixes flags not support MSVC IoT.js-DCO-1.0-Signed-off-by: Yonggang Luo luoyonggang@gmail.com --- CMakeLists.txt | 7 +++---- cmake/iotjs.cmake | 35 +++++++++++++++++------------------ cmake/jerry.cmake | 9 +++++++++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cab35a7e1..b17341182d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5) include(CheckCCompilerFlag) project(IOTJS C) @@ -88,8 +88,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") if(HAS_NO_PIE AND NOT "${TARGET_OS}" STREQUAL "darwin") iotjs_add_link_flags(-no-pie) endif() -else() - +elseif(HAS_NO_PIE) iotjs_add_compile_flags(-fPIE) if("${TARGET_OS}" STREQUAL "darwin") iotjs_add_link_flags(-Wl,-pie) @@ -98,7 +97,7 @@ else() endif() endif() -if (CREATE_SHARED_LIB) +if (CREATE_SHARED_LIB AND NOT USING_MSVC) iotjs_add_compile_flags(-fPIC) endif() diff --git a/cmake/iotjs.cmake b/cmake/iotjs.cmake index 2216f12e4c..2aaffc10b0 100644 --- a/cmake/iotjs.cmake +++ b/cmake/iotjs.cmake @@ -448,11 +448,11 @@ set(IOTJS_INCLUDE_DIRS if(NOT BUILD_LIB_ONLY) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") - iotjs_add_link_flags("-Xlinker -map -Xlinker iotjs.map") + iotjs_add_link_flags(-Wl,-map,iotjs.map) elseif(USING_MSVC) - iotjs_add_link_flags("/MAP:iotjs.map") + iotjs_add_link_flags("-MAP:iotjs.map") else() - iotjs_add_link_flags("-Xlinker -Map -Xlinker iotjs.map") + iotjs_add_link_flags(-Xlinker -Map=iotjs.map) endif() endif() @@ -515,22 +515,21 @@ else() file(READ "${IOTJS_SOURCE_DIR}/napi/node_symbols.txt" NODE_SYMBOLS) string(REGEX REPLACE "[\r|\n]" ";" NODE_SYMBOLS "${NODE_SYMBOLS}") - if(USING_MSVC) - set(NODE_SYMBOL_SEPARATOR " /INCLUDE:") - if("${TARGET_ARCH}" STREQUAL "i686") - set(NODE_SYMBOL_SEPARATOR "${NODE_SYMBOL_SEPARATOR}_") - endif() - else() - set(NODE_SYMBOLS_LINK_FLAGS "-Wl") - set(NODE_SYMBOL_SEPARATOR ",-u,") - endif() - foreach(NODE_SYMBOL ${NODE_SYMBOLS}) - set(NODE_SYMBOLS_LINK_FLAGS - "${NODE_SYMBOLS_LINK_FLAGS}${NODE_SYMBOL_SEPARATOR}${NODE_SYMBOL}") - endforeach() - - iotjs_add_link_flags(${NODE_SYMBOLS_LINK_FLAGS}) + if(USING_MSVC) + if("${TARGET_ARCH}" STREQUAL "i686") + iotjs_add_link_flags("/INCLUDE:_${NODE_SYMBOL}") + else() + iotjs_add_link_flags("/INCLUDE:${NODE_SYMBOL}") + endif() + else() + if("${TARGET_OS}" STREQUAL "DARWIN") + iotjs_add_link_flags("-Wl,-u,_${NODE_SYMBOL}") + else() + iotjs_add_link_flags("-Wl,-u,${NODE_SYMBOL}") + endif() + endif() + endforeach() endif() endif(CREATE_SHARED_LIB) diff --git a/cmake/jerry.cmake b/cmake/jerry.cmake index b86ab9f166..1cb156f8fc 100644 --- a/cmake/jerry.cmake +++ b/cmake/jerry.cmake @@ -16,6 +16,14 @@ cmake_minimum_required(VERSION 2.8) # Host jerry for snapshot generation set(DEPS_HOST_JERRY deps/jerry-host) +if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + set(JERRY_HOST_C_FLAGS_INIT "-Wno-error=maybe-uninitialized") +endif() + +if (USING_MSVC) + set(JERRY_HOST_C_FLAGS_INIT "-DWIN32") +endif() + ExternalProject_Add(hostjerry PREFIX ${DEPS_HOST_JERRY} SOURCE_DIR ${ROOT_DIR}/deps/jerry/ @@ -23,6 +31,7 @@ ExternalProject_Add(hostjerry BINARY_DIR ${DEPS_HOST_JERRY} CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_FLAGS=${JERRY_HOST_C_FLAGS_INIT} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY} -DENABLE_AMALGAM=ON -DENABLE_LTO=${ENABLE_LTO}