2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2011-03-04 17:17:30 +03:00
|
|
|
project(Assembler C)
|
2011-03-04 17:08:18 +03:00
|
|
|
message("CTEST_FULL_OUTPUT ")
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE 1)
|
2007-07-05 17:05:40 +04:00
|
|
|
|
|
|
|
set(SRCS)
|
|
|
|
|
2011-02-24 22:56:53 +03:00
|
|
|
# (at least) the following toolchains can process assembler files directly
|
2011-02-12 19:21:58 +03:00
|
|
|
# and also generate assembler files from C:
|
2012-08-15 20:55:03 +04:00
|
|
|
if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
|
|
|
|
NOT CMAKE_OSX_ARCHITECTURES)
|
2013-10-02 21:52:48 +04:00
|
|
|
if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX))
|
2011-03-04 16:59:56 +03:00
|
|
|
set(C_FLAGS "${CMAKE_C_FLAGS}")
|
|
|
|
separate_arguments(C_FLAGS)
|
2012-09-21 18:34:10 +04:00
|
|
|
if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")
|
|
|
|
list(APPEND C_FLAGS ${CMAKE_C_SYSROOT_FLAG} ${CMAKE_OSX_SYSROOT})
|
|
|
|
endif()
|
2013-11-01 18:55:58 +04:00
|
|
|
# Clang on OS X, and perhaps other compilers, do not support -g
|
|
|
|
# for both generating and assembling, so drop it from generating.
|
|
|
|
list(REMOVE_ITEM C_FLAGS -g)
|
2011-03-04 17:08:18 +03:00
|
|
|
set(SRCS main.s)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT main.s
|
|
|
|
COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s
|
|
|
|
DEPENDS main.c
|
|
|
|
VERBATIM
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2007-07-05 17:05:40 +04:00
|
|
|
|
2011-02-12 19:21:58 +03:00
|
|
|
|
|
|
|
if(SRCS)
|
2012-06-19 00:19:38 +04:00
|
|
|
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
|
2011-02-12 19:21:58 +03:00
|
|
|
enable_language(ASM OPTIONAL)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2007-07-05 17:05:40 +04:00
|
|
|
message(STATUS "No assembler enabled, using C")
|
|
|
|
set(SRCS main.c)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-07-05 17:05:40 +04:00
|
|
|
|
|
|
|
add_executable(HelloAsm ${SRCS})
|