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 Jan 30, 2021
1 parent 7fdafb0 commit fa97473
Show file tree
Hide file tree
Showing 3 changed files with 25 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
31 changes: 13 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,17 @@ 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()
iotjs_add_link_flags("-Wl,-u,${NODE_SYMBOL}")
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_ALL_IN_ONE=ON
-DENABLE_LTO=${ENABLE_LTO}
Expand Down

0 comments on commit fa97473

Please sign in to comment.