Skip to content

Commit 6f5fa11

Browse files
committed
Bug cppcheck-opensource#2524: Addition of CMake build files - quoting of parameters
Some parameters must be enclosed by quotation marks so that the passed value will be processed as a single string. http://cmake.org/Wiki/CMake/Language_Syntax#CMake_splits_arguments_unless_you_use_quotation_marks_or_escapes. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
1 parent 59cb2d2 commit 6f5fa11

3 files changed

Lines changed: 13 additions & 15 deletions

File tree

‎cli/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ if (CMAKE_COMPILER_IS_GNUCXX)
3434
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wshadow -Wno-long-long -Wfloat-equal -Wcast-qual")
3535
endif (CMAKE_COMPILER_IS_GNUCXX)
3636

37-
include_directories(${CPPCHECK_SOURCE_DIR}/lib
37+
include_directories("${CPPCHECK_SOURCE_DIR}/lib"
3838
"${PCRE_INCLUDE_DIR}"
3939
"${TINYXML_INCLUDE_DIR}")
4040
add_executable(cppcheck ${CPPCHECK_CLI_SOURCES} ${CPPCHECK_LIB_SOURCES})

‎cmake/modules/FindPCRE.cmake‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,18 @@ if (NOT WIN32)
2525
pkg_check_modules(PC_PCRE QUIET libpcre)
2626

2727
set(PCRE_DEFINITIONS ${PC_PCRE_CFLAGS_OTHER})
28-
2928
endif (NOT WIN32)
3029

31-
find_path(PCRE_INCLUDE_DIR pcre.h
32-
HINTS ${PC_PCRE_INCLUDEDIR} ${PC_PCRE_INCLUDE_DIRS}
30+
find_path(PCRE_INCLUDE_DIR "pcre.h"
31+
HINTS "${PC_PCRE_INCLUDEDIR}" ${PC_PCRE_INCLUDE_DIRS}
3332
PATH_SUFFIXES pcre)
3433

35-
find_library(PCRE_PCRE_LIBRARY NAMES pcre pcred HINTS ${PC_PCRE_LIBDIR} ${PC_PCRE_LIBRARY_DIRS})
36-
37-
find_library(PCRE_PCREPOSIX_LIBRARY NAMES pcreposix pcreposixd HINTS ${PC_PCRE_LIBDIR} ${PC_PCRE_LIBRARY_DIRS})
34+
find_library(PCRE_PCRE_LIBRARY NAMES pcre pcred HINTS "${PC_PCRE_LIBDIR}" ${PC_PCRE_LIBRARY_DIRS})
35+
find_library(PCRE_PCREPOSIX_LIBRARY NAMES pcreposix pcreposixd HINTS "${PC_PCRE_LIBDIR}" ${PC_PCRE_LIBRARY_DIRS})
3836

3937
include(FindPackageHandleStandardArgs)
4038
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY PCRE_PCREPOSIX_LIBRARY )
4139

42-
set(PCRE_LIBRARIES ${PCRE_PCRE_LIBRARY} ${PCRE_PCREPOSIX_LIBRARY})
40+
set(PCRE_LIBRARIES "${PCRE_PCRE_LIBRARY}" "${PCRE_PCREPOSIX_LIBRARY}")
4341

4442
mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCREPOSIX_LIBRARY PCRE_PCRE_LIBRARY)

‎cmake/modules/FindXmlTo.cmake‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ macro ( _XMLTO_FILE outfiles mode)
4444
string ( REGEX REPLACE "[[:space:]]" "" XMLTO_FILEEXT_${mode} "${XMLTO_FILEEXT_${mode}}" )
4545
endif ( "${mode}" STREQUAL "man" )
4646

47-
get_filename_component ( dbFilePath ${CMAKE_CURRENT_BINARY_DIR}/${dbFile} PATH )
48-
get_filename_component ( dbFileWE ${dbFile} NAME_WE )
49-
get_filename_component ( dbFileAbsWE ${dbFilePath}/${dbFileWE} ABSOLUTE )
47+
get_filename_component ( dbFilePath "${CMAKE_CURRENT_BINARY_DIR}/${dbFile}" PATH )
48+
get_filename_component ( dbFileWE "${dbFile}" NAME_WE )
49+
get_filename_component ( dbFileAbsWE "${dbFilePath}/${dbFileWE}" ABSOLUTE )
5050

5151
add_custom_command (
52-
OUTPUT ${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}
53-
COMMAND ${XMLTO_EXECUTABLE} ${XMLTO_COMMAND_ARGS} -o ${CMAKE_CURRENT_BINARY_DIR}
52+
OUTPUT "${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}"
53+
COMMAND "${XMLTO_EXECUTABLE}" ${XMLTO_COMMAND_ARGS} -o "${CMAKE_CURRENT_BINARY_DIR}"
5454
${XMLTO_MODE_${mode}} "${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}"
55-
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}
55+
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/${dbFile}"
5656
VERBATIM
5757
)
5858

5959
set ( ${outfiles}
6060
${${outfiles}}
61-
${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}
61+
"${dbFileAbsWE}.${XMLTO_FILEEXT_${mode}}"
6262
)
6363
endforeach ( dbFile )
6464
endmacro ( _XMLTO_FILE outfiles )

0 commit comments

Comments
 (0)