Skip to content

Commit 5b63ff7

Browse files
committed
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]
1 parent 32a3114 commit 5b63ff7

File tree

3 files changed

+25
-22
lines changed

3 files changed

+25
-22
lines changed

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
cmake_minimum_required(VERSION 2.8)
15+
cmake_minimum_required(VERSION 3.5)
1616
include(CheckCCompilerFlag)
1717

1818
project(IOTJS C)
@@ -94,8 +94,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
9494
if(HAS_NO_PIE AND NOT "${TARGET_OS}" STREQUAL "darwin")
9595
iotjs_add_link_flags(-no-pie)
9696
endif()
97-
else()
98-
97+
elseif(HAS_NO_PIE)
9998
iotjs_add_compile_flags(-fPIE)
10099
if("${TARGET_OS}" STREQUAL "darwin")
101100
iotjs_add_link_flags(-Wl,-pie)
@@ -104,7 +103,7 @@ else()
104103
endif()
105104
endif()
106105

107-
if (CREATE_SHARED_LIB)
106+
if (CREATE_SHARED_LIB AND NOT USING_MSVC)
108107
iotjs_add_compile_flags(-fPIC)
109108
endif()
110109

cmake/iotjs.cmake

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,11 @@ set(IOTJS_INCLUDE_DIRS
446446

447447
if(NOT BUILD_LIB_ONLY)
448448
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
449-
iotjs_add_link_flags("-Xlinker -map -Xlinker iotjs.map")
449+
iotjs_add_link_flags(-Wl,-map,iotjs.map)
450450
elseif(USING_MSVC)
451-
iotjs_add_link_flags("/MAP:iotjs.map")
451+
iotjs_add_link_flags("-MAP:iotjs.map")
452452
else()
453-
iotjs_add_link_flags("-Xlinker -Map -Xlinker iotjs.map")
453+
iotjs_add_link_flags(-Xlinker -Map=iotjs.map)
454454
endif()
455455
endif()
456456

@@ -513,22 +513,17 @@ else()
513513
file(READ "${IOTJS_SOURCE_DIR}/napi/node_symbols.txt" NODE_SYMBOLS)
514514
string(REGEX REPLACE "[\r|\n]" ";" NODE_SYMBOLS "${NODE_SYMBOLS}")
515515

516-
if(USING_MSVC)
517-
set(NODE_SYMBOL_SEPARATOR " /INCLUDE:")
518-
if("${TARGET_ARCH}" STREQUAL "i686")
519-
set(NODE_SYMBOL_SEPARATOR "${NODE_SYMBOL_SEPARATOR}_")
520-
endif()
521-
else()
522-
set(NODE_SYMBOLS_LINK_FLAGS "-Wl")
523-
set(NODE_SYMBOL_SEPARATOR ",-u,")
524-
endif()
525-
526516
foreach(NODE_SYMBOL ${NODE_SYMBOLS})
527-
set(NODE_SYMBOLS_LINK_FLAGS
528-
"${NODE_SYMBOLS_LINK_FLAGS}${NODE_SYMBOL_SEPARATOR}${NODE_SYMBOL}")
529-
endforeach()
530-
531-
iotjs_add_link_flags(${NODE_SYMBOLS_LINK_FLAGS})
517+
if(USING_MSVC)
518+
if("${TARGET_ARCH}" STREQUAL "i686")
519+
iotjs_add_link_flags("/INCLUDE:_${NODE_SYMBOL}")
520+
else()
521+
iotjs_add_link_flags("/INCLUDE:${NODE_SYMBOL}")
522+
endif()
523+
else()
524+
iotjs_add_link_flags("-Wl,-u,${NODE_SYMBOL}")
525+
endif()
526+
endforeach()
532527
endif()
533528
endif(CREATE_SHARED_LIB)
534529

cmake/jerry.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,22 @@ set(JERRY_HOST_BUILD_BYPRODUCTS
2222
${JERRY_HOST_SNAPSHOT}
2323
)
2424

25+
if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
26+
set(JERRY_HOST_C_FLAGS_INIT "-Wno-error=maybe-uninitialized")
27+
endif()
28+
29+
if (USING_MSVC)
30+
set(JERRY_HOST_C_FLAGS_INIT "-DWIN32")
31+
endif()
32+
2533
ExternalProject_Add(hostjerry
2634
PREFIX ${DEPS_HOST_JERRY}
2735
SOURCE_DIR ${ROOT_DIR}/deps/jerry/
2836
BUILD_IN_SOURCE 0
2937
BINARY_DIR ${DEPS_HOST_JERRY}
3038
CMAKE_ARGS
3139
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
40+
-DCMAKE_C_FLAGS=${JERRY_HOST_C_FLAGS_INIT}
3241
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/${DEPS_HOST_JERRY}
3342
-DENABLE_ALL_IN_ONE=ON
3443
-DENABLE_LTO=${ENABLE_LTO}

0 commit comments

Comments
 (0)