Skip to content

Commit

Permalink
Fixes building with new version cmake
Browse files Browse the repository at this point in the history
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 9, 2021
1 parent c8a49ce commit 51c4c6c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 22 deletions.
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 @@ -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)
Expand All @@ -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()

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

Expand Down Expand Up @@ -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)

Expand Down
9 changes: 9 additions & 0 deletions cmake/jerry.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@ 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/
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

0 comments on commit 51c4c6c

Please sign in to comment.