Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 [email protected]
  • Loading branch information
lygstate committed Feb 5, 2021
commit df474aa6dc9221d4f35cf69dc6d270e98c9bf73c
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -94,8 +94,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)
Expand All @@ -104,7 +103,7 @@ else()
endif()
endif()

if (CREATE_SHARED_LIB)
if (CREATE_SHARED_LIB AND NOT USING_MSVC)
iotjs_add_compile_flags(-fPIC)
endif()

Expand Down
35 changes: 17 additions & 18 deletions cmake/iotjs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,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()

Expand Down Expand Up @@ -513,22 +513,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)

Expand Down
9 changes: 9 additions & 0 deletions cmake/jerry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@ set(JERRY_HOST_BUILD_BYPRODUCTS
${JERRY_HOST_SNAPSHOT}
)

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/
BUILD_IN_SOURCE 0
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}
Expand Down