From 906745bab12e3f07f6d6c43e8a649e86d6f0c24a Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <peter@pcc.me.uk>
Date: Fri, 18 Dec 2009 06:56:20 +0000
Subject: [PATCH 3/3] Added support for the nasm assembler

This patch adds support for the nasm assembler on Windows, Apple
and other Unix-like platforms.
---
 Modules/CMakeASM_NASMInformation.cmake       |   30 ++++++++++++++++++++++++++
 Modules/CMakeDetermineASM_NASMCompiler.cmake |   13 +++++++++++
 Modules/CMakeTestASM_NASMCompiler.cmake      |    9 +++++++
 3 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 Modules/CMakeASM_NASMInformation.cmake
 create mode 100644 Modules/CMakeDetermineASM_NASMCompiler.cmake
 create mode 100644 Modules/CMakeTestASM_NASMCompiler.cmake

diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake
new file mode 100644
index 0000000..c3a071a
--- /dev/null
+++ b/Modules/CMakeASM_NASMInformation.cmake
@@ -0,0 +1,30 @@
+# support for the nasm assembler
+
+SET(ASM_DIALECT "_NASM")
+
+SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS nasm)
+
+if(WIN32)
+  if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT win64)
+  else()
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT win32)
+  endif()
+elseif(APPLE)
+  if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT macho64)
+  else()
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT macho)
+  endif()
+else()
+  if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT elf64)
+  else()
+    SET(CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT elf)
+  endif()
+endif()
+
+SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <FLAGS> -f ${CMAKE_ASM${ASM_DIALECT}_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
+
+INCLUDE(CMakeASMInformation)
+SET(ASM_DIALECT)
diff --git a/Modules/CMakeDetermineASM_NASMCompiler.cmake b/Modules/CMakeDetermineASM_NASMCompiler.cmake
new file mode 100644
index 0000000..3dbfbcc
--- /dev/null
+++ b/Modules/CMakeDetermineASM_NASMCompiler.cmake
@@ -0,0 +1,13 @@
+# Find the nasm assembler
+
+SET(ASM_DIALECT "_NASM")
+
+SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT nasm)
+
+IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
+  FIND_PROGRAM(CMAKE_ASM${ASM_DIALECT}_COMPILER nasm
+    "$ENV{ProgramFiles}/NASM")
+ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
+
+INCLUDE(CMakeDetermineASMCompiler)
+SET(ASM_DIALECT)
diff --git a/Modules/CMakeTestASM_NASMCompiler.cmake b/Modules/CMakeTestASM_NASMCompiler.cmake
new file mode 100644
index 0000000..d5942cb
--- /dev/null
+++ b/Modules/CMakeTestASM_NASMCompiler.cmake
@@ -0,0 +1,9 @@
+# This file is used by EnableLanguage in cmGlobalGenerator to
+# determine that the selected ASM_NASM "compiler"
+# can actually "compile" and link the most basic of programs.   If not, a 
+# fatal error is set and cmake stops processing commands and will not generate
+# any makefiles or projects.
+
+SET(ASM_DIALECT "_NASM")
+INCLUDE(CMakeTestASMCompiler)
+SET(ASM_DIALECT)
-- 
1.6.3.3

