Skip to content

Commit 44a81d6

Browse files
committed
Handle cmake flags properly
Use if DEFINED to make sure the flag still setup when it's defined and value to NO separate_arguments(EXTRA_JERRY_CMAKE_PARAMS) at the beginning. IoT.js-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
1 parent df474aa commit 44a81d6

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ if(NOT DEFINED ENABLE_LTO)
5555
set(ENABLE_LTO OFF)
5656
endif()
5757

58+
if(NOT DEFINED JERRY_LINE_INFO)
59+
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
60+
message("Line info default enabled in debug mode")
61+
set(JERRY_LINE_INFO ON)
62+
else()
63+
message("Line info default disabled in non debug mode")
64+
set(JERRY_LINE_INFO OFF)
65+
endif()
66+
endif()
67+
5868
macro(iotjs_add_flags VAR)
5969
foreach(_flag ${ARGN})
6070
set(${VAR} "${${VAR}} ${_flag}")

cmake/jerry.cmake

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if (USING_MSVC)
3030
set(JERRY_HOST_C_FLAGS_INIT "-DWIN32")
3131
endif()
3232

33+
separate_arguments(EXTRA_JERRY_CMAKE_PARAMS)
34+
3335
ExternalProject_Add(hostjerry
3436
PREFIX ${DEPS_HOST_JERRY}
3537
SOURCE_DIR ${ROOT_DIR}/deps/jerry/
@@ -45,10 +47,10 @@ ExternalProject_Add(hostjerry
4547
-DJERRY_CMDLINE_SNAPSHOT=ON
4648
-DJERRY_EXT=ON
4749
-DJERRY_LOGGING=ON
50+
-DJERRY_LINE_INFO=${JERRY_LINE_INFO}
4851
-DJERRY_ERROR_MESSAGES=ON
4952
-DJERRY_SNAPSHOT_SAVE=${ENABLE_SNAPSHOT}
5053
-DJERRY_PROFILE=${JERRY_PROFILE}
51-
-DJERRY_LINE_INFO=${JERRY_LINE_INFO}
5254
${EXTRA_JERRY_CMAKE_PARAMS}
5355

5456
# The snapshot tool does not require the system allocator
@@ -70,7 +72,7 @@ set_property(TARGET jerry-snapshot PROPERTY
7072

7173
# Utility method to add -D<KEY>=<KEY_Value>
7274
macro(add_cmake_arg TARGET_ARG KEY)
73-
if(${KEY})
75+
if(DEFINED ${KEY})
7476
list(APPEND ${TARGET_ARG} -D${KEY}=${${KEY}})
7577
endif()
7678
endmacro(add_cmake_arg)
@@ -112,7 +114,7 @@ endif()
112114

113115
# Add a few cmake options based on buildtype/external cmake defines
114116
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
115-
list(APPEND DEPS_LIB_JERRY_ARGS -DJERRY_ERROR_MESSAGES=ON)
117+
set(JERRY_ERROR_MESSAGES ON)
116118
endif()
117119

118120
# NuttX is not using the default port implementation of JerryScript
@@ -129,8 +131,6 @@ add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_DEBUGGER)
129131
add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_GLOBAL_HEAP_SIZE)
130132
add_cmake_arg(DEPS_LIB_JERRY_ARGS JERRY_ATTR_GLOBAL_HEAP)
131133

132-
separate_arguments(EXTRA_JERRY_CMAKE_PARAMS)
133-
134134
build_lib_name(JERRY_CORE_NAME jerry-core)
135135
build_lib_name(JERRY_LIBM_NAME jerry-math)
136136
build_lib_name(JERRY_EXT_NAME jerry-ext)
@@ -174,8 +174,6 @@ ExternalProject_Add(libjerry
174174
-DJERRY_LOGGING=ON
175175
-DJERRY_LINE_INFO=${JERRY_LINE_INFO}
176176
-DJERRY_VM_EXEC_STOP=ON
177-
-DJERRY_ERROR_MESSAGES=ON
178-
-DENABLE_LTO=${ENABLE_LTO}
179177
${DEPS_LIB_JERRY_ARGS}
180178
${EXTRA_JERRY_CMAKE_PARAMS}
181179
BUILD_BYPRODUCTS ${JERRY_LIB_BUILD_BYPRODUCTS}

0 commit comments

Comments
 (0)