summaryrefslogtreecommitdiffstats
path: root/Tests/VSNASM
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@google.com>2018-06-29 19:54:42 (GMT)
committerDavid Benjamin <davidben@google.com>2018-07-02 22:50:12 (GMT)
commitcb694f8cd65dfb4e73fedcfa04f92c8be7a2bcf6 (patch)
tree1864e4af430fe5f2b33beb0adad881430ba28cdb /Tests/VSNASM
parent9539985fb215439d3d379f60a381e6102ac49e4b (diff)
downloadCMake-cb694f8cd65dfb4e73fedcfa04f92c8be7a2bcf6.zip
CMake-cb694f8cd65dfb4e73fedcfa04f92c8be7a2bcf6.tar.gz
CMake-cb694f8cd65dfb4e73fedcfa04f92c8be7a2bcf6.tar.bz2
VS: Properly quote arguments in nasm.xml
Most arguments were quoted, but some weren't, causing problems if the arguments contained whitespace. In particular, the _STL_EXTRA_DISABLED_WARNINGS value takes spaces and CMake's NASM support applies all add_definitions lines to NASM. The -D flag is missing quotes, so projects using NASM and setting _STL_EXTRA_DISABLED_WARNINGS break in the Visual Studio generator. Likewise, the -o flag is missing quotes, which means filenames with spaces do not work. (The -U flag is unlikely to need quotes, but include them for consistency.) Extend the existing VSNASM test to cover these cases.
Diffstat (limited to 'Tests/VSNASM')
-rw-r--r--Tests/VSNASM/CMakeLists.txt12
-rw-r--r--Tests/VSNASM/bar.asm13
-rw-r--r--Tests/VSNASM/include/foo-proc.asm2
-rw-r--r--Tests/VSNASM/main.c3
4 files changed, 27 insertions, 3 deletions
diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt
index c2e29df..821d022 100644
--- a/Tests/VSNASM/CMakeLists.txt
+++ b/Tests/VSNASM/CMakeLists.txt
@@ -1,10 +1,20 @@
cmake_minimum_required(VERSION 2.8.12)
project(VSNASM C ASM_NASM)
+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DTESTx64)
string(APPEND CMAKE_ASM_NASM_FLAGS " -DTEST2x64")
else()
add_definitions(-DTESTi386)
endif()
+
+# Test quoting for definitions with spaces.
+add_definitions("-DEAX_COMMA_SPACE_ZERO=eax, 0")
+
+# Test quoting for file names with spaces. The file is generated because CMake
+# itself cannot have files with spaces.
+file(READ bar.asm BAR_ASM_CONTENTS)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm" "${BAR_ASM_CONTENTS}")
+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-add_executable(VSNASM main.c foo.asm)
+add_executable(VSNASM main.c foo.asm "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm")
diff --git a/Tests/VSNASM/bar.asm b/Tests/VSNASM/bar.asm
new file mode 100644
index 0000000..b486d82
--- /dev/null
+++ b/Tests/VSNASM/bar.asm
@@ -0,0 +1,13 @@
+section .text
+%ifdef TEST2x64
+global bar
+%else
+global _bar
+%endif
+%ifdef TESTx64
+bar:
+%else
+_bar:
+%endif
+ mov EAX_COMMA_SPACE_ZERO
+ ret
diff --git a/Tests/VSNASM/include/foo-proc.asm b/Tests/VSNASM/include/foo-proc.asm
index 450a791..eb5bb2b 100644
--- a/Tests/VSNASM/include/foo-proc.asm
+++ b/Tests/VSNASM/include/foo-proc.asm
@@ -3,5 +3,5 @@ foo:
%else
_foo:
%endif
- mov eax, 0
+ mov EAX_COMMA_SPACE_ZERO
ret
diff --git a/Tests/VSNASM/main.c b/Tests/VSNASM/main.c
index 18ddb78..b1401b6 100644
--- a/Tests/VSNASM/main.c
+++ b/Tests/VSNASM/main.c
@@ -1,5 +1,6 @@
extern int foo(void);
+extern int bar(void);
int main(void)
{
- return foo();
+ return foo() + bar();
}